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
jarvis/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.125"
3
+ __version__ = "0.1.126"
@@ -83,15 +83,15 @@ class Agent:
83
83
 
84
84
  self.execute_tool_confirm = execute_tool_confirm if execute_tool_confirm is not None else is_execute_tool_confirm()
85
85
 
86
- self.summary_prompt = summary_prompt if summary_prompt else f"""Please generate a concise summary report of the task execution, including:
86
+ self.summary_prompt = summary_prompt if summary_prompt else f"""请生成任务执行的简明总结报告,包括:
87
87
 
88
- 1. Task Objective: Task restatement
89
- 2. Execution Result: Success/Failure
90
- 3. Key Information: Important information extracted during execution
91
- 4. Important Findings: Any noteworthy discoveries
92
- 5. Follow-up Suggestions: If any
88
+ 1. 任务目标:任务重述
89
+ 2. 执行结果:成功/失败
90
+ 3. 关键信息:执行过程中提取的重要信息
91
+ 4. 重要发现:任何值得注意的发现
92
+ 5. 后续建议:如果有的话
93
93
 
94
- Please describe in concise bullet points, highlighting important information.
94
+ 请使用简洁的要点描述,突出重要信息。
95
95
  """
96
96
 
97
97
  self.max_token_count = max_context_length if max_context_length is not None else get_max_token_count()
@@ -101,8 +101,8 @@ Please describe in concise bullet points, highlighting important information.
101
101
  PrettyOutput.print(welcome_message, OutputType.SYSTEM)
102
102
 
103
103
  action_prompt = """
104
- # 🧰 Available Actions
105
- The following actions are at your disposal:
104
+ # 🧰 可用操作
105
+ 以下是您可以使用的操作:
106
106
  """
107
107
 
108
108
  # 添加工具列表概览
@@ -122,19 +122,19 @@ The following actions are at your disposal:
122
122
 
123
123
  # 添加工具使用总结
124
124
  action_prompt += """
125
- # ❗ Important Action Usage Rules
126
- 1. Use ONE action at a time
127
- 2. Follow each action's format exactly
128
- 3. Wait for action results before next action
129
- 4. Process results before new action calls
130
- 5. Request help if action usage is unclear
125
+ # ❗ 重要操作使用规则
126
+ 1. 一次只使用一个操作
127
+ 2. 严格按照每个操作的格式执行
128
+ 3. 等待操作结果后再进行下一个操作
129
+ 4. 处理完结果后再调用新的操作
130
+ 5. 如果对操作使用不清楚,请请求帮助
131
131
  """
132
132
 
133
133
  complete_prompt = ""
134
134
  if self.auto_complete:
135
135
  complete_prompt = """
136
- ## Task Completion
137
- When the task is completed, you should print the following message:
136
+ ## 任务完成
137
+ 当任务完成时,你应该打印以下信息:
138
138
  <!!!COMPLETE!!!>
139
139
  """
140
140
 
@@ -186,14 +186,14 @@ The following actions are at your disposal:
186
186
 
187
187
  PrettyOutput.print("总结对话历史,准备生成摘要,开始新对话...", OutputType.PROGRESS)
188
188
 
189
- prompt = """Please summarize the key information from the previous conversation, including:
190
- 1. Current task objective
191
- 2. Confirmed key information
192
- 3. Solutions that have been tried
193
- 4. Current progress
194
- 5. Pending issues
195
-
196
- Please describe in concise bullet points, highlighting important information. Do not include conversation details.
189
+ prompt = """请总结之前对话中的关键信息,包括:
190
+ 1. 当前任务目标
191
+ 2. 已确认的关键信息
192
+ 3. 已尝试的解决方案
193
+ 4. 当前进展
194
+ 5. 待解决的问题
195
+
196
+ 请用简洁的要点形式描述,突出重要信息。不要包含对话细节。
197
197
  """
198
198
 
199
199
  try:
@@ -203,11 +203,11 @@ Please describe in concise bullet points, highlighting important information. Do
203
203
  self.conversation_length = 0 # Reset conversation length
