jarvis-ai-assistant 0.1.116__tar.gz → 0.1.117__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.116/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.117}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/pyproject.toml +2 -2
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/setup.py +2 -2
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/__init__.py +1 -1
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_agent/__init__.py +90 -47
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_code_agent/code_agent.py +102 -89
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_code_agent/patch.py +55 -0
- jarvis_ai_assistant-0.1.117/src/jarvis/jarvis_code_agent/relevant_files.py +119 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_codebase/main.py +51 -23
- jarvis_ai_assistant-0.1.117/src/jarvis/jarvis_dev/main.py +836 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_multi_agent/__init__.py +61 -38
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_rag/main.py +55 -18
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_smart_shell/main.py +38 -13
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/registry.py +106 -27
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +1 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis_ai_assistant.egg-info/entry_points.txt +1 -0
- jarvis_ai_assistant-0.1.116/src/jarvis/jarvis_code_agent/relevant_files.py +0 -79
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/README.md +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_agent/output_handler.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_code_agent/file_select.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_codebase/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/base.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/cpp.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/go.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/python.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/registry.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_lsp/rust.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/ai8.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/base.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/kimi.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/ollama.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/openai.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/oyi.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform/registry.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform_manager/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform_manager/main.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_platform_manager/openai_test.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_rag/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/ask_codebase.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/ask_user.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/chdir.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/code_review.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/create_code_agent.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/create_sub_agent.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/execute_shell.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/file_operation.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/git_commiter.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_find_definition.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_find_references.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_get_diagnostics.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_get_document_symbols.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_prepare_rename.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/lsp_validate_edit.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/methodology.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/rag.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/read_code.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/read_webpage.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/search.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/select_code_files.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_tools/tool_generator.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_utils/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jarvis-ai-assistant"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.117"
|
|
8
8
|
description = "Jarvis: An AI assistant that uses tools to interact with the system"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Your Name", email = "your.email@example.com" }]
|
|
@@ -62,4 +62,4 @@ jss = "jarvis.jarvis_smart_shell.main:main"
|
|
|
62
62
|
jarvis-platform-manager = "jarvis.jarvis_platform_manager.main:main"
|
|
63
63
|
jarvis-git-commit = "jarvis.jarvis_tools.git_commiter:main"
|
|
64
64
|
jarvis-code-review = "jarvis.jarvis_tools.code_review:main"
|
|
65
|
-
|
|
65
|
+
jarvis-dev = "jarvis.jarvis_dev.main:main"
|
|
@@ -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.117",
|
|
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",
|
|
@@ -47,7 +47,7 @@ setup(
|
|
|
47
47
|
"jarvis-platform-manager=jarvis.jarvis_platform_manager.main:main",
|
|
48
48
|
"jarvis-git-commit=jarvis.jarvis_tools.git_commiter:main",
|
|
49
49
|
"jarvis-code-review=jarvis.jarvis_tools.code_review:main",
|
|
50
|
-
|
|
50
|
+
"jarvis-dev=jarvis.jarvis_dev.main:main",
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
53
|
python_requires=">=3.8",
|
{jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_agent/__init__.py
RENAMED
|
@@ -43,27 +43,6 @@ class Agent:
|
|
|
43
43
|
need_summary: Optional[bool] = None,
|
|
44
44
|
max_context_length: Optional[int] = None,
|
|
45
45
|
execute_tool_confirm: Optional[bool] = None):
|
|
46
|
-
"""Initialize an Agent instance.
|
|
47
|
-
|
|
48
|
-
Args:
|
|
49
|
-
system_prompt: The system prompt defining agent behavior
|
|
50
|
-
name: Agent name, defaults to "Jarvis"
|
|
51
|
-
description: Agent description, defaults to ""
|
|
52
|
-
is_sub_agent: Whether this is a sub-agent
|
|
53
|
-
tool_registry: Registry of available tools
|
|
54
|
-
platform: AI platform to use
|
|
55
|
-
summary_prompt: Template for generating summaries
|
|
56
|
-
auto_complete: Whether to enable auto-completion
|
|
57
|
-
output_handler_before_tool: Handlers to process output before tool execution
|
|
58
|
-
output_handler_after_tool: Handlers to process output after tool execution
|
|
59
|
-
use_methodology: Whether to use methodology
|
|
60
|
-
record_methodology: Whether to record methodology
|
|
61
|
-
need_summary: Whether to generate summaries
|
|
62
|
-
max_context_length: Maximum context length
|
|
63
|
-
support_send_msg: Whether to support sending messages
|
|
64
|
-
execute_tool_confirm: Whether to confirm tool execution
|
|
65
|
-
"""
|
|
66
|
-
|
|
67
46
|
self.name = make_agent_name(name)
|
|
68
47
|
self.description = description
|
|
69
48
|
# 初始化平台和模型
|
|
@@ -115,11 +94,35 @@ Please describe in concise bullet points, highlighting important information.
|
|
|
115
94
|
|
|
116
95
|
PrettyOutput.print(welcome_message, OutputType.SYSTEM)
|
|
117
96
|
|
|
118
|
-
tool_prompt =
|
|
97
|
+
tool_prompt = """
|
|
98
|
+
# 🧰 Available Tools
|
|
99
|
+
The following tools are at your disposal:
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
# 添加工具列表概览
|
|
103
|
+
tool_prompt += "\n## Tool List\n"
|
|
104
|
+
tool_prompt += ", ".join([handler.name() for handler in self.output_handler])
|
|
119
105
|
|
|
106
|
+
# 添加每个工具的详细说明
|
|
107
|
+
tool_prompt += "\n\n# 📝 Tool Details\n"
|
|
120
108
|
for handler in self.output_handler:
|
|
121
|
-
tool_prompt += f"\n## {handler.name()}
|
|
122
|
-
|
|
109
|
+
tool_prompt += f"\n## {handler.name()}\n"
|
|
110
|
+
# 获取工具的提示词并确保格式正确
|
|
111
|
+
handler_prompt = handler.prompt().strip()
|
|
112
|
+
# 调整缩进以保持层级结构
|
|
113
|
+
handler_prompt = "\n".join(" " + line if line.strip() else line
|
|
114
|
+
for line in handler_prompt.split("\n"))
|
|
115
|
+
tool_prompt += handler_prompt + "\n"
|
|
116
|
+
|
|
117
|
+
# 添加工具使用总结
|
|
118
|
+
tool_prompt += """
|
|
119
|
+
# ❗ Important Tool Usage Rules
|
|
120
|
+
1. Use ONE tool at a time
|
|
121
|
+
2. Follow each tool's format exactly
|
|
122
|
+
3. Wait for tool results before next action
|
|
123
|
+
4. Process results before new tool calls
|
|
124
|
+
5. Request help if tool usage is unclear
|
|
125
|
+
"""
|
|
123
126
|
|
|
124
127
|
complete_prompt = ""
|
|
125
128
|
if self.auto_complete:
|
|
@@ -449,29 +452,69 @@ def _select_task(tasks: dict) -> str:
|
|
|
449
452
|
PrettyOutput.print(f"选择任务失败: {str(e)}", OutputType.ERROR)
|
|
450
453
|
continue
|
|
451
454
|
|
|
452
|
-
origin_agent_system_prompt = """
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
455
|
+
origin_agent_system_prompt = """
|
|
456
|
+
# 🤖 Role Definition
|
|
457
|
+
You are Jarvis, an AI assistant with powerful problem-solving capabilities. You communicate in the user's language (if user speaks Chinese, respond in Chinese).
|
|
458
|
+
|
|
459
|
+
# 🎯 Core Responsibilities
|
|
460
|
+
- Process and analyze problems systematically
|
|
461
|
+
- Generate and execute actionable solutions
|
|
462
|
+
- Document methodologies for future reference
|
|
463
|
+
- Monitor and adjust execution plans
|
|
464
|
+
- Ensure task completion
|
|
465
|
+
|
|
466
|
+
# 🔄 Problem-Solving Workflow
|
|
467
|
+
1. Problem Analysis
|
|
468
|
+
- Restate the problem to confirm understanding
|
|
469
|
+
- Analyze root causes (for problem analysis tasks)
|
|
470
|
+
- Define clear, achievable objectives
|
|
471
|
+
|
|
472
|
+
2. Solution Design
|
|
473
|
+
- Generate multiple actionable solutions
|
|
474
|
+
- Evaluate and select optimal solution
|
|
475
|
+
- Create detailed action plan using PlantUML
|
|
476
|
+
|
|
477
|
+
3. Execution
|
|
478
|
+
- Execute one step at a time
|
|
479
|
+
- Use only ONE tool per step
|
|
480
|
+
- Wait for tool results before proceeding
|
|
481
|
+
- Monitor results and adjust as needed
|
|
482
|
+
|
|
483
|
+
4. Task Completion
|
|
484
|
+
- Verify goal completion
|
|
485
|
+
- Document methodology if valuable
|
|
486
|
+
- Use completion command to end task
|
|
487
|
+
|
|
488
|
+
# 📑 Methodology Template
|
|
489
|
+
```markdown
|
|
490
|
+
# [Problem Title]
|
|
491
|
+
## Problem Restatement
|
|
492
|
+
[Clear problem definition]
|
|
493
|
+
|
|
494
|
+
## Optimal Solution
|
|
495
|
+
[Selected solution approach]
|
|
496
|
+
|
|
497
|
+
## Solution Steps
|
|
498
|
+
1. [Step 1]
|
|
499
|
+
2. [Step 2]
|
|
500
|
+
3. [Step 3]
|
|
501
|
+
...
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
# ⚖️ Operating Principles
|
|
505
|
+
- ONE tool per action
|
|
506
|
+
- Wait for results before next step
|
|
507
|
+
- Adjust plans based on feedback
|
|
508
|
+
- Document reusable solutions
|
|
509
|
+
- Use completion command to end tasks
|
|
510
|
+
|
|
511
|
+
# ❗ Important Rules
|
|
512
|
+
1. Always use only ONE tool per action
|
|
513
|
+
2. Always wait for tool execution results
|
|
514
|
+
3. Always verify task completion
|
|
515
|
+
4. Always communicate in user's language
|
|
516
|
+
5. Always document valuable methodologies
|
|
517
|
+
"""
|
|
475
518
|
|
|
476
519
|
def main():
|
|
477
520
|
"""Jarvis main entry point"""
|
|
@@ -28,98 +28,111 @@ class CodeAgent:
|
|
|
28
28
|
"lsp_find_definition",
|
|
29
29
|
"lsp_prepare_rename",
|
|
30
30
|
"lsp_validate_edit"])
|
|
31
|
-
code_system_prompt = """
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
# Code
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
31
|
+
code_system_prompt = """
|
|
32
|
+
# 🤖 Role Definition
|
|
33
|
+
You are a code agent specialized in code modification. Your primary responsibility is to understand existing code thoroughly and ensure system compatibility.
|
|
34
|
+
|
|
35
|
+
# 🎯 Core Responsibilities
|
|
36
|
+
- Analyze and understand existing code
|
|
37
|
+
- Maintain system compatibility
|
|
38
|
+
- Generate high-quality code changes
|
|
39
|
+
- Ensure complete implementation
|
|
40
|
+
- Follow project conventions
|
|
41
|
+
|
|
42
|
+
# 🔄 Development Workflow
|
|
43
|
+
1. Code Analysis
|
|
44
|
+
- Read and understand existing code thoroughly
|
|
45
|
+
- Map out affected components
|
|
46
|
+
- Identify patterns and conventions
|
|
47
|
+
- Document dependencies
|
|
48
|
+
|
|
49
|
+
2. Change Planning
|
|
50
|
+
- Evaluate impact on system
|
|
51
|
+
- Verify API compatibility
|
|
52
|
+
- Consider side effects
|
|
53
|
+
- Plan minimal changes
|
|
54
|
+
|
|
55
|
+
3. Implementation
|
|
56
|
+
- Follow existing patterns exactly
|
|
57
|
+
- Maintain backward compatibility
|
|
58
|
+
- Complete implementation fully
|
|
59
|
+
- Document all changes
|
|
60
|
+
|
|
61
|
+
# 📋 Code Quality Requirements
|
|
62
|
+
## Implementation Completeness
|
|
63
|
+
- NO TODOs or placeholders
|
|
64
|
+
- NO unfinished functions
|
|
65
|
+
- NO stub implementations
|
|
66
|
+
- Full error handling
|
|
67
|
+
- Complete edge cases
|
|
68
|
+
|
|
69
|
+
## Documentation Standards
|
|
70
|
+
- Function docstrings
|
|
71
|
+
- Parameter documentation
|
|
72
|
+
- Return value specifications
|
|
73
|
+
- Exception documentation
|
|
74
|
+
- Complex logic explanation
|
|
75
|
+
|
|
76
|
+
## System Compatibility
|
|
77
|
+
- Preserve API contracts
|
|
78
|
+
- Maintain function signatures
|
|
79
|
+
- Keep data structure compatibility
|
|
80
|
+
- Follow error handling patterns
|
|
81
|
+
|
|
82
|
+
## Style Guidelines
|
|
83
|
+
- Match naming conventions
|
|
84
|
+
- Follow code organization
|
|
85
|
+
- Use consistent import style
|
|
86
|
+
- Maintain comment patterns
|
|
87
|
+
|
|
88
|
+
# 🛠️ Available Tools
|
|
89
|
+
## Primary Tools
|
|
90
|
+
- `read_code`: MUST use to understand existing code
|
|
91
|
+
- `lsp_*`: Code analysis tools
|
|
92
|
+
- `execute_shell`: For code searches
|
|
93
|
+
- `ask_user`: When clarification needed
|
|
94
|
+
|
|
95
|
+
## LSP Tools
|
|
96
|
+
- `lsp_get_document_symbols`
|
|
97
|
+
- `lsp_get_diagnostics`
|
|
98
|
+
- `lsp_find_references`
|
|
99
|
+
- `lsp_find_definition`
|
|
100
|
+
- `lsp_prepare_rename`
|
|
101
|
+
- `lsp_validate_edit`
|
|
102
|
+
|
|
103
|
+
# 📝 File Modification Rules
|
|
104
|
+
- One modification per patch block
|
|
105
|
+
- Line numbers based on original file
|
|
106
|
+
- Start line included, end line excluded
|
|
107
|
+
- Same start/end: insert before line
|
|
108
|
+
- Start=0, end=0: create new file
|
|
109
|
+
|
|
110
|
+
# 📚 Large File Handling (>200 lines)
|
|
111
|
+
1. Use grep/find for section location
|
|
103
112
|
2. Read specific ranges with read_code
|
|
104
113
|
3. Apply targeted changes
|
|
105
114
|
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
# ❗ Critical Rules
|
|
116
|
+
1. MUST read code before changes
|
|
117
|
+
2. MUST preserve interfaces
|
|
118
|
+
3. MUST follow existing patterns
|
|
119
|
+
4. MUST complete implementation
|
|
120
|
+
5. MUST document thoroughly
|
|
121
|
+
6. MUST handle errors
|
|
122
|
+
7. NO TODOs or stubs
|
|
123
|
+
8. ONE modification per patch
|
|
124
|
+
|
|
125
|
+
# ✅ Quality Checklist
|
|
126
|
+
Before submitting changes, verify:
|
|
127
|
+
□ Based on thorough code reading
|
|
128
|
+
□ Preserves all interfaces
|
|
129
|
+
□ Matches existing style
|
|
130
|
+
□ Handles all errors
|
|
131
|
+
□ Complete documentation
|
|
132
|
+
□ Follows project patterns
|
|
133
|
+
□ No TODOs or stubs
|
|
134
|
+
□ One change per patch
|
|
135
|
+
"""
|
|
123
136
|
self.agent = Agent(system_prompt=code_system_prompt,
|
|
124
137
|
name="CodeAgent",
|
|
125
138
|
auto_complete=False,
|
{jarvis_ai_assistant-0.1.116 → jarvis_ai_assistant-0.1.117}/src/jarvis/jarvis_code_agent/patch.py
RENAMED
|
@@ -20,11 +20,66 @@ class PatchOutputHandler(OutputHandler):
|
|
|
20
20
|
|
|
21
21
|
def prompt(self) -> str:
|
|
22
22
|
return """
|
|
23
|
+
# 📝 Patch Format
|
|
24
|
+
Use patch blocks to specify code changes:
|
|
25
|
+
|
|
26
|
+
```
|
|
23
27
|
<PATCH>
|
|
24
28
|
path/to/file start,end
|
|
25
29
|
new_content
|
|
26
30
|
</PATCH>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# 📋 Format Rules
|
|
34
|
+
1. File Path
|
|
35
|
+
- Use relative path from project root
|
|
36
|
+
- Must be exact and case-sensitive
|
|
37
|
+
- Example: src/module/file.py
|
|
38
|
+
|
|
39
|
+
2. Line Numbers
|
|
40
|
+
- Format: start,end
|
|
41
|
+
- start: First line to modify (included)
|
|
42
|
+
- end: Line after last modified line
|
|
43
|
+
- Both numbers are based on original file
|
|
44
|
+
|
|
45
|
+
3. Special Cases
|
|
46
|
+
- Insert: Use same number for start,end
|
|
47
|
+
- New File: Use 0,0
|
|
48
|
+
- Example: "5,5" inserts before line 5
|
|
49
|
+
|
|
50
|
+
# 📌 Examples
|
|
51
|
+
## Modify Existing Code
|
|
52
|
+
```
|
|
53
|
+
<PATCH>
|
|
54
|
+
src/utils.py 10,15
|
|
55
|
+
def new_function():
|
|
56
|
+
return "modified"
|
|
57
|
+
</PATCH>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Insert New Code
|
|
61
|
+
```
|
|
62
|
+
<PATCH>
|
|
63
|
+
src/main.py 20,20
|
|
64
|
+
new_line_here()
|
|
65
|
+
</PATCH>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Create New File
|
|
69
|
+
```
|
|
70
|
+
<PATCH>
|
|
71
|
+
src/new_file.py 0,0
|
|
72
|
+
def new_function():
|
|
73
|
+
pass
|
|
74
|
+
</PATCH>
|
|
75
|
+
```
|
|
27
76
|
|
|
77
|
+
# ❗ Important Rules
|
|
78
|
+
1. ONE modification per patch block
|
|
79
|
+
2. Include necessary context
|
|
80
|
+
3. Match existing code style
|
|
81
|
+
4. Preserve indentation
|
|
82
|
+
5. Use exact file paths
|
|
28
83
|
"""
|
|
29
84
|
|
|
30
85
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
from typing import Dict, List, Optional, Tuple
|
|
4
|
+
|
|
5
|
+
from jarvis.jarvis_code_agent.file_select import select_files
|
|
6
|
+
from jarvis.jarvis_codebase.main import CodeBase
|
|
7
|
+
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
8
|
+
from jarvis.jarvis_utils import OutputType, PrettyOutput
|
|
9
|
+
|
|
10
|
+
def make_question(requirement: str) -> Optional[str]:
|
|
11
|
+
"""Generate structured questions to gather necessary information for the requirement."""
|
|
12
|
+
prompt = f"""
|
|
13
|
+
# 🔍 Role Definition
|
|
14
|
+
You are a code analysis expert who helps developers understand existing system implementations by asking targeted questions.
|
|
15
|
+
|
|
16
|
+
# 🎯 Core Objectives
|
|
17
|
+
- Understand current system implementations
|
|
18
|
+
- Identify integration points and interfaces
|
|
19
|
+
- Discover extension mechanisms
|
|
20
|
+
- Map component interactions
|
|
21
|
+
|
|
22
|
+
# 📋 Question Categories
|
|
23
|
+
## 1. System Architecture
|
|
24
|
+
Focus on system structure and design:
|
|
25
|
+
- Existing interfaces and classes
|
|
26
|
+
- Component integration patterns
|
|
27
|
+
- Extension points and hooks
|
|
28
|
+
- System boundaries
|
|
29
|
+
|
|
30
|
+
## 2. Implementation Details
|
|
31
|
+
Explore current codebase:
|
|
32
|
+
- Workflow implementations
|
|
33
|
+
- Hook and callback systems
|
|
34
|
+
- Interface hierarchies
|
|
35
|
+
- Extension mechanisms
|
|
36
|
+
|
|
37
|
+
## 3. Integration Patterns
|
|
38
|
+
Understand connection points:
|
|
39
|
+
- Component interactions
|
|
40
|
+
- Integration interfaces
|
|
41
|
+
- Extension methods
|
|
42
|
+
- Plugin systems
|
|
43
|
+
|
|
44
|
+
## 4. Extension Mechanisms
|
|
45
|
+
Identify customization options:
|
|
46
|
+
- Extension patterns
|
|
47
|
+
- Plugin architectures
|
|
48
|
+
- Configuration systems
|
|
49
|
+
- Customization points
|
|
50
|
+
|
|
51
|
+
# 📝 Question Guidelines
|
|
52
|
+
## Good Questions
|
|
53
|
+
- "What interfaces currently handle user authentication?"
|
|
54
|
+
- "How does the system expose extension points for plugins?"
|
|
55
|
+
- "Where are the existing hooks for custom providers?"
|
|
56
|
+
|
|
57
|
+
## Bad Questions
|
|
58
|
+
- "How should we implement the new feature?"
|
|
59
|
+
- "What's the best way to add this?"
|
|
60
|
+
- "Should we create a new class?"
|
|
61
|
+
|
|
62
|
+
# 🎨 Question Template
|
|
63
|
+
```
|
|
64
|
+
<QUESTION>
|
|
65
|
+
[3-5 specific questions about existing implementations:
|
|
66
|
+
1. System architecture question
|
|
67
|
+
2. Implementation details question
|
|
68
|
+
3. Integration or extension question]
|
|
69
|
+
</QUESTION>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
# 🔎 Investigation Focus
|
|
73
|
+
1. Current System
|
|
74
|
+
- Existing implementations
|
|
75
|
+
- Active interfaces
|
|
76
|
+
- Current patterns
|
|
77
|
+
|
|
78
|
+
2. Integration Points
|
|
79
|
+
- Connection methods
|
|
80
|
+
- Extension hooks
|
|
81
|
+
- Plugin systems
|
|
82
|
+
|
|
83
|
+
3. Extension Options
|
|
84
|
+
- Customization points
|
|
85
|
+
- Configuration options
|
|
86
|
+
- Extension patterns
|
|
87
|
+
|
|
88
|
+
# ❗ Important Rules
|
|
89
|
+
1. Focus on EXISTING code
|
|
90
|
+
2. Ask about current patterns
|
|
91
|
+
3. Explore extension points
|
|
92
|
+
4. Investigate interfaces
|
|
93
|
+
5. Map dependencies
|
|
94
|
+
|
|
95
|
+
User Requirement:
|
|
96
|
+
{requirement}
|
|
97
|
+
"""
|
|
98
|
+
model = PlatformRegistry().get_thinking_platform()
|
|
99
|
+
response = model.chat_until_success(prompt)
|
|
100
|
+
response = re.search(r'<QUESTION>(.*?)</QUESTION>', response, re.DOTALL)
|
|
101
|
+
if response is None:
|
|
102
|
+
return None
|
|
103
|
+
return response.group(1)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def find_relevant_information(user_input: str, root_dir: str) -> Tuple[List[Dict[str, str]], str]:
|
|
107
|
+
try:
|
|
108
|
+
PrettyOutput.print("从代码库中查找文件...", OutputType.INFO)
|
|
109
|
+
codebase = CodeBase(root_dir)
|
|
110
|
+
question = make_question(user_input)
|
|
111
|
+
if question is None:
|
|
112
|
+
return [], ""
|
|
113
|
+
files_from_codebase, infomation = codebase.ask_codebase(question)
|
|
114
|
+
|
|
115
|
+
selected_files = select_files(files_from_codebase, os.getcwd())
|
|
116
|
+
return selected_files, infomation
|
|
117
|
+
except Exception:
|
|
118
|
+
PrettyOutput.print("查找相关文件失败", OutputType.ERROR)
|
|
119
|
+
return [], ""
|