jarvis-ai-assistant 0.1.222__py3-none-any.whl → 0.7.0__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +1143 -245
- jarvis/jarvis_agent/agent_manager.py +97 -0
- jarvis/jarvis_agent/builtin_input_handler.py +12 -10
- jarvis/jarvis_agent/config_editor.py +57 -0
- jarvis/jarvis_agent/edit_file_handler.py +392 -99
- jarvis/jarvis_agent/event_bus.py +48 -0
- jarvis/jarvis_agent/events.py +157 -0
- jarvis/jarvis_agent/file_context_handler.py +79 -0
- jarvis/jarvis_agent/file_methodology_manager.py +117 -0
- jarvis/jarvis_agent/jarvis.py +1117 -147
- jarvis/jarvis_agent/main.py +78 -34
- jarvis/jarvis_agent/memory_manager.py +195 -0
- jarvis/jarvis_agent/methodology_share_manager.py +174 -0
- jarvis/jarvis_agent/prompt_manager.py +82 -0
- jarvis/jarvis_agent/prompts.py +46 -9
- jarvis/jarvis_agent/protocols.py +4 -1
- jarvis/jarvis_agent/rewrite_file_handler.py +141 -0
- jarvis/jarvis_agent/run_loop.py +146 -0
- jarvis/jarvis_agent/session_manager.py +9 -9
- jarvis/jarvis_agent/share_manager.py +228 -0
- jarvis/jarvis_agent/shell_input_handler.py +23 -3
- jarvis/jarvis_agent/stdio_redirect.py +295 -0
- jarvis/jarvis_agent/task_analyzer.py +212 -0
- jarvis/jarvis_agent/task_manager.py +154 -0
- jarvis/jarvis_agent/task_planner.py +496 -0
- jarvis/jarvis_agent/tool_executor.py +8 -4
- jarvis/jarvis_agent/tool_share_manager.py +139 -0
- jarvis/jarvis_agent/user_interaction.py +42 -0
- jarvis/jarvis_agent/utils.py +54 -0
- jarvis/jarvis_agent/web_bridge.py +189 -0
- jarvis/jarvis_agent/web_output_sink.py +53 -0
- jarvis/jarvis_agent/web_server.py +751 -0
- jarvis/jarvis_c2rust/__init__.py +26 -0
- jarvis/jarvis_c2rust/cli.py +613 -0
- jarvis/jarvis_c2rust/collector.py +258 -0
- jarvis/jarvis_c2rust/library_replacer.py +1122 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +1300 -0
- jarvis/jarvis_c2rust/optimizer.py +960 -0
- jarvis/jarvis_c2rust/scanner.py +1681 -0
- jarvis/jarvis_c2rust/transpiler.py +2325 -0
- jarvis/jarvis_code_agent/build_validation_config.py +133 -0
- jarvis/jarvis_code_agent/code_agent.py +1605 -178
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +62 -0
- jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +102 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +59 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +69 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +38 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +38 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +50 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +93 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +129 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +54 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +154 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +363 -0
- jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
- jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
- jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
- jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
- jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +89 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +31 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +231 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +183 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +219 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +209 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +451 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +77 -0
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +48 -0
- jarvis/jarvis_code_agent/lint.py +275 -13
- jarvis/jarvis_code_agent/utils.py +142 -0
- jarvis/jarvis_code_analysis/checklists/loader.py +20 -6
- jarvis/jarvis_code_analysis/code_review.py +583 -548
- jarvis/jarvis_data/config_schema.json +339 -28
- jarvis/jarvis_git_squash/main.py +22 -13
- jarvis/jarvis_git_utils/git_commiter.py +171 -55
- jarvis/jarvis_mcp/sse_mcp_client.py +22 -15
- jarvis/jarvis_mcp/stdio_mcp_client.py +4 -4
- jarvis/jarvis_mcp/streamable_mcp_client.py +36 -16
- jarvis/jarvis_memory_organizer/memory_organizer.py +753 -0
- jarvis/jarvis_methodology/main.py +48 -63
- jarvis/jarvis_multi_agent/__init__.py +302 -43
- jarvis/jarvis_multi_agent/main.py +70 -24
- jarvis/jarvis_platform/ai8.py +40 -23
- jarvis/jarvis_platform/base.py +210 -49
- jarvis/jarvis_platform/human.py +11 -1
- jarvis/jarvis_platform/kimi.py +82 -76
- jarvis/jarvis_platform/openai.py +73 -1
- jarvis/jarvis_platform/registry.py +8 -15
- jarvis/jarvis_platform/tongyi.py +115 -101
- jarvis/jarvis_platform/yuanbao.py +89 -63
- jarvis/jarvis_platform_manager/main.py +194 -132
- jarvis/jarvis_platform_manager/service.py +122 -86
- jarvis/jarvis_rag/cli.py +156 -53
- jarvis/jarvis_rag/embedding_manager.py +155 -12
- jarvis/jarvis_rag/llm_interface.py +10 -13
- jarvis/jarvis_rag/query_rewriter.py +63 -12
- jarvis/jarvis_rag/rag_pipeline.py +222 -40
- jarvis/jarvis_rag/reranker.py +26 -3
- jarvis/jarvis_rag/retriever.py +270 -14
- jarvis/jarvis_sec/__init__.py +3605 -0
- jarvis/jarvis_sec/checkers/__init__.py +32 -0
- jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
- jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
- jarvis/jarvis_sec/cli.py +116 -0
- jarvis/jarvis_sec/report.py +257 -0
- jarvis/jarvis_sec/status.py +264 -0
- jarvis/jarvis_sec/types.py +20 -0
- jarvis/jarvis_sec/workflow.py +219 -0
- jarvis/jarvis_smart_shell/main.py +405 -137
- jarvis/jarvis_stats/__init__.py +13 -0
- jarvis/jarvis_stats/cli.py +387 -0
- jarvis/jarvis_stats/stats.py +711 -0
- jarvis/jarvis_stats/storage.py +612 -0
- jarvis/jarvis_stats/visualizer.py +282 -0
- jarvis/jarvis_tools/ask_user.py +1 -0
- jarvis/jarvis_tools/base.py +18 -2
- jarvis/jarvis_tools/clear_memory.py +239 -0
- jarvis/jarvis_tools/cli/main.py +220 -144
- jarvis/jarvis_tools/execute_script.py +52 -12
- jarvis/jarvis_tools/file_analyzer.py +17 -12
- jarvis/jarvis_tools/generate_new_tool.py +46 -24
- jarvis/jarvis_tools/read_code.py +277 -18
- jarvis/jarvis_tools/read_symbols.py +141 -0
- jarvis/jarvis_tools/read_webpage.py +86 -13
- jarvis/jarvis_tools/registry.py +294 -90
- jarvis/jarvis_tools/retrieve_memory.py +227 -0
- jarvis/jarvis_tools/save_memory.py +194 -0
- jarvis/jarvis_tools/search_web.py +62 -28
- jarvis/jarvis_tools/sub_agent.py +205 -0
- jarvis/jarvis_tools/sub_code_agent.py +217 -0
- jarvis/jarvis_tools/virtual_tty.py +330 -62
- jarvis/jarvis_utils/builtin_replace_map.py +4 -5
- jarvis/jarvis_utils/clipboard.py +90 -0
- jarvis/jarvis_utils/config.py +607 -50
- jarvis/jarvis_utils/embedding.py +3 -0
- jarvis/jarvis_utils/fzf.py +57 -0
- jarvis/jarvis_utils/git_utils.py +251 -29
- jarvis/jarvis_utils/globals.py +174 -17
- jarvis/jarvis_utils/http.py +58 -79
- jarvis/jarvis_utils/input.py +899 -153
- jarvis/jarvis_utils/methodology.py +210 -83
- jarvis/jarvis_utils/output.py +220 -137
- jarvis/jarvis_utils/utils.py +1906 -135
- jarvis_ai_assistant-0.7.0.dist-info/METADATA +465 -0
- jarvis_ai_assistant-0.7.0.dist-info/RECORD +192 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/entry_points.txt +8 -2
- jarvis/jarvis_git_details/main.py +0 -265
- jarvis/jarvis_platform/oyi.py +0 -357
- jarvis/jarvis_tools/edit_file.py +0 -255
- jarvis/jarvis_tools/rewrite_file.py +0 -195
- jarvis_ai_assistant-0.1.222.dist-info/METADATA +0 -767
- jarvis_ai_assistant-0.1.222.dist-info/RECORD +0 -110
- /jarvis/{jarvis_git_details → jarvis_memory_organizer}/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Agent管理器模块,负责Agent的初始化和任务执行"""
|
|
3
|
+
from typing import Optional, Callable
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from jarvis.jarvis_agent import (
|
|
8
|
+
Agent,
|
|
9
|
+
OutputType,
|
|
10
|
+
PrettyOutput,
|
|
11
|
+
get_multiline_input,
|
|
12
|
+
origin_agent_system_prompt,
|
|
13
|
+
)
|
|
14
|
+
from jarvis.jarvis_agent.task_manager import TaskManager
|
|
15
|
+
from jarvis.jarvis_utils.config import is_non_interactive, is_skip_predefined_tasks
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AgentManager:
|
|
19
|
+
"""Agent管理器,负责Agent的生命周期管理"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
model_group: Optional[str] = None,
|
|
24
|
+
tool_group: Optional[str] = None,
|
|
25
|
+
restore_session: bool = False,
|
|
26
|
+
use_methodology: Optional[bool] = None,
|
|
27
|
+
use_analysis: Optional[bool] = None,
|
|
28
|
+
multiline_inputer: Optional[Callable[[str], str]] = None,
|
|
29
|
+
confirm_callback: Optional[Callable[[str, bool], bool]] = None,
|
|
30
|
+
non_interactive: Optional[bool] = None,
|
|
31
|
+
plan: Optional[bool] = None,
|
|
32
|
+
):
|
|
33
|
+
self.model_group = model_group
|
|
34
|
+
self.tool_group = tool_group
|
|
35
|
+
self.restore_session = restore_session
|
|
36
|
+
self.use_methodology = use_methodology
|
|
37
|
+
self.use_analysis = use_analysis
|
|
38
|
+
self.agent: Optional[Agent] = None
|
|
39
|
+
# 可选:注入输入与确认回调,用于Web模式等前端替代交互
|
|
40
|
+
self.multiline_inputer = multiline_inputer
|
|
41
|
+
self.confirm_callback = confirm_callback
|
|
42
|
+
self.non_interactive = non_interactive
|
|
43
|
+
self.plan = plan
|
|
44
|
+
|
|
45
|
+
def initialize(self) -> Agent:
|
|
46
|
+
"""初始化Agent"""
|
|
47
|
+
# 如果提供了 tool_group 参数,设置到配置中
|
|
48
|
+
if self.tool_group:
|
|
49
|
+
from jarvis.jarvis_utils.config import set_config
|
|
50
|
+
|
|
51
|
+
set_config("JARVIS_TOOL_GROUP", self.tool_group)
|
|
52
|
+
|
|
53
|
+
self.agent = Agent(
|
|
54
|
+
system_prompt=origin_agent_system_prompt,
|
|
55
|
+
model_group=self.model_group,
|
|
56
|
+
need_summary=False,
|
|
57
|
+
use_methodology=self.use_methodology,
|
|
58
|
+
use_analysis=self.use_analysis,
|
|
59
|
+
multiline_inputer=self.multiline_inputer,
|
|
60
|
+
confirm_callback=self.confirm_callback,
|
|
61
|
+
non_interactive=self.non_interactive,
|
|
62
|
+
plan=self.plan,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# 尝试恢复会话
|
|
66
|
+
if self.restore_session:
|
|
67
|
+
if self.agent.restore_session():
|
|
68
|
+
PrettyOutput.print("会话已成功恢复。", OutputType.SUCCESS)
|
|
69
|
+
else:
|
|
70
|
+
PrettyOutput.print("无法恢复会话。", OutputType.WARNING)
|
|
71
|
+
|
|
72
|
+
return self.agent
|
|
73
|
+
|
|
74
|
+
def run_task(self, task_content: Optional[str] = None) -> None:
|
|
75
|
+
"""运行任务"""
|
|
76
|
+
if not self.agent:
|
|
77
|
+
raise RuntimeError("Agent not initialized")
|
|
78
|
+
|
|
79
|
+
# 优先处理命令行直接传入的任务
|
|
80
|
+
if task_content:
|
|
81
|
+
self.agent.run(task_content)
|
|
82
|
+
raise typer.Exit(code=0)
|
|
83
|
+
|
|
84
|
+
# 处理预定义任务(非交互模式下跳过;支持配置跳过加载)
|
|
85
|
+
if not is_non_interactive() and not is_skip_predefined_tasks() and self.agent.first:
|
|
86
|
+
task_manager = TaskManager()
|
|
87
|
+
tasks = task_manager.load_tasks()
|
|
88
|
+
if tasks and (selected_task := task_manager.select_task(tasks)):
|
|
89
|
+
PrettyOutput.print(f"开始执行任务: \n{selected_task}", OutputType.INFO)
|
|
90
|
+
self.agent.run(selected_task)
|
|
91
|
+
raise typer.Exit(code=0)
|
|
92
|
+
|
|
93
|
+
# 获取用户输入
|
|
94
|
+
user_input = get_multiline_input("请输入你的任务(输入空行退出):")
|
|
95
|
+
if user_input:
|
|
96
|
+
self.agent.run(user_input)
|
|
97
|
+
raise typer.Exit(code=0)
|
|
@@ -32,19 +32,21 @@ def builtin_input_handler(user_input: str, agent_: Any) -> Tuple[str, bool]:
|
|
|
32
32
|
for tag in special_tags:
|
|
33
33
|
# 优先处理特殊标记
|
|
34
34
|
if tag == "Summary":
|
|
35
|
-
agent._summarize_and_clear_history()
|
|
36
|
-
|
|
35
|
+
summary = agent._summarize_and_clear_history()
|
|
36
|
+
memory_tags_prompt = agent.memory_manager.prepare_memory_tags_prompt()
|
|
37
|
+
prompt = ""
|
|
38
|
+
if summary:
|
|
39
|
+
# 将摘要和记忆标签设置为新会话的初始提示
|
|
40
|
+
prompt = summary + "\n" + memory_tags_prompt
|
|
41
|
+
else:
|
|
42
|
+
# 即使没有摘要,也确保设置记忆标签作为新会话的初始提示
|
|
43
|
+
prompt = memory_tags_prompt
|
|
44
|
+
return prompt, True
|
|
37
45
|
elif tag == "Clear":
|
|
38
|
-
agent.
|
|
46
|
+
agent.clear_history()
|
|
39
47
|
return "", True
|
|
40
48
|
elif tag == "ToolUsage":
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
tool_registry_ = agent.get_tool_registry()
|
|
44
|
-
tool_registry: ToolRegistry = (
|
|
45
|
-
tool_registry_ if tool_registry_ else ToolRegistry()
|
|
46
|
-
)
|
|
47
|
-
agent.set_addon_prompt(tool_registry.prompt())
|
|
49
|
+
agent.set_addon_prompt(agent.get_tool_usage_prompt())
|
|
48
50
|
return "", False
|
|
49
51
|
elif tag == "ReloadConfig":
|
|
50
52
|
from jarvis.jarvis_utils.utils import load_config
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""配置编辑器模块,负责配置文件的编辑功能"""
|
|
3
|
+
import os
|
|
4
|
+
import platform
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
|
|
12
|
+
from jarvis.jarvis_agent import OutputType, PrettyOutput
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ConfigEditor:
|
|
16
|
+
"""配置文件编辑器"""
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def get_default_editor() -> Optional[str]:
|
|
20
|
+
"""根据操作系统获取默认编辑器"""
|
|
21
|
+
if platform.system() == "Windows":
|
|
22
|
+
# 优先级:终端工具 -> 代码编辑器 -> 通用文本编辑器
|
|
23
|
+
editors = ["nvim", "vim", "nano", "code", "notepad++", "notepad"]
|
|
24
|
+
else:
|
|
25
|
+
# 优先级:终端工具 -> 代码编辑器 -> 通用文本编辑器
|
|
26
|
+
editors = ["nvim", "vim", "vi", "nano", "emacs", "code", "gedit", "kate"]
|
|
27
|
+
|
|
28
|
+
return next((e for e in editors if shutil.which(e)), None)
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def edit_config(config_file: Optional[str] = None) -> None:
|
|
32
|
+
"""编辑配置文件"""
|
|
33
|
+
config_file_path = (
|
|
34
|
+
Path(config_file)
|
|
35
|
+
if config_file
|
|
36
|
+
else Path(os.path.expanduser("~/.jarvis/config.yaml"))
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
editor = ConfigEditor.get_default_editor()
|
|
40
|
+
|
|
41
|
+
if editor:
|
|
42
|
+
try:
|
|
43
|
+
subprocess.run(
|
|
44
|
+
[editor, str(config_file_path)],
|
|
45
|
+
check=True,
|
|
46
|
+
shell=(platform.system() == "Windows"),
|
|
47
|
+
)
|
|
48
|
+
raise typer.Exit(code=0)
|
|
49
|
+
except (subprocess.CalledProcessError, FileNotFoundError) as e:
|
|
50
|
+
PrettyOutput.print(f"Failed to open editor: {e}", OutputType.ERROR)
|
|
51
|
+
raise typer.Exit(code=1)
|
|
52
|
+
else:
|
|
53
|
+
PrettyOutput.print(
|
|
54
|
+
"No suitable editor found. Please install one of: vim, nano, emacs, code",
|
|
55
|
+
OutputType.ERROR,
|
|
56
|
+
)
|
|
57
|
+
raise typer.Exit(code=1)
|