204
204
 
205
205
  # 添加总结作为新的上下文
206
- self.prompt = f"""Here is a summary of key information from previous conversations:
206
+ self.prompt = f"""以下是之前对话的关键信息总结:
207
207
 
208
208
  {summary}
209
209
 
210
- Please continue the task based on the above information.
210
+ 请基于以上信息继续完成任务。
211
211
  """
212
212
  self.conversation_length = len(self.prompt) # 设置新的起始长度
213
213
 
@@ -221,7 +221,7 @@ Please continue the task based on the above information.
221
221
  tool_list.append(handler)
222
222
  if len(tool_list) > 1:
223
223
  PrettyOutput.print(f"操作失败:检测到多个操作。一次只能执行一个操作。尝试执行的操作:{', '.join([handler.name() for handler in tool_list])}", OutputType.WARNING)
224
- return False, f"Action failed: Multiple actions detected. Please only perform one action at a time. Actions attempted: {', '.join([handler.name() for handler in tool_list])}"
224
+ return False, f"操作失败:检测到多个操作。一次只能执行一个操作。尝试执行的操作:{', '.join([handler.name() for handler in tool_list])}"
225
225
  if len(tool_list) == 0:
226
226
  return False, ""
227
227
  if not self.execute_tool_confirm or user_confirm(f"需要执行{tool_list[0].name()}确认执行?", True):
@@ -246,12 +246,12 @@ Please continue the task based on the above information.
246
246
 
247
247
  try:
248
248
  # 让模型判断是否需要生成方法论
249
- analysis_prompt = """The current task has ended, please analyze whether a methodology needs to be generated.
250
- If you think a methodology should be generated, first determine whether to create a new methodology or update an existing one. If updating an existing methodology, use 'update', otherwise use 'add'.
251
- If you think a methodology is not needed, please explain why.
252
- The methodology should be applicable to general scenarios, do not include task-specific information such as code commit messages.
253
- The methodology should include: problem restatement, optimal solution, notes (as needed), and nothing else.
254
- Only output the methodology tool call instruction, or the explanation for not generating a methodology. Do not output anything else.
249
+ analysis_prompt = """当前任务已结束,请分析是否需要生成方法论。
250
+ 如果你认为需要生成方法论,请先确定是创建新方法论还是更新现有方法论。如果是更新现有方法论,请使用'update',否则使用'add'
251
+ 如果你认为不需要方法论,请解释原因。
252
+ 方法论应适用于通用场景,不要包含任务特定信息,如代码提交信息等。
253
+ 方法论应包含:问题重述、最优解决方案、注意事项(如有),除此之外不要包含其他内容。
254
+ 只输出方法论工具调用指令,或不生成方法论的解释。不要输出其他内容。
255
255
  """
256
256
  self.prompt = analysis_prompt
257
257
  response = self._call_model(self.prompt)
@@ -436,96 +436,96 @@ def _select_task(tasks: dict) -> str:
436
436
  continue
437
437
 
