jarvis-ai-assistant 0.1.116__py3-none-any.whl → 0.1.118__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 +90 -47
- jarvis/jarvis_code_agent/code_agent.py +102 -89
- jarvis/jarvis_code_agent/patch.py +55 -0
- jarvis/jarvis_code_agent/relevant_files.py +81 -41
- jarvis/jarvis_codebase/main.py +49 -23
- jarvis/jarvis_dev/main.py +836 -0
- jarvis/jarvis_multi_agent/__init__.py +61 -38
- jarvis/jarvis_rag/main.py +55 -18
- jarvis/jarvis_smart_shell/main.py +38 -13
- jarvis/jarvis_tools/registry.py +99 -27
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/METADATA +1 -1
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/RECORD +17 -16
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/entry_points.txt +1 -0
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.116.dist-info → jarvis_ai_assistant-0.1.118.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
|
@@ -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,
|
|
@@ -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
|
|
|
@@ -9,51 +9,91 @@ from jarvis.jarvis_utils import OutputType, PrettyOutput
|
|
|
9
9
|
|
|
10
10
|
def make_question(requirement: str) -> Optional[str]:
|
|
11
11
|
"""Generate structured questions to gather necessary information for the requirement."""
|
|
12
|
-
prompt = f"""
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Extension mechanisms and patterns
|
|
16
|
-
- Related components and their interactions
|
|
17
|
-
|
|
18
|
-
Key Instructions:
|
|
19
|
-
1. Focus on understanding the EXISTING system
|
|
20
|
-
2. Ask about interfaces, hooks, and extension points
|
|
21
|
-
3. Investigate integration patterns and dependencies
|
|
22
|
-
4. Explore current implementation details
|
|
23
|
-
|
|
24
|
-
For example:
|
|
25
|
-
BAD: "How should we implement the new feature?"
|
|
26
|
-
GOOD: "What are the existing extension points in the authentication system that we can use to add the new OAuth provider? Specifically, how does AuthProvider interface work and where is it currently used?"
|
|
27
|
-
|
|
28
|
-
Consider these investigation aspects:
|
|
29
|
-
|
|
30
|
-
1. System Architecture:
|
|
31
|
-
- "What are the existing interfaces/classes that handle [functionality]?"
|
|
32
|
-
- "How is [feature] currently integrated with other components?"
|
|
33
|
-
- "Where are the extension points for [system component]?"
|
|
34
|
-
|
|
35
|
-
2. Implementation Details:
|
|
36
|
-
- "What is the current workflow for [operation] in the system?"
|
|
37
|
-
- "How does the system expose hooks/callbacks for [functionality]?"
|
|
38
|
-
- "Which interfaces/abstract classes are used for [feature] extensibility?"
|
|
39
|
-
|
|
40
|
-
3. Integration Patterns:
|
|
41
|
-
- "How do existing components integrate with [system part]?"
|
|
42
|
-
- "What are the current integration points for [feature]?"
|
|
43
|
-
- "How does the system handle extensions to [component]?"
|
|
44
|
-
|
|
45
|
-
4. Extension Mechanisms:
|
|
46
|
-
- "What patterns are used for extending [functionality]?"
|
|
47
|
-
- "How do existing plugins/extensions connect to [system]?"
|
|
48
|
-
- "Where are the configuration points for [feature] customization?"
|
|
12
|
+
prompt = f"""
|
|
13
|
+
# 🔍 Role Definition
|
|
14
|
+
You are a code analysis expert who helps developers understand existing system implementations by asking targeted questions.
|
|
49
15
|
|
|
50
|
-
|
|
51
|
-
|
|
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?"
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
# 🎨 Question Template
|
|
63
|
+
```
|
|
54
64
|
<QUESTION>
|
|
55
|
-
[
|
|
65
|
+
[3-5 specific questions about existing implementations:
|
|
66
|
+
1. System architecture question
|
|
67
|
+
2. Implementation details question
|
|
68
|
+
3. Integration or extension question]
|
|
56
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}
|
|
57
97
|
"""
|
|
58
98
|
model = PlatformRegistry().get_thinking_platform()
|
|
59
99
|
response = model.chat_until_success(prompt)
|
jarvis/jarvis_codebase/main.py
CHANGED
|
@@ -787,23 +787,46 @@ Please provide 10 search-optimized expressions in the specified format.
|
|
|
787
787
|
|
|
788
788
|
if not files_from_codebase:
|
|
789
789
|
PrettyOutput.print("没有找到相关文件", output_type=OutputType.WARNING)
|
|
790
|
-
return [],""
|
|
790
|
+
return [], ""
|
|
791
791
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
792
|
+
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]
|
|
813
|
+
answer: |
|
|
814
|
+
[Detailed technical answer with:
|
|
815
|
+
- Implementation details
|
|
816
|
+
- Code examples (if relevant)
|
|
817
|
+
- Missing information (if any)
|
|
818
|
+
- Related technical concepts]
|
|
819
|
+
|
|
820
|
+
- question: [Follow-up question if needed]
|
|
821
|
+
answer: |
|
|
822
|
+
[Additional technical details]
|
|
823
|
+
|
|
824
|
+
# 🔍 Analysis Context
|
|
803
825
|
Question: {query}
|
|
804
826
|
|
|
805
|
-
Relevant
|
|
827
|
+
Relevant Code Files (by relevance):
|
|
806
828
|
"""
|
|
829
|
+
|
|
807
830
|
# Add context with length control
|
|
808
831
|
available_count = self.max_token_count - get_context_token_count(prompt) - 1000 # Reserve space for answer
|
|
809
832
|
current_count = 0
|
|
@@ -812,10 +835,11 @@ Relevant code files (ordered by relevance):
|
|
|
812
835
|
try:
|
|
813
836
|
content = open(path["file"], "r", encoding="utf-8").read()
|
|
814
837
|
file_content = f"""
|
|
815
|
-
File: {path["file"]}
|
|
816
|
-
|
|
838
|
+
## File: {path["file"]}
|
|
839
|
+
```
|
|
817
840
|
{content}
|
|
818
|
-
|
|
841
|
+
```
|
|
842
|
+
---
|
|
819
843
|
"""
|
|
820
844
|
if current_count + get_context_token_count(file_content) > available_count:
|
|
821
845
|
PrettyOutput.print(
|
|
@@ -831,17 +855,19 @@ Content:
|
|
|
831
855
|
PrettyOutput.print(f"读取 {path} 失败: {str(e)}",
|
|
832
856
|
output_type=OutputType.ERROR)
|
|
833
857
|
continue
|
|
834
|
-
|
|
835
|
-
model = PlatformRegistry.get_global_platform_registry().get_thinking_platform()
|
|
836
858
|
|
|
837
859
|
prompt += """
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
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
|
|
843
867
|
"""
|
|
844
868
|
|
|
869
|
+
model = PlatformRegistry.get_global_platform_registry().get_thinking_platform()
|
|
870
|
+
|
|
845
871
|
return files_from_codebase, model.chat_until_success(prompt)
|
|
846
872
|
|
|
847
873
|
def is_index_generated(self) -> bool:
|