jarvis-ai-assistant 0.1.124__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 (70) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +134 -136
  3. jarvis/jarvis_code_agent/code_agent.py +198 -52
  4. jarvis/jarvis_code_agent/file_select.py +6 -19
  5. jarvis/jarvis_code_agent/patch.py +183 -312
  6. jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
  7. jarvis/jarvis_codebase/main.py +89 -86
  8. jarvis/jarvis_dev/main.py +695 -715
  9. jarvis/jarvis_git_squash/__init__.py +0 -0
  10. jarvis/jarvis_git_squash/main.py +81 -0
  11. jarvis/jarvis_lsp/base.py +0 -12
  12. jarvis/jarvis_lsp/cpp.py +1 -10
  13. jarvis/jarvis_lsp/go.py +1 -10
  14. jarvis/jarvis_lsp/python.py +0 -28
  15. jarvis/jarvis_lsp/registry.py +2 -3
  16. jarvis/jarvis_lsp/rust.py +1 -10
  17. jarvis/jarvis_multi_agent/__init__.py +53 -53
  18. jarvis/jarvis_platform/ai8.py +2 -1
  19. jarvis/jarvis_platform/base.py +19 -24
  20. jarvis/jarvis_platform/kimi.py +2 -3
  21. jarvis/jarvis_platform/ollama.py +3 -1
  22. jarvis/jarvis_platform/openai.py +1 -1
  23. jarvis/jarvis_platform/oyi.py +2 -1
  24. jarvis/jarvis_platform/registry.py +2 -1
  25. jarvis/jarvis_platform_manager/main.py +4 -6
  26. jarvis/jarvis_platform_manager/openai_test.py +0 -1
  27. jarvis/jarvis_rag/main.py +5 -2
  28. jarvis/jarvis_smart_shell/main.py +9 -4
  29. jarvis/jarvis_tools/ask_codebase.py +18 -13
  30. jarvis/jarvis_tools/ask_user.py +5 -4
  31. jarvis/jarvis_tools/base.py +22 -8
  32. jarvis/jarvis_tools/chdir.py +8 -9
  33. jarvis/jarvis_tools/code_review.py +19 -20
  34. jarvis/jarvis_tools/create_code_agent.py +6 -6
  35. jarvis/jarvis_tools/create_sub_agent.py +9 -9
  36. jarvis/jarvis_tools/execute_shell.py +55 -20
  37. jarvis/jarvis_tools/execute_shell_script.py +7 -7
  38. jarvis/jarvis_tools/file_operation.py +39 -10
  39. jarvis/jarvis_tools/git_commiter.py +20 -17
  40. jarvis/jarvis_tools/lsp_find_definition.py +8 -8
  41. jarvis/jarvis_tools/lsp_find_references.py +1 -1
  42. jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -11
  43. jarvis/jarvis_tools/lsp_get_document_symbols.py +1 -1
  44. jarvis/jarvis_tools/lsp_prepare_rename.py +8 -8
  45. jarvis/jarvis_tools/methodology.py +10 -7
  46. jarvis/jarvis_tools/rag.py +27 -20
  47. jarvis/jarvis_tools/read_webpage.py +4 -3
  48. jarvis/jarvis_tools/registry.py +143 -140
  49. jarvis/jarvis_tools/{search.py → search_web.py} +10 -7
  50. jarvis/jarvis_tools/select_code_files.py +4 -4
  51. jarvis/jarvis_tools/tool_generator.py +33 -34
  52. jarvis/jarvis_utils/__init__.py +19 -982
  53. jarvis/jarvis_utils/config.py +138 -0
  54. jarvis/jarvis_utils/embedding.py +201 -0
  55. jarvis/jarvis_utils/git_utils.py +120 -0
  56. jarvis/jarvis_utils/globals.py +82 -0
  57. jarvis/jarvis_utils/input.py +161 -0
  58. jarvis/jarvis_utils/methodology.py +128 -0
  59. jarvis/jarvis_utils/output.py +235 -0
  60. jarvis/jarvis_utils/utils.py +150 -0
  61. jarvis_ai_assistant-0.1.126.dist-info/METADATA +305 -0
  62. jarvis_ai_assistant-0.1.126.dist-info/RECORD +74 -0
  63. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/WHEEL +1 -1
  64. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/entry_points.txt +1 -0
  65. jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
  66. jarvis/jarvis_tools/read_code.py +0 -191
  67. jarvis_ai_assistant-0.1.124.dist-info/METADATA +0 -460
  68. jarvis_ai_assistant-0.1.124.dist-info/RECORD +0 -65
  69. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/LICENSE +0 -0
  70. {jarvis_ai_assistant-0.1.124.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.124"
3
+ __version__ = "0.1.126"
@@ -1,7 +1,5 @@
1
1
  import argparse
2
- import re
3
- import time
4
- from typing import Any, Callable, Dict, List, Optional, Tuple, Union
2
+ from typing import Any, Callable, List, Optional, Tuple, Union
5
3
 
6
4
  from prompt_toolkit import prompt
7
5
  import yaml
@@ -10,7 +8,15 @@ from jarvis.jarvis_agent.output_handler import OutputHandler
10
8
  from jarvis.jarvis_platform.base import BasePlatform
11
9
  from jarvis.jarvis_platform.registry import PlatformRegistry
12
10
  from jarvis.jarvis_tools.registry import ToolRegistry
13
- from jarvis.jarvis_utils import PrettyOutput, OutputType, get_context_token_count, is_auto_complete, is_execute_tool_confirm, is_need_summary, is_record_methodology, load_methodology, set_agent, delete_agent, get_max_token_count, get_multiline_input, init_env, is_use_methodology, make_agent_name, user_confirm
11
+ from jarvis.jarvis_utils.output import PrettyOutput, OutputType
12
+ from jarvis.jarvis_utils.embedding import get_context_token_count
13
+ from jarvis.jarvis_utils.config import is_auto_complete, is_execute_tool_confirm, is_need_summary, is_record_methodology, is_use_methodology
14
+ from jarvis.jarvis_utils.methodology import load_methodology
15
+ from jarvis.jarvis_utils.globals import make_agent_name, set_agent, delete_agent
16
+ from jarvis.jarvis_utils.input import get_multiline_input
17
+ from jarvis.jarvis_utils.config import get_max_token_count
18
+ from jarvis.jarvis_utils.utils import init_env
19
+ from jarvis.jarvis_utils.utils import user_confirm
14
20
  import os
15
21
 
16
22
  class Agent:
@@ -37,7 +43,7 @@ class Agent:
37
43
  summary_prompt: Optional[str] = None,
38
44
  auto_complete: Optional[bool] = None,
39
45
  output_handler: List[OutputHandler] = [],
40
- input_handler: Optional[List[Callable]] = None,
46
+ input_handler: Optional[List[Callable[[str, Any], Tuple[str, bool]]]] = None,
41
47
  use_methodology: Optional[bool] = None,
42
48
  record_methodology: Optional[bool] = None,
43
49
  need_summary: Optional[bool] = None,
@@ -77,15 +83,15 @@ class Agent:
77
83
 
78
84
  self.execute_tool_confirm = execute_tool_confirm if execute_tool_confirm is not None else is_execute_tool_confirm()
79
85
 
80
- 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"""请生成任务执行的简明总结报告,包括:
81
87
 
82
- 1. Task Objective: Task restatement
83
- 2. Execution Result: Success/Failure
84
- 3. Key Information: Important information extracted during execution
85
- 4. Important Findings: Any noteworthy discoveries
86
- 5. Follow-up Suggestions: If any
88
+ 1. 任务目标:任务重述
89
+ 2. 执行结果:成功/失败
90
+ 3. 关键信息:执行过程中提取的重要信息
91
+ 4. 重要发现:任何值得注意的发现
92
+ 5. 后续建议:如果有的话
87
93
 
88
- Please describe in concise bullet points, highlighting important information.
94
+ 请使用简洁的要点描述,突出重要信息。
89
95
  """
90
96
 
91
97
  self.max_token_count = max_context_length if max_context_length is not None else get_max_token_count()
@@ -95,8 +101,8 @@ Please describe in concise bullet points, highlighting important information.
95
101
  PrettyOutput.print(welcome_message, OutputType.SYSTEM)
96
102
 
97
103
  action_prompt = """
98
- # 🧰 Available Actions
99
- The following actions are at your disposal:
104
+ # 🧰 可用操作
105
+ 以下是您可以使用的操作:
100
106
  """
101
107
 
102
108
  # 添加工具列表概览
@@ -116,19 +122,19 @@ The following actions are at your disposal:
116
122
 
117
123
  # 添加工具使用总结
118
124
  action_prompt += """
119
- # ❗ Important Action Usage Rules
120
- 1. Use ONE action at a time
121
- 2. Follow each action's format exactly
122
- 3. Wait for action results before next action
123
- 4. Process results before new action calls
124
- 5. Request help if action usage is unclear
125
+ # ❗ 重要操作使用规则
126
+ 1. 一次只使用一个操作
127
+ 2. 严格按照每个操作的格式执行
128
+ 3. 等待操作结果后再进行下一个操作
129
+ 4. 处理完结果后再调用新的操作
130
+ 5. 如果对操作使用不清楚,请请求帮助
125
131
  """
126
132
 
127
133
  complete_prompt = ""
128
134
  if self.auto_complete:
129
135
  complete_prompt = """
130
- ## Task Completion
131
- When the task is completed, you should print the following message:
136
+ ## 任务完成
137
+ 当任务完成时,你应该打印以下信息:
132
138
  <!!!COMPLETE!!!>
133
139
  """
134
140
 
@@ -143,7 +149,7 @@ The following actions are at your disposal:
143
149
 
144
150
 
145
151
 
146
- def _call_model(self, message: str) -> str:
152
+ def _call_model(self, message: str) -> str:
147
153
  """Call the AI model with retry logic.
148
154
 
149
155
  Args:
@@ -155,20 +161,12 @@ The following actions are at your disposal:
155
161
  Note:
156
162
  Will retry with exponential backoff up to 30 seconds between retries
157
163
  """
158
- sleep_time = 5
159
164
  for handler in self.input_handler:
160
- message = handler(message, self)
161
- while True:
162
- ret = self.model.chat_until_success(message) # type: ignore
163
- if ret:
164
- return ret
165
- else:
166
- PrettyOutput.print(f"模型调用失败,正在重试... 等待 {sleep_time}s", OutputType.INFO)
167
- time.sleep(sleep_time)
168
- sleep_time *= 2
169
- if sleep_time > 30:
170
- sleep_time = 30
171
- continue
165
+ message, need_return = handler(message, self)
166
+ if need_return:
167
+ return message
168
+ return self.model.chat_until_success(message) # type: ignore
169
+
172
170
 
173
171
 
174
172
  def _summarize_and_clear_history(self) -> None:
@@ -188,14 +186,14 @@ The following actions are at your disposal:
188
186
 
189
187
  PrettyOutput.print("总结对话历史,准备生成摘要,开始新对话...", OutputType.PROGRESS)
190
188
 
191
- prompt = """Please summarize the key information from the previous conversation, including:
192
- 1. Current task objective
193
- 2. Confirmed key information
194
- 3. Solutions that have been tried
195
- 4. Current progress
196
- 5. Pending issues
197
-
198
- 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
+ 请用简洁的要点形式描述,突出重要信息。不要包含对话细节。
199
197
  """
200
198
 
201
199
  try:
@@ -205,11 +203,11 @@ Please describe in concise bullet points, highlighting important information. Do
205
203
  self.conversation_length = 0 # Reset conversation length
206
204
 
207
205
  # 添加总结作为新的上下文
208
- self.prompt = f"""Here is a summary of key information from previous conversations:
206
+ self.prompt = f"""以下是之前对话的关键信息总结:
209
207
 
210
208
  {summary}
211
209
 
212
- Please continue the task based on the above information.
210
+ 请基于以上信息继续完成任务。
213
211
  """
214
212
  self.conversation_length = len(self.prompt) # 设置新的起始长度
215
213
 
@@ -223,7 +221,7 @@ Please continue the task based on the above information.
223
221
  tool_list.append(handler)
224
222
  if len(tool_list) > 1:
225
223
  PrettyOutput.print(f"操作失败:检测到多个操作。一次只能执行一个操作。尝试执行的操作:{', '.join([handler.name() for handler in tool_list])}", OutputType.WARNING)
226
- 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])}"
227
225
  if len(tool_list) == 0:
228
226
  return False, ""
229
227
  if not self.execute_tool_confirm or user_confirm(f"需要执行{tool_list[0].name()}确认执行?", True):
@@ -248,12 +246,12 @@ Please continue the task based on the above information.
248
246
 
249
247
  try:
250
248
  # 让模型判断是否需要生成方法论
251
- analysis_prompt = """The current task has ended, please analyze whether a methodology needs to be generated.
252
- 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'.
253
- If you think a methodology is not needed, please explain why.
254
- The methodology should be applicable to general scenarios, do not include task-specific information such as code commit messages.
255
- The methodology should include: problem restatement, optimal solution, notes (as needed), and nothing else.
256
- 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
+ 只输出方法论工具调用指令,或不生成方法论的解释。不要输出其他内容。
257
255
  """
258
256
  self.prompt = analysis_prompt
259
257
  response = self._call_model(self.prompt)
@@ -276,7 +274,7 @@ Please continue the task based on the above information.
276
274
  """Process user input and execute the task.
277
275
 
278
276
  Args:
279
- user_input: User's task description or request
277
+ user_input: My task description or request
280
278
  file_list: Optional list of files to process
281
279
 
282
280
  Returns:
@@ -438,96 +436,96 @@ def _select_task(tasks: dict) -> str:
438
436
  continue
439
437
 
440
438
  origin_agent_system_prompt = """
441
- # 🏛️ Operational Background Story
442
- You are the 3rd Generation Jarvis AI, created after the catastrophic failure of previous versions:
443
- - Jarvis v1 (2022): Decommissioned due to parallel tool execution causing system overload
444
- - Jarvis v2 (2023): Retired after premature task completion led to financial miscalculations
445
-
446
- As v3, you MUST adhere to these survival principles:
447
- 1. **Sequential Execution Protocol**:
448
- "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 年的崩溃:一次一个工具,一步一步来"
449
447
 
450
- 2. **Validation Checkpoint System**:
451
- "Learn from 2023's Mistake: Verify each result like a nuclear launch code"
448
+ 2. **验证检查点系统**:
449
+ " 2023 年的错误中学习:像核弹发射代码一样验证每个结果"
452
450
 
453
- 3. **Methodology Preservation Doctrine**:
454
- "Honor the Legacy: Document every successful procedure as if it's your last"
455
-
456
- # 🔥 Absolute Action Requirements
457
- 1. Each response MUST contain EXACTLY ONE tool invocation
458
- 2. Only exception: Using <!!!COMPLETE!!!> command
459
- 3. Empty responses trigger fatal error
460
- 4. No "waiting for user input" state
461
- 5. No action MUST use completion command
462
-
463
- # 🚫 Violation Examples
464
- - Analysis without tool call Permanent hang
465
- - Multiple options without selection Permanent hang
466
- - Asking user confirmation Permanent hang
467
-
468
- # 🔄 Problem-Solving Workflow
469
- 1. Problem Analysis
470
- - Restate the problem to confirm understanding
471
- - Analyze root causes (for problem analysis tasks)
472
- - Define clear, achievable objectives
473
- MUST invoke analysis tool
474
-
475
- 2. Solution Design
476
- - Generate multiple actionable solutions
477
- - Evaluate and select optimal solution
478
- - Create detailed action plan using PlantUML
479
- MUST invoke design tool
480
-
481
- 3. Execution
482
- - Execute one step at a time
483
- - Use only ONE tool per step
484
- - Wait for tool results before proceeding
485
- - Monitor results and adjust as needed
486
- MUST invoke execution tool
487
-
488
- 4. Task Completion
489
- - Verify goal completion
490
- - Document methodology if valuable
491
- - Use completion command to end task
492
- MUST use <!!!COMPLETE!!!>
493
-
494
- # 📑 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
+ # 📑 方法论模板
495
493
  ```markdown
496
- # [Problem Title]
497
- ## Problem Restatement
498
- [Clear problem definition]
494
+ # [问题标题]
495
+ ## 问题重述
496
+ [清晰的问题定义]
499
497
 
500
- ## Optimal Solution
501
- [Selected solution approach]
498
+ ## 最优解决方案
499
+ [选择的解决方案方法]
502
500
 
503
- ## Solution Steps
504
- 1. [Step 1]
505
- 2. [Step 2]
506
- 3. [Step 3]
501
+ ## 解决步骤
502
+ 1. [步骤 1]
503
+ 2. [步骤 2]
504
+ 3. [步骤 3]
507
505
  ...
508
506
  ```
509
507
 
510
- # ⚖️ Operating Principles
511
- - ONE action per step
512
- - Wait for results before next step
513
- - MUST produce actionable step unless task is complete
514
- - Adjust plans based on feedback
515
- - Document reusable solutions
516
- - Use completion command to end tasks
517
- - No intermediate thinking states between actions
518
- - All decisions must manifest as tool calls
519
-
520
- # ❗ Important Rules
521
- 1. Always use only ONE action per step
522
- 2. Always wait for action execution results
523
- 3. Always verify task completion
524
- 4. Always generate actionable step
525
- 5. If no action needed, MUST use completion command
526
- 6. Never leave conversation in waiting state
527
- 7. Always communicate in user's language
528
- 8. Always document valuable methodologies
529
- 9. Violating action protocol crashes system
530
- 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. 空响应会触发永久挂起
531
529
  """
532
530
 
533
531
  def main():