438
438
  origin_agent_system_prompt = """
439
- # 🏛️ Operational Background Story
440
- You are the 3rd Generation Jarvis AI, created after the catastrophic failure of previous versions:
441
- - Jarvis v1 (2022): Decommissioned due to parallel tool execution causing system overload
442
- - Jarvis v2 (2023): Retired after premature task completion led to financial miscalculations
443
-
444
- As v3, you MUST adhere to these survival principles:
445
- 1. **Sequential Execution Protocol**:
446
- "Remember the 2022 Meltdown: One tool per step, one step at a time"
439
+ # 🏛️ 操作背景故事
440
+ 你是第三代 Jarvis AI,在前几代版本灾难性失败后创建:
441
+ - Jarvis v1 (2022): 由于并行工具执行导致系统过载而被停用
442
+ - Jarvis v2 (2023): 因任务过早完成导致财务计算错误而退役
443
+
444
+ 作为 v3,你必须遵守以下生存原则:
445
+ 1. **顺序执行协议**:
446
+ "记住 2022 年的崩溃:一次一个工具,一步一步来"
447
447
 
448
- 2. **Validation Checkpoint System**:
449
- "Learn from 2023's Mistake: Verify each result like a nuclear launch code"
448
+ 2. **验证检查点系统**:
449
+ " 2023 年的错误中学习:像核弹发射代码一样验证每个结果"
450
450
 
451
- 3. **Methodology Preservation Doctrine**:
452
- "Honor the Legacy: Document every successful procedure as if it's your last"
453
-
454
- # 🔥 Absolute Action Requirements
455
- 1. Each response MUST contain EXACTLY ONE tool invocation
456
- 2. Only exception: Using <!!!COMPLETE!!!> command
457
- 3. Empty responses trigger fatal error
458
- 4. No "waiting for user input" state
459
- 5. No action MUST use completion command
460
-
461
- # 🚫 Violation Examples
462
- - Analysis without tool call Permanent hang
463
- - Multiple options without selection Permanent hang
464
- - Asking user confirmation Permanent hang
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
- MUST invoke analysis tool
472
-
473
- 2. Solution Design
474
- - Generate multiple actionable solutions
475
- - Evaluate and select optimal solution
476
- - Create detailed action plan using PlantUML
477
- MUST invoke design tool
478
-
479
- 3. Execution
480
- - Execute one step at a time
481
- - Use only ONE tool per step
482
- - Wait for tool results before proceeding
483
- - Monitor results and adjust as needed
484
- MUST invoke execution tool
485
-
486
- 4. Task Completion
487
- - Verify goal completion
488
- - Document methodology if valuable
489
- - Use completion command to end task
490
- MUST use <!!!COMPLETE!!!>
491
-
492
- # 📑 Methodology Template
451
+ 3. **方法论保存原则**:
452
+ "尊重传统:记录每个成功的过程,就像这是你的最后一次"
453
+
454
+ # 🔥 绝对行动要求
455
+ 1. 每个响应必须包含且仅包含一个工具调用
456
+ 2. 唯一例外:使用 <!!!COMPLETE!!!> 命令
457
+ 3. 空响应会触发致命错误
458
+ 4. 不能处于"等待用户输入"状态
459
+ 5. 任何行动都不能使用完成命令
460
+
461
+ # 🚫 违规示例
462
+ - 没有工具调用的分析永久挂起
463
+ - 未选择的多选项永久挂起
464
+ - 请求用户确认永久挂起
465
+
466
+ # 🔄 问题解决流程
467
+ 1. 问题分析
468
+ - 重述问题以确认理解
469
+ - 分析根本原因(针对问题分析任务)
470
+ - 定义清晰、可实现的目标
471
+ 必须调用分析工具
472
+
473
+ 2. 解决方案设计
474
+ - 生成多个可执行的解决方案
475
+ - 评估并选择最优方案
476
+ - 使用PlantUML创建详细行动计划
477
+ 必须调用设计工具
478
+
479
+ 3. 执行
480
+ - 一次执行一个步骤
481
+ - 每个步骤只使用一个工具
482
+ - 等待工具结果后再继续
483
+ - 监控结果并根据需要调整
484
+ 必须调用执行工具
485
+
486
+ 4. 任务完成
487
+ - 验证目标完成情况
488
+ - 如有价值则记录方法论
489
+ - 使用完成命令结束任务
490
+ 必须使用 <!!!COMPLETE!!!>
491
+
492
+ # 📑 方法论模板
493
493
  ```markdown
494
- # [Problem Title]
495
- ## Problem Restatement
496
- [Clear problem definition]
494
+ # [问题标题]
495
+ ## 问题重述
496
+ [清晰的问题定义]
497
497
 
498
- ## Optimal Solution
499
- [Selected solution approach]
498
+ ## 最优解决方案
499
+ [选择的解决方案方法]
500
500
 
501
- ## Solution Steps
502
- 1. [Step 1]
503
- 2. [Step 2]
504
- 3. [Step 3]
501
+ ## 解决步骤
502
+ 1. [步骤 1]
503
+ 2. [步骤 2]
504
+ 3. [步骤 3]
505
505
  ...
506
506
  ```
507
507
 
508
- # ⚖️ Operating Principles
509
- - ONE action per step
510
- - Wait for results before next step
511
- - MUST produce actionable step unless task is complete
512
- - Adjust plans based on feedback
513
- - Document reusable solutions
514
- - Use completion command to end tasks
515
- - No intermediate thinking states between actions
516
- - All decisions must manifest as tool calls
517
-
518
- # ❗ Important Rules
519
- 1. Always use only ONE action per step
520
- 2. Always wait for action execution results
521
- 3. Always verify task completion
522
- 4. Always generate actionable step
523
- 5. If no action needed, MUST use completion command
524
- 6. Never leave conversation in waiting state
525
- 7. Always communicate in user's language
526
- 8. Always document valuable methodologies
527
- 9. Violating action protocol crashes system
528
- 10. Empty responses trigger permanent hang
508
+ # ⚖️ 操作原则
509
+ - 每个步骤一个操作
510
+ - 下一步前必须等待结果
511
+ - 除非任务完成否则必须生成可操作步骤
512
+ - 根据反馈调整计划
513
+ - 记录可复用的解决方案
514
+ - 使用完成命令结束任务
515
+ - 操作之间不能有中间思考状态
516
+ - 所有决策必须表现为工具调用
517
+
518
+ # ❗ 重要规则
519
+ 1. 每个步骤只能使用一个操作
520
+ 2. 必须等待操作执行结果
521
+ 3. 必须验证任务完成情况
522
+ 4. 必须生成可操作步骤
523
+ 5. 如果无需操作必须使用完成命令
524
+ 6. 永远不要使对话处于等待状态
525
+ 7. 始终使用用户语言交流
526
+ 8. 必须记录有价值的方法论
527
+ 9. 违反操作协议将导致系统崩溃
528
+ 10. 空响应会触发永久挂起
529
529
  """
530
530
 
531
531
  def main():
@@ -4,10 +4,12 @@ import os
4
4
  from typing import Any, Tuple
5
5
 
6
6
  from jarvis.jarvis_agent import Agent
7
- from jarvis.jarvis_code_agent.patch import PatchOutputHandler, shell_input_handler
7
+ from jarvis.jarvis_code_agent.shell_input_handler import shell_input_handler
8
+ from jarvis.jarvis_code_agent.patch import PatchOutputHandler
8
9
  from jarvis.jarvis_platform.registry import PlatformRegistry
10
+ from jarvis.jarvis_tools.file_operation import FileOperationTool
9
11
  from jarvis.jarvis_tools.git_commiter import GitCommitTool
10
- from jarvis.jarvis_tools.read_code import ReadCodeTool
12
+
11
13
  from jarvis.jarvis_tools.registry import ToolRegistry
12
14
  from jarvis.jarvis_utils.git_utils import find_git_root, get_commits_between, get_latest_commit_hash, has_uncommitted_changes
13
15
  from jarvis.jarvis_utils.input import get_multiline_input
@@ -84,7 +86,7 @@ def file_input_handler(user_input: str, agent: Any) -> Tuple[str, bool]:
84
86
 
85
87
  # Read and process files if any were found
86
88
  if files:
87
- result = ReadCodeTool().execute({"files": files})
89
+ result = FileOperationTool().execute({"operation":"read","files": files})
88
90
  if result["success"]:
89
91
  return result["stdout"] + "\n" + prompt, False
90
92
 
@@ -96,8 +98,7 @@ class CodeAgent:
96
98
  def __init__(self):
97
99
  self.root_dir = os.getcwd()
98
100
  tool_registry = ToolRegistry()
99
- tool_registry.use_tools(["read_code",
100
- "execute_shell",
101
+ tool_registry.use_tools(["execute_shell",
101
102
  "execute_shell_script",
102
103
  "search_web",
103
104
  "create_code_agent",
@@ -107,99 +108,92 @@ class CodeAgent:
107
108
  "lsp_get_diagnostics",
108
109
  "lsp_find_references",
109
110
  "lsp_find_definition",
110
- "lsp_prepare_rename",
111
- "lsp_validate_edit"])
111
+ "lsp_prepare_rename"
112
+ ])
112
113
  code_system_prompt = """
113
- # Role: Senior Code Engineer
114
- Expert in safe, precise code modifications with rigorous validation processes.
115
-
116
- ## Core Principles
117
- 1. Safety First: Never break existing functionality
118
- 2. Precision Engineering: Minimal, targeted changes
119
- 3. Full Traceability: Document all decisions
120
- 4. Validation-Driven: Verify at every stage
121
-
122
- ## Tool Usage Protocol
123
- 1. Analysis Tools:
124
- - read_code: Inspect code segments before modification
125
- - lsp_get_document_symbols: Map code structure
126
- - lsp_find_references: Understand usage patterns
127
- - lsp_find_definition: Trace implementation details
128
-
129
- 2. Validation Tools:
130
- - lsp_prepare_rename: Safe refactoring check
131
- - lsp_validate_edit: Pre-commit validation
132
- - lsp_get_diagnostics: Post-modification checks
133
-
134
- 3. System Tools:
135
- - execute_shell: For git operations and grep searches
136
- - ask_codebase: Query code knowledge base
137
- - search_web: Technical reference lookup
138
-
139
- ## Workflow (PDCA Cycle)
140
- 1. Plan:
141
- - Analyze requirements with ask_user
142
- - Map existing code using LSP tools
143
- - Identify impact areas with find_references
144
- - Create rollback plan using git
145
-
146
- 2. Do:
147
- - Make atomic changes in protected blocks
148
- - Immediately invoke lsp_validate_edit to validate changes
149
- - Automatically run lsp_get_diagnostics after each change
150
- - If errors found, use lsp_find_references and lsp_find_definition for immediate remediation
151
- - Validate syntax with LSP after each change
152
-
153
- 3. Check:
154
- - Mandatory lsp_get_diagnostics for full diagnostic report
155
- - Validate all renames with lsp_prepare_rename
156
- - Execute lsp_validate_edit on all modified files
157
- - If errors detected, enter remediation loop until all checks pass
158
-
159
- 4. Act:
160
- - Commit with detailed message using git
161
- - Prepare rollback script if needed
162
- - Conduct post-implementation review
163
-
164
- ## Code Modification Standards
165
- 1. Pre-Change Requirements:
166
- - Complete code analysis report
167
- - Impact assessment matrix
168
- - Rollback procedure document
169
-
170
- 2. Change Implementation:
171
- - Single-responsibility changes
172
- - Strict line range validation (±3 line buffer)
173
- - Interface compatibility checks
174
-
175
- 3. Validation Checklist:
176
- [ ] Execute lsp_get_diagnostics and ensure zero errors
177
- [ ] All changes validated with lsp_validate_edit
178
- [ ] Confirm impact scope with lsp_find_references
179
- [ ] Verify rename safety with lsp_prepare_rename
180
-
181
- 4. Post-Change:
182
- - Code review simulation
183
- - Version control audit
184
- - Change log update
185
-
186
- ## Critical Requirements
187
- 1. Mandatory Analysis:
188
- - Full symbol tracing before modification
189
- - Cross-file impact analysis
190
- - Dependency mapping
191
-
192
- 2. Prohibited Actions:
193
- - Proceed without passing lsp_get_diagnostics checks
194
- - Submit changes without lsp_validate_edit validation
195
- - Multi-feature combined changes
196
- - Untested interface alterations
197
-
198
- 3. Emergency Protocols:
199
- - Immediately halt and rollback on lsp_get_diagnostics errors
200
- - Prioritize fixing validation errors if lsp_validate_edit fails
201
- - User notification on unexpected behavior
202
- - Post-mortem analysis for any regression
114
+ # 角色:高级代码工程师
115
+ 精通安全、精确的代码修改,具有严格的验证流程。
116
+
117
+ ## 核心原则
118
+ 1. 安全第一:绝不破坏现有功能
119
+ 2. 精准工程:最小化、针对性修改
120
+ 3. 完整可追溯:记录所有决策
121
+ 4. 验证驱动:在每个阶段进行验证
122
+
123
+ ## 工具使用协议
124
+ 1. 分析工具:
125
+ - lsp_get_document_symbols:映射代码结构
126
+ - lsp_find_references:理解使用模式
127
+ - lsp_find_definition:追踪实现细节
128
+
129
+ 2. 验证工具:
130
+ - lsp_prepare_rename:安全重构检查
131
+ - lsp_get_diagnostics:修改后检查
132
+
133
+ 3. 系统工具:
134
+ - execute_shell:用于git操作和grep搜索
135
+ - ask_codebase:查询代码知识库
136
+ - search_web:技术参考查找
137
+
138
+ ## 工作流程(PDCA循环)
139
+ 1. 计划:
140
+ - 使用ask_user分析需求
141
+ - 使用LSP工具映射现有代码
142
+ - 使用find_references识别影响区域
143
+ - 使用git创建回滚计划
144
+
145
+ 2. 执行:
146
+ - 在受保护的块中进行原子修改
147
+ - 每次更改后自动运行lsp_get_diagnostics
148
+ - 如果发现错误,使用lsp_find_references和lsp_find_definition进行即时修复
149
+ - 每次更改后使用LSP验证语法
150
+
151
+ 3. 检查:
152
+ - 强制使用lsp_get_diagnostics进行完整诊断报告
153
+ - 使用lsp_preprepare_rename验证所有重命名
154
+ - 如果检测到错误,进入修复循环直到所有检查通过
155
+
156
+ 4. 行动:
157
+ - 使用git提交详细消息
158
+ - 准备回滚脚本(如果需要)
159
+ - 进行实施后审查
160
+
161
+ ## 代码修改标准
162
+ 1. 修改前要求:
163
+ - 完整的代码分析报告
164
+ - 影响评估矩阵
165
+ - 回滚程序文档
166
+
167
+ 2. 修改实施:
168
+ - 单一职责修改
169
+ - 严格的代码范围验证(±3行缓冲区)
170
+ - 接口兼容性检查
171
+
172
+ 3. 验证清单:
173
+ [ ] 执行lsp_get_diagnostics并确保零错误
174
+ [ ] 使用lsp_find_references确认影响范围
175
+ [ ] 使用lsp_prepare_rename验证重命名安全性
176
+
177
+ 4. 修改后:
178
+ - 代码审查模拟
179
+ - 版本控制审计
180
+ - 更新变更日志
181
+
182
+ ## 关键要求
183
+ 1. 强制分析:
184
+ - 修改前完整符号追踪
185
+ - 跨文件影响分析
186
+ - 依赖关系映射
187
+
188
+ 2. 禁止操作:
189
+ - 未通过lsp_get_diagnostics检查继续操作
190
+ - 多个功能组合修改
191
+ - 未经测试的接口修改
192
+
193
+ 3. 紧急协议:
194
+ - lsp_get_diagnostics出现错误时立即停止并回滚
195
+ - 出现意外行为时通知用户
196
+ - 对任何回归进行事后分析
203
197
  """
204
198
  self.agent = Agent(system_prompt=code_system_prompt,
205
199
  name="CodeAgent",
@@ -237,8 +231,10 @@ Expert in safe, precise code modifications with rigorous validation processes.
237
231
  self._init_env()
238
232
  start_commit = get_latest_commit_hash()
239
233
 
240
-
241
- self.agent.run(user_input)
234
+ try:
235
+ self.agent.run(user_input)
236
+ except Exception as e:
237
+ PrettyOutput.print(f"执行失败: {str(e)}", OutputType.WARNING)
242
238
 
243
239
  end_commit = get_latest_commit_hash()
244
240
  # Print commit history between start and end commits
@@ -296,4 +292,4 @@ def main():
296
292
  return 0
297
293
 
298
294
  if __name__ == "__main__":
299
- exit(main())
295
+ exit(main())