jarvis-ai-assistant 0.7.16__py3-none-any.whl → 1.0.2__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 +567 -222
- jarvis/jarvis_agent/agent_manager.py +19 -12
- jarvis/jarvis_agent/builtin_input_handler.py +79 -11
- jarvis/jarvis_agent/config_editor.py +7 -2
- jarvis/jarvis_agent/event_bus.py +24 -13
- jarvis/jarvis_agent/events.py +19 -1
- jarvis/jarvis_agent/file_context_handler.py +67 -64
- jarvis/jarvis_agent/file_methodology_manager.py +38 -24
- jarvis/jarvis_agent/jarvis.py +186 -114
- jarvis/jarvis_agent/language_extractors/__init__.py +8 -1
- jarvis/jarvis_agent/language_extractors/c_extractor.py +7 -4
- jarvis/jarvis_agent/language_extractors/cpp_extractor.py +9 -4
- jarvis/jarvis_agent/language_extractors/go_extractor.py +7 -4
- jarvis/jarvis_agent/language_extractors/java_extractor.py +27 -20
- jarvis/jarvis_agent/language_extractors/javascript_extractor.py +22 -17
- jarvis/jarvis_agent/language_extractors/python_extractor.py +7 -4
- jarvis/jarvis_agent/language_extractors/rust_extractor.py +7 -4
- jarvis/jarvis_agent/language_extractors/typescript_extractor.py +22 -17
- jarvis/jarvis_agent/language_support_info.py +250 -219
- jarvis/jarvis_agent/main.py +19 -23
- jarvis/jarvis_agent/memory_manager.py +9 -6
- jarvis/jarvis_agent/methodology_share_manager.py +21 -15
- jarvis/jarvis_agent/output_handler.py +4 -2
- jarvis/jarvis_agent/prompt_builder.py +7 -6
- jarvis/jarvis_agent/prompt_manager.py +113 -8
- jarvis/jarvis_agent/prompts.py +317 -85
- jarvis/jarvis_agent/protocols.py +5 -2
- jarvis/jarvis_agent/run_loop.py +192 -32
- jarvis/jarvis_agent/session_manager.py +7 -3
- jarvis/jarvis_agent/share_manager.py +23 -13
- jarvis/jarvis_agent/shell_input_handler.py +12 -8
- jarvis/jarvis_agent/stdio_redirect.py +25 -26
- jarvis/jarvis_agent/task_analyzer.py +29 -23
- jarvis/jarvis_agent/task_list.py +869 -0
- jarvis/jarvis_agent/task_manager.py +26 -23
- jarvis/jarvis_agent/tool_executor.py +6 -5
- jarvis/jarvis_agent/tool_share_manager.py +24 -14
- jarvis/jarvis_agent/user_interaction.py +3 -3
- jarvis/jarvis_agent/utils.py +9 -1
- jarvis/jarvis_agent/web_bridge.py +37 -17
- jarvis/jarvis_agent/web_output_sink.py +5 -2
- jarvis/jarvis_agent/web_server.py +165 -36
- jarvis/jarvis_c2rust/__init__.py +1 -1
- jarvis/jarvis_c2rust/cli.py +260 -141
- jarvis/jarvis_c2rust/collector.py +37 -18
- jarvis/jarvis_c2rust/constants.py +60 -0
- jarvis/jarvis_c2rust/library_replacer.py +242 -1010
- jarvis/jarvis_c2rust/library_replacer_checkpoint.py +133 -0
- jarvis/jarvis_c2rust/library_replacer_llm.py +287 -0
- jarvis/jarvis_c2rust/library_replacer_loader.py +191 -0
- jarvis/jarvis_c2rust/library_replacer_output.py +134 -0
- jarvis/jarvis_c2rust/library_replacer_prompts.py +124 -0
- jarvis/jarvis_c2rust/library_replacer_utils.py +188 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +98 -1044
- jarvis/jarvis_c2rust/llm_module_agent_apply.py +170 -0
- jarvis/jarvis_c2rust/llm_module_agent_executor.py +288 -0
- jarvis/jarvis_c2rust/llm_module_agent_loader.py +170 -0
- jarvis/jarvis_c2rust/llm_module_agent_prompts.py +268 -0
- jarvis/jarvis_c2rust/llm_module_agent_types.py +57 -0
- jarvis/jarvis_c2rust/llm_module_agent_utils.py +150 -0
- jarvis/jarvis_c2rust/llm_module_agent_validator.py +119 -0
- jarvis/jarvis_c2rust/loaders.py +28 -10
- jarvis/jarvis_c2rust/models.py +5 -2
- jarvis/jarvis_c2rust/optimizer.py +192 -1974
- jarvis/jarvis_c2rust/optimizer_build_fix.py +286 -0
- jarvis/jarvis_c2rust/optimizer_clippy.py +766 -0
- jarvis/jarvis_c2rust/optimizer_config.py +49 -0
- jarvis/jarvis_c2rust/optimizer_docs.py +183 -0
- jarvis/jarvis_c2rust/optimizer_options.py +48 -0
- jarvis/jarvis_c2rust/optimizer_progress.py +469 -0
- jarvis/jarvis_c2rust/optimizer_report.py +52 -0
- jarvis/jarvis_c2rust/optimizer_unsafe.py +309 -0
- jarvis/jarvis_c2rust/optimizer_utils.py +469 -0
- jarvis/jarvis_c2rust/optimizer_visibility.py +185 -0
- jarvis/jarvis_c2rust/scanner.py +229 -166
- jarvis/jarvis_c2rust/transpiler.py +531 -2732
- jarvis/jarvis_c2rust/transpiler_agents.py +503 -0
- jarvis/jarvis_c2rust/transpiler_build.py +1294 -0
- jarvis/jarvis_c2rust/transpiler_codegen.py +204 -0
- jarvis/jarvis_c2rust/transpiler_compile.py +146 -0
- jarvis/jarvis_c2rust/transpiler_config.py +178 -0
- jarvis/jarvis_c2rust/transpiler_context.py +122 -0
- jarvis/jarvis_c2rust/transpiler_executor.py +516 -0
- jarvis/jarvis_c2rust/transpiler_generation.py +278 -0
- jarvis/jarvis_c2rust/transpiler_git.py +163 -0
- jarvis/jarvis_c2rust/transpiler_mod_utils.py +225 -0
- jarvis/jarvis_c2rust/transpiler_modules.py +336 -0
- jarvis/jarvis_c2rust/transpiler_planning.py +394 -0
- jarvis/jarvis_c2rust/transpiler_review.py +1196 -0
- jarvis/jarvis_c2rust/transpiler_symbols.py +176 -0
- jarvis/jarvis_c2rust/utils.py +269 -79
- jarvis/jarvis_code_agent/after_change.py +233 -0
- jarvis/jarvis_code_agent/build_validation_config.py +37 -30
- jarvis/jarvis_code_agent/builtin_rules.py +68 -0
- jarvis/jarvis_code_agent/code_agent.py +976 -1517
- jarvis/jarvis_code_agent/code_agent_build.py +227 -0
- jarvis/jarvis_code_agent/code_agent_diff.py +246 -0
- jarvis/jarvis_code_agent/code_agent_git.py +525 -0
- jarvis/jarvis_code_agent/code_agent_impact.py +177 -0
- jarvis/jarvis_code_agent/code_agent_lint.py +283 -0
- jarvis/jarvis_code_agent/code_agent_llm.py +159 -0
- jarvis/jarvis_code_agent/code_agent_postprocess.py +105 -0
- jarvis/jarvis_code_agent/code_agent_prompts.py +46 -0
- jarvis/jarvis_code_agent/code_agent_rules.py +305 -0
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +52 -48
- jarvis/jarvis_code_agent/code_analyzer/base_language.py +12 -10
- jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +12 -11
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +16 -12
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +26 -17
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +558 -104
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +27 -16
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +22 -18
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +21 -16
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +20 -16
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +27 -16
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +47 -23
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +71 -37
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +162 -35
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +111 -57
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +18 -12
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +185 -183
- jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +2 -1
- jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +24 -15
- jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +227 -141
- jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +321 -247
- jarvis/jarvis_code_agent/code_analyzer/language_registry.py +37 -29
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +21 -13
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +15 -9
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +75 -45
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +87 -52
- jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +84 -51
- jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +94 -64
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +109 -71
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +97 -63
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +103 -69
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +271 -268
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +76 -64
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +92 -19
- jarvis/jarvis_code_agent/diff_visualizer.py +998 -0
- jarvis/jarvis_code_agent/lint.py +223 -524
- jarvis/jarvis_code_agent/rule_share_manager.py +158 -0
- jarvis/jarvis_code_agent/rules/clean_code.md +144 -0
- jarvis/jarvis_code_agent/rules/code_review.md +115 -0
- jarvis/jarvis_code_agent/rules/documentation.md +165 -0
- jarvis/jarvis_code_agent/rules/generate_rules.md +52 -0
- jarvis/jarvis_code_agent/rules/performance.md +158 -0
- jarvis/jarvis_code_agent/rules/refactoring.md +139 -0
- jarvis/jarvis_code_agent/rules/security.md +160 -0
- jarvis/jarvis_code_agent/rules/tdd.md +78 -0
- jarvis/jarvis_code_agent/test_rules/cpp_test.md +118 -0
- jarvis/jarvis_code_agent/test_rules/go_test.md +98 -0
- jarvis/jarvis_code_agent/test_rules/java_test.md +99 -0
- jarvis/jarvis_code_agent/test_rules/javascript_test.md +113 -0
- jarvis/jarvis_code_agent/test_rules/php_test.md +117 -0
- jarvis/jarvis_code_agent/test_rules/python_test.md +91 -0
- jarvis/jarvis_code_agent/test_rules/ruby_test.md +102 -0
- jarvis/jarvis_code_agent/test_rules/rust_test.md +86 -0
- jarvis/jarvis_code_agent/utils.py +36 -26
- jarvis/jarvis_code_analysis/checklists/loader.py +21 -21
- jarvis/jarvis_code_analysis/code_review.py +64 -33
- jarvis/jarvis_data/config_schema.json +285 -192
- jarvis/jarvis_git_squash/main.py +8 -6
- jarvis/jarvis_git_utils/git_commiter.py +53 -76
- jarvis/jarvis_mcp/__init__.py +5 -2
- jarvis/jarvis_mcp/sse_mcp_client.py +40 -30
- jarvis/jarvis_mcp/stdio_mcp_client.py +27 -19
- jarvis/jarvis_mcp/streamable_mcp_client.py +35 -26
- jarvis/jarvis_memory_organizer/memory_organizer.py +78 -55
- jarvis/jarvis_methodology/main.py +48 -39
- jarvis/jarvis_multi_agent/__init__.py +56 -23
- jarvis/jarvis_multi_agent/main.py +15 -18
- jarvis/jarvis_platform/base.py +179 -111
- jarvis/jarvis_platform/human.py +27 -16
- jarvis/jarvis_platform/kimi.py +52 -45
- jarvis/jarvis_platform/openai.py +101 -40
- jarvis/jarvis_platform/registry.py +51 -33
- jarvis/jarvis_platform/tongyi.py +68 -38
- jarvis/jarvis_platform/yuanbao.py +59 -43
- jarvis/jarvis_platform_manager/main.py +68 -76
- jarvis/jarvis_platform_manager/service.py +24 -14
- jarvis/jarvis_rag/README_CONFIG.md +314 -0
- jarvis/jarvis_rag/README_DYNAMIC_LOADING.md +311 -0
- jarvis/jarvis_rag/README_ONLINE_MODELS.md +230 -0
- jarvis/jarvis_rag/__init__.py +57 -4
- jarvis/jarvis_rag/cache.py +3 -1
- jarvis/jarvis_rag/cli.py +48 -68
- jarvis/jarvis_rag/embedding_interface.py +39 -0
- jarvis/jarvis_rag/embedding_manager.py +7 -230
- jarvis/jarvis_rag/embeddings/__init__.py +41 -0
- jarvis/jarvis_rag/embeddings/base.py +114 -0
- jarvis/jarvis_rag/embeddings/cohere.py +66 -0
- jarvis/jarvis_rag/embeddings/edgefn.py +117 -0
- jarvis/jarvis_rag/embeddings/local.py +260 -0
- jarvis/jarvis_rag/embeddings/openai.py +62 -0
- jarvis/jarvis_rag/embeddings/registry.py +293 -0
- jarvis/jarvis_rag/llm_interface.py +8 -6
- jarvis/jarvis_rag/query_rewriter.py +8 -9
- jarvis/jarvis_rag/rag_pipeline.py +61 -52
- jarvis/jarvis_rag/reranker.py +7 -75
- jarvis/jarvis_rag/reranker_interface.py +32 -0
- jarvis/jarvis_rag/rerankers/__init__.py +41 -0
- jarvis/jarvis_rag/rerankers/base.py +109 -0
- jarvis/jarvis_rag/rerankers/cohere.py +67 -0
- jarvis/jarvis_rag/rerankers/edgefn.py +140 -0
- jarvis/jarvis_rag/rerankers/jina.py +79 -0
- jarvis/jarvis_rag/rerankers/local.py +89 -0
- jarvis/jarvis_rag/rerankers/registry.py +293 -0
- jarvis/jarvis_rag/retriever.py +58 -43
- jarvis/jarvis_sec/__init__.py +66 -141
- jarvis/jarvis_sec/agents.py +21 -17
- jarvis/jarvis_sec/analysis.py +80 -33
- jarvis/jarvis_sec/checkers/__init__.py +7 -13
- jarvis/jarvis_sec/checkers/c_checker.py +356 -164
- jarvis/jarvis_sec/checkers/rust_checker.py +47 -29
- jarvis/jarvis_sec/cli.py +43 -21
- jarvis/jarvis_sec/clustering.py +430 -272
- jarvis/jarvis_sec/file_manager.py +99 -55
- jarvis/jarvis_sec/parsers.py +9 -6
- jarvis/jarvis_sec/prompts.py +4 -3
- jarvis/jarvis_sec/report.py +44 -22
- jarvis/jarvis_sec/review.py +180 -107
- jarvis/jarvis_sec/status.py +50 -41
- jarvis/jarvis_sec/types.py +3 -0
- jarvis/jarvis_sec/utils.py +160 -83
- jarvis/jarvis_sec/verification.py +411 -181
- jarvis/jarvis_sec/workflow.py +132 -21
- jarvis/jarvis_smart_shell/main.py +28 -41
- jarvis/jarvis_stats/cli.py +14 -12
- jarvis/jarvis_stats/stats.py +28 -19
- jarvis/jarvis_stats/storage.py +14 -8
- jarvis/jarvis_stats/visualizer.py +12 -7
- jarvis/jarvis_tools/base.py +5 -2
- jarvis/jarvis_tools/clear_memory.py +13 -9
- jarvis/jarvis_tools/cli/main.py +23 -18
- jarvis/jarvis_tools/edit_file.py +572 -873
- jarvis/jarvis_tools/execute_script.py +10 -7
- jarvis/jarvis_tools/file_analyzer.py +7 -8
- jarvis/jarvis_tools/meta_agent.py +287 -0
- jarvis/jarvis_tools/methodology.py +5 -3
- jarvis/jarvis_tools/read_code.py +305 -1438
- jarvis/jarvis_tools/read_symbols.py +50 -17
- jarvis/jarvis_tools/read_webpage.py +19 -18
- jarvis/jarvis_tools/registry.py +435 -156
- jarvis/jarvis_tools/retrieve_memory.py +16 -11
- jarvis/jarvis_tools/save_memory.py +8 -6
- jarvis/jarvis_tools/search_web.py +31 -31
- jarvis/jarvis_tools/sub_agent.py +32 -28
- jarvis/jarvis_tools/sub_code_agent.py +44 -60
- jarvis/jarvis_tools/task_list_manager.py +1811 -0
- jarvis/jarvis_tools/virtual_tty.py +29 -19
- jarvis/jarvis_utils/__init__.py +4 -0
- jarvis/jarvis_utils/builtin_replace_map.py +2 -1
- jarvis/jarvis_utils/clipboard.py +9 -8
- jarvis/jarvis_utils/collections.py +331 -0
- jarvis/jarvis_utils/config.py +699 -194
- jarvis/jarvis_utils/dialogue_recorder.py +294 -0
- jarvis/jarvis_utils/embedding.py +6 -3
- jarvis/jarvis_utils/file_processors.py +7 -1
- jarvis/jarvis_utils/fzf.py +9 -3
- jarvis/jarvis_utils/git_utils.py +71 -42
- jarvis/jarvis_utils/globals.py +116 -32
- jarvis/jarvis_utils/http.py +6 -2
- jarvis/jarvis_utils/input.py +318 -83
- jarvis/jarvis_utils/jsonnet_compat.py +119 -104
- jarvis/jarvis_utils/methodology.py +37 -28
- jarvis/jarvis_utils/output.py +201 -44
- jarvis/jarvis_utils/utils.py +986 -628
- {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/METADATA +49 -33
- jarvis_ai_assistant-1.0.2.dist-info/RECORD +304 -0
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +0 -556
- jarvis/jarvis_tools/generate_new_tool.py +0 -205
- jarvis/jarvis_tools/lsp_client.py +0 -1552
- jarvis/jarvis_tools/rewrite_file.py +0 -105
- jarvis_ai_assistant-0.7.16.dist-info/RECORD +0 -218
- {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/top_level.txt +0 -0
jarvis/jarvis_agent/main.py
CHANGED
|
@@ -3,12 +3,13 @@ import os
|
|
|
3
3
|
from typing import Optional
|
|
4
4
|
|
|
5
5
|
import typer
|
|
6
|
-
import yaml
|
|
6
|
+
import yaml
|
|
7
7
|
|
|
8
8
|
from jarvis.jarvis_agent import Agent
|
|
9
|
+
from jarvis.jarvis_utils.config import set_config
|
|
9
10
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
11
|
+
from jarvis.jarvis_utils.output import PrettyOutput
|
|
10
12
|
from jarvis.jarvis_utils.utils import init_env
|
|
11
|
-
from jarvis.jarvis_utils.config import set_config
|
|
12
13
|
|
|
13
14
|
app = typer.Typer(help="Jarvis AI 助手")
|
|
14
15
|
|
|
@@ -23,7 +24,7 @@ def load_config(config_path: str) -> dict:
|
|
|
23
24
|
dict: 配置字典
|
|
24
25
|
"""
|
|
25
26
|
if not os.path.exists(config_path):
|
|
26
|
-
|
|
27
|
+
PrettyOutput.auto_print(f"⚠️ 配置文件 {config_path} 不存在,使用默认配置")
|
|
27
28
|
return {}
|
|
28
29
|
|
|
29
30
|
with open(config_path, "r", encoding="utf-8", errors="ignore") as f:
|
|
@@ -31,7 +32,7 @@ def load_config(config_path: str) -> dict:
|
|
|
31
32
|
config = yaml.safe_load(f)
|
|
32
33
|
return config if config else {}
|
|
33
34
|
except yaml.YAMLError as e:
|
|
34
|
-
|
|
35
|
+
PrettyOutput.auto_print(f"❌ 配置文件解析失败: {str(e)}")
|
|
35
36
|
return {}
|
|
36
37
|
|
|
37
38
|
|
|
@@ -44,28 +45,22 @@ def cli(
|
|
|
44
45
|
None, "-c", "--agent-definition", help="代理定义文件路径"
|
|
45
46
|
),
|
|
46
47
|
task: Optional[str] = typer.Option(None, "-T", "--task", help="初始任务内容"),
|
|
47
|
-
|
|
48
48
|
model_group: Optional[str] = typer.Option(
|
|
49
49
|
None, "-g", "--llm-group", help="使用的模型组,覆盖配置文件中的设置"
|
|
50
50
|
),
|
|
51
51
|
non_interactive: bool = typer.Option(
|
|
52
|
-
False,
|
|
52
|
+
False,
|
|
53
|
+
"-n",
|
|
54
|
+
"--non-interactive",
|
|
55
|
+
help="启用非交互模式:用户无法与命令交互,脚本执行超时限制为5分钟",
|
|
53
56
|
),
|
|
54
57
|
):
|
|
55
58
|
"""Main entry point for Jarvis agent"""
|
|
56
|
-
# CLI 标志:非交互模式(不依赖配置文件)
|
|
57
|
-
if non_interactive:
|
|
58
|
-
try:
|
|
59
|
-
os.environ["JARVIS_NON_INTERACTIVE"] = "true"
|
|
60
|
-
except Exception:
|
|
61
|
-
pass
|
|
62
|
-
try:
|
|
63
|
-
set_config("JARVIS_NON_INTERACTIVE", True)
|
|
64
|
-
except Exception:
|
|
65
|
-
pass
|
|
66
59
|
# 非交互模式要求从命令行传入任务
|
|
67
60
|
if non_interactive and not (task and str(task).strip()):
|
|
68
|
-
|
|
61
|
+
PrettyOutput.auto_print(
|
|
62
|
+
"❌ 非交互模式已启用:必须使用 --task 传入任务内容,因多行输入不可用。"
|
|
63
|
+
)
|
|
69
64
|
raise typer.Exit(code=2)
|
|
70
65
|
# Initialize环境
|
|
71
66
|
init_env(
|
|
@@ -74,9 +69,7 @@ def cli(
|
|
|
74
69
|
# 在初始化环境后同步 CLI 选项到全局配置,避免被 init_env 覆盖
|
|
75
70
|
try:
|
|
76
71
|
if model_group:
|
|
77
|
-
set_config("
|
|
78
|
-
if non_interactive:
|
|
79
|
-
set_config("JARVIS_NON_INTERACTIVE", True)
|
|
72
|
+
set_config("llm_group", str(model_group))
|
|
80
73
|
except Exception:
|
|
81
74
|
# 静默忽略同步异常,不影响主流程
|
|
82
75
|
pass
|
|
@@ -91,11 +84,14 @@ def cli(
|
|
|
91
84
|
|
|
92
85
|
# Create and run agent
|
|
93
86
|
try:
|
|
87
|
+
# 将 non_interactive 标志传递给 Agent,确保仅在该 Agent 实例内生效
|
|
88
|
+
if non_interactive:
|
|
89
|
+
config["non_interactive"] = True
|
|
94
90
|
agent = Agent(**config)
|
|
95
91
|
|
|
96
92
|
# Run agent with initial task if specified
|
|
97
93
|
if task:
|
|
98
|
-
|
|
94
|
+
PrettyOutput.auto_print(f"ℹ️ 执行初始任务: {task}")
|
|
99
95
|
agent.run(task)
|
|
100
96
|
return
|
|
101
97
|
|
|
@@ -114,12 +110,12 @@ def cli(
|
|
|
114
110
|
# 来自输入流程的正常退出
|
|
115
111
|
return
|
|
116
112
|
except Exception as e:
|
|
117
|
-
|
|
113
|
+
PrettyOutput.auto_print(f"❌ 错误: {str(e)}")
|
|
118
114
|
|
|
119
115
|
except typer.Exit:
|
|
120
116
|
return
|
|
121
117
|
except Exception as e:
|
|
122
|
-
|
|
118
|
+
PrettyOutput.auto_print(f"❌ 初始化错误: {str(e)}")
|
|
123
119
|
raise typer.Exit(code=1)
|
|
124
120
|
|
|
125
121
|
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
负责处理Agent的记忆保存和检索功能
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from jarvis.jarvis_agent.events import BEFORE_HISTORY_CLEAR
|
|
8
|
+
from jarvis.jarvis_agent.events import TASK_COMPLETED
|
|
9
|
+
from jarvis.jarvis_agent.events import TASK_STARTED
|
|
7
10
|
from jarvis.jarvis_utils.globals import get_all_memory_tags
|
|
8
|
-
from jarvis.
|
|
11
|
+
from jarvis.jarvis_utils.output import PrettyOutput
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
class MemoryManager:
|
|
@@ -95,7 +98,7 @@ class MemoryManager:
|
|
|
95
98
|
except Exception:
|
|
96
99
|
pass
|
|
97
100
|
|
|
98
|
-
response = self.agent.model.chat_until_success(prompt)
|
|
101
|
+
response = self.agent.model.chat_until_success(prompt)
|
|
99
102
|
|
|
100
103
|
# 执行工具调用(如果有)
|
|
101
104
|
need_return, result = self.agent._call_tools(response)
|
|
@@ -109,12 +112,12 @@ class MemoryManager:
|
|
|
109
112
|
saved = False
|
|
110
113
|
|
|
111
114
|
if saved:
|
|
112
|
-
|
|
115
|
+
PrettyOutput.auto_print("✅ 已自动保存有价值的信息到记忆系统")
|
|
113
116
|
else:
|
|
114
|
-
|
|
117
|
+
PrettyOutput.auto_print("ℹ️ 本次任务没有特别需要记忆的信息")
|
|
115
118
|
|
|
116
119
|
except Exception as e:
|
|
117
|
-
|
|
120
|
+
PrettyOutput.auto_print(f"❌ 记忆分析失败: {str(e)}")
|
|
118
121
|
finally:
|
|
119
122
|
# 设置记忆提示完成标记,避免事件触发造成重复处理
|
|
120
123
|
self._memory_prompted = True
|
|
@@ -149,7 +152,7 @@ class MemoryManager:
|
|
|
149
152
|
# 事件订阅与处理(旁路)
|
|
150
153
|
# -----------------------
|
|
151
154
|
def _subscribe_events(self) -> None:
|
|
152
|
-
bus = self.agent.get_event_bus()
|
|
155
|
+
bus = self.agent.get_event_bus()
|
|
153
156
|
# 任务开始时重置去重标记
|
|
154
157
|
bus.subscribe(TASK_STARTED, self._on_task_started)
|
|
155
158
|
# 在清理历史前尝试保存记忆(若开启强制保存且尚未处理)
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""方法论分享管理模块"""
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import glob
|
|
5
5
|
import json
|
|
6
|
+
import os
|
|
6
7
|
import shutil
|
|
7
|
-
from typing import
|
|
8
|
+
from typing import Any
|
|
9
|
+
from typing import Dict
|
|
10
|
+
from typing import List
|
|
8
11
|
|
|
9
12
|
import typer
|
|
10
13
|
|
|
11
14
|
from jarvis.jarvis_agent import user_confirm
|
|
12
15
|
from jarvis.jarvis_agent.share_manager import ShareManager
|
|
13
|
-
from jarvis.jarvis_utils.config import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
16
|
+
from jarvis.jarvis_utils.config import get_central_methodology_repo
|
|
17
|
+
from jarvis.jarvis_utils.config import get_methodology_dirs
|
|
18
|
+
from jarvis.jarvis_utils.output import PrettyOutput
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
class MethodologyShareManager(ShareManager):
|
|
@@ -22,8 +24,10 @@ class MethodologyShareManager(ShareManager):
|
|
|
22
24
|
def __init__(self):
|
|
23
25
|
central_repo = get_central_methodology_repo()
|
|
24
26
|
if not central_repo:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
PrettyOutput.auto_print(
|
|
28
|
+
"❌ 错误:未配置中心方法论仓库(central_methodology_repo)"
|
|
29
|
+
)
|
|
30
|
+
PrettyOutput.auto_print("ℹ️ 请在配置文件中设置中心方法论仓库的Git地址")
|
|
27
31
|
raise typer.Exit(code=1)
|
|
28
32
|
|
|
29
33
|
super().__init__(central_repo, "central_methodology_repo")
|
|
@@ -118,8 +122,8 @@ class MethodologyShareManager(ShareManager):
|
|
|
118
122
|
share_list = ["\n将要分享以下方法论到中心仓库:"]
|
|
119
123
|
for meth in resources:
|
|
120
124
|
share_list.append(f"- {meth['problem_type']}")
|
|
121
|
-
joined_list =
|
|
122
|
-
|
|
125
|
+
joined_list = "\n".join(share_list)
|
|
126
|
+
PrettyOutput.auto_print(f"ℹ️ {joined_list}")
|
|
123
127
|
|
|
124
128
|
if not user_confirm("确认分享这些方法论吗?"):
|
|
125
129
|
return []
|
|
@@ -143,7 +147,9 @@ class MethodologyShareManager(ShareManager):
|
|
|
143
147
|
# 获取本地资源
|
|
144
148
|
local_resources = self.get_local_resources()
|
|
145
149
|
if not local_resources:
|
|
146
|
-
|
|
150
|
+
PrettyOutput.auto_print(
|
|
151
|
+
"⚠️ 没有找到新的方法论文件(所有方法论可能已存在于中心仓库)"
|
|
152
|
+
)
|
|
147
153
|
return
|
|
148
154
|
|
|
149
155
|
# 选择要分享的资源
|
|
@@ -155,14 +161,14 @@ class MethodologyShareManager(ShareManager):
|
|
|
155
161
|
copied_list = self.share_resources(selected_resources)
|
|
156
162
|
if copied_list:
|
|
157
163
|
# 一次性显示所有复制结果
|
|
158
|
-
joined_copied =
|
|
159
|
-
|
|
164
|
+
joined_copied = "\n".join(copied_list)
|
|
165
|
+
PrettyOutput.auto_print(f"✅ {joined_copied}")
|
|
160
166
|
|
|
161
167
|
# 提交并推送
|
|
162
168
|
self.commit_and_push(len(selected_resources))
|
|
163
169
|
|
|
164
|
-
|
|
170
|
+
PrettyOutput.auto_print("✅ 方法论已成功分享到中心仓库!")
|
|
165
171
|
|
|
166
172
|
except Exception as e:
|
|
167
|
-
|
|
173
|
+
PrettyOutput.auto_print(f"❌ 分享方法论时出错: {str(e)}")
|
|
168
174
|
raise typer.Exit(code=1)
|
|
@@ -45,12 +45,13 @@ def build_action_prompt(output_handlers: List[OutputHandlerProtocol]) -> str:
|
|
|
45
45
|
</details>
|
|
46
46
|
|
|
47
47
|
<rules>
|
|
48
|
-
# ❗
|
|
49
|
-
1.
|
|
50
|
-
2.
|
|
51
|
-
3.
|
|
52
|
-
4.
|
|
53
|
-
5.
|
|
48
|
+
# ❗ 重要操作使用规则(必须严格遵守,违反将导致错误)
|
|
49
|
+
1. **一次对话只能使用一个操作**:每个响应必须包含且仅包含一个工具调用(任务完成时除外)。同时调用多个工具会导致系统错误。
|
|
50
|
+
2. **禁止虚构结果**:所有操作必须基于实际执行结果,禁止推测、假设或虚构任何执行结果。必须等待工具执行完成并获得实际结果后再进行下一步。
|
|
51
|
+
3. **等待操作结果**:在继续下一步之前,必须等待当前工具的执行结果,不能假设工具执行的结果。
|
|
52
|
+
4. **处理完结果后再调用新的操作**:必须完整处理当前工具的执行结果,包括错误信息、输出内容等,然后再决定下一步操作。
|
|
53
|
+
5. **严格按照每个操作的格式执行**:必须遵循每个工具调用的格式要求,包括参数类型、必需字段等。
|
|
54
|
+
6. 如果对操作使用不清楚,请请求帮助
|
|
54
55
|
</rules>
|
|
55
56
|
</actions>
|
|
56
57
|
"""
|
|
@@ -7,6 +7,8 @@ PromptManager: 统一管理 Agent 的系统提示词与附加提示词的构建
|
|
|
7
7
|
- 先行落地构建逻辑,后续在 Agent 中逐步委派使用
|
|
8
8
|
- 保持与现有工具/记忆系统兼容
|
|
9
9
|
"""
|
|
10
|
+
|
|
11
|
+
import shutil
|
|
10
12
|
from typing import TYPE_CHECKING
|
|
11
13
|
|
|
12
14
|
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
@@ -14,8 +16,7 @@ from jarvis.jarvis_utils.tag import ot
|
|
|
14
16
|
|
|
15
17
|
if TYPE_CHECKING:
|
|
16
18
|
# 避免运行时循环依赖,仅用于类型标注
|
|
17
|
-
from . import Agent
|
|
18
|
-
|
|
19
|
+
from . import Agent
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class PromptManager:
|
|
@@ -35,26 +36,127 @@ class PromptManager:
|
|
|
35
36
|
构建系统提示词,复用现有的工具使用提示生成逻辑,保持行为一致。
|
|
36
37
|
"""
|
|
37
38
|
action_prompt = self.agent.get_tool_usage_prompt()
|
|
39
|
+
|
|
40
|
+
# 检查 task_list_manager 工具是否可用
|
|
41
|
+
task_list_manager_note = ""
|
|
42
|
+
tool_registry = self.agent.get_tool_registry()
|
|
43
|
+
if isinstance(tool_registry, ToolRegistry):
|
|
44
|
+
task_list_tool = tool_registry.get_tool("task_list_manager")
|
|
45
|
+
if task_list_tool:
|
|
46
|
+
task_list_manager_note = """
|
|
47
|
+
|
|
48
|
+
<task_list_manager_guide>
|
|
49
|
+
# 任务列表管理工具使用指南
|
|
50
|
+
|
|
51
|
+
**重要:在开始处理任务的第一步,先判断是否需要创建任务列表**
|
|
52
|
+
|
|
53
|
+
在开始执行任务之前,首先评估任务复杂度。**强烈建议:对于任何需要2个或以上步骤的任务,都应该使用 `task_list_manager` 创建任务列表**。即使任务看似简单,使用任务列表也有助于跟踪进度、记录结果和便于调试。
|
|
54
|
+
|
|
55
|
+
**适合提前规划的任务类型(符合任一情况即应使用):**
|
|
56
|
+
- **多步骤任务**:需要2个或以上步骤才能完成的任务(如:实现完整功能模块、重构大型代码库、修改多个文件)
|
|
57
|
+
- **有依赖关系的任务**:任务之间存在依赖,需要按顺序执行(如:先设计数据库表,再实现API接口)
|
|
58
|
+
- **需要并行执行的任务**:可以同时进行的独立任务(如:同时开发多个功能模块)
|
|
59
|
+
- **需要跟踪进度的长期任务**:需要分阶段完成、跟踪进度的长期项目
|
|
60
|
+
- **需要不同Agent类型的任务**:部分任务需要代码Agent,部分需要通用Agent(如:代码实现 + 文档编写)
|
|
61
|
+
- **需要分阶段验证的任务**:每个阶段完成后需要验证,再继续下一步(如:先实现基础功能,测试通过后再添加高级特性)
|
|
62
|
+
|
|
63
|
+
**🚨 强制使用流程:**
|
|
64
|
+
1. **第一步:识别是否需要拆分** - 如果任务符合上述类型,立即使用 `add_tasks` 创建任务列表
|
|
65
|
+
2. **同时拆分任务** - 在 `add_tasks` 时同时提供 `main_goal` 和 `tasks_info`,一次性创建并添加所有子任务
|
|
66
|
+
3. **强制准备additional_info** - 每次使用 `execute_task` 前必须准备详细的 additional_info 参数
|
|
67
|
+
4. **执行任务** - 使用 `execute_task` 逐个执行任务,系统会自动创建子 Agent
|
|
68
|
+
|
|
69
|
+
**核心功能:**
|
|
70
|
+
- 创建任务列表并添加任务:使用 `add_tasks` 操作,可同时提供 `tasks_info` 一次性创建并添加所有任务
|
|
71
|
+
- 管理任务执行:通过 `execute_task` 自动创建子 Agent 执行任务
|
|
72
|
+
- 跟踪任务状态:查看任务执行进度和结果
|
|
73
|
+
|
|
74
|
+
**使用建议:**
|
|
75
|
+
- **关键原则**:在开始执行任务的第一步就判断是否需要拆分,如果需要则立即创建任务列表,避免先执行部分步骤再意识到需要拆分
|
|
76
|
+
- **简单任务无需拆分**:如果任务可以在1-3步内完成、只涉及单个文件修改、或只需要单次工具调用,绝对不要创建任务列表,直接由主Agent执行
|
|
77
|
+
- **避免过度拆分**:任务拆分应该保持合理粒度,避免将简单任务拆分成过多过细的子任务,这会增加信息传递负担并可能降低执行效率
|
|
78
|
+
- **评估拆分必要性**:对于可以在1-2步内完成的任务,优先考虑由主Agent直接执行,而不是创建子Agent
|
|
79
|
+
- 推荐在 `add_tasks` 时同时提供 `tasks_info`,一次性创建任务列表并添加所有任务
|
|
80
|
+
- 任务之间的依赖关系可以使用任务名称引用(系统会自动匹配)
|
|
81
|
+
- 通过任务列表可以更好地组织和管理任务执行流程,确保任务按正确顺序执行
|
|
82
|
+
</task_list_manager_guide>
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
system_tools_info = self._get_system_tools_info()
|
|
86
|
+
|
|
38
87
|
return f"""
|
|
39
88
|
{self.agent.system_prompt}
|
|
40
89
|
|
|
41
|
-
{action_prompt}
|
|
90
|
+
{action_prompt}{task_list_manager_note}{system_tools_info}
|
|
42
91
|
"""
|
|
43
92
|
|
|
93
|
+
# ----------------------------
|
|
94
|
+
# 系统工具信息
|
|
95
|
+
# ----------------------------
|
|
96
|
+
def _get_system_tools_info(self) -> str:
|
|
97
|
+
"""
|
|
98
|
+
检测并返回rg和fd命令的安装状态信息。
|
|
99
|
+
|
|
100
|
+
返回:
|
|
101
|
+
str: 格式化的系统工具信息字符串,供AI助手了解可用工具
|
|
102
|
+
"""
|
|
103
|
+
tools = []
|
|
104
|
+
|
|
105
|
+
# 检测rg命令
|
|
106
|
+
rg_installed = shutil.which("rg") is not None
|
|
107
|
+
tools.append(f"rg_available: {rg_installed}")
|
|
108
|
+
|
|
109
|
+
# 检测fd命令
|
|
110
|
+
fd_installed = shutil.which("fd") is not None
|
|
111
|
+
tools.append(f"fd_available: {fd_installed}")
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
"""
|
|
115
|
+
<system_info>
|
|
116
|
+
可用工具:
|
|
117
|
+
"""
|
|
118
|
+
+ "\n".join(f"- {tool}" for tool in tools)
|
|
119
|
+
+ """
|
|
120
|
+
- rg: 递归快速搜索文件内容(ripgrep)
|
|
121
|
+
- fd: 快速查找文件(fd-find)
|
|
122
|
+
</system_info>"""
|
|
123
|
+
)
|
|
124
|
+
|
|
44
125
|
# ----------------------------
|
|
45
126
|
# 附加提示词构建
|
|
46
127
|
# ----------------------------
|
|
128
|
+
def _format_token_metadata(self) -> str:
|
|
129
|
+
"""
|
|
130
|
+
格式化token元数据信息,包括已用token和剩余token。
|
|
131
|
+
|
|
132
|
+
返回:
|
|
133
|
+
str: 格式化的token元数据字符串,如果无法获取则返回空字符串
|
|
134
|
+
"""
|
|
135
|
+
try:
|
|
136
|
+
used_tokens = self.agent.session.conversation_length
|
|
137
|
+
remaining_tokens = self.agent.get_remaining_token_count()
|
|
138
|
+
|
|
139
|
+
# 如果无法获取有效数据,返回空字符串
|
|
140
|
+
if used_tokens == 0 and remaining_tokens == 0:
|
|
141
|
+
return ""
|
|
142
|
+
|
|
143
|
+
return f"[Agent元数据] 已用token: {used_tokens} | 剩余token: {remaining_tokens}"
|
|
144
|
+
except Exception:
|
|
145
|
+
return ""
|
|
146
|
+
|
|
47
147
|
def build_default_addon_prompt(self, need_complete: bool) -> str:
|
|
48
148
|
"""
|
|
49
149
|
构建默认附加提示词(与 Agent.make_default_addon_prompt 行为保持一致)。
|
|
50
150
|
仅进行字符串拼装,不操作会话状态。
|
|
51
151
|
"""
|
|
52
152
|
# 结构化系统指令
|
|
53
|
-
action_handlers = ", ".join(
|
|
153
|
+
action_handlers = ", ".join(
|
|
154
|
+
[handler.name() for handler in self.agent.output_handler]
|
|
155
|
+
)
|
|
54
156
|
|
|
55
157
|
# 任务完成提示
|
|
56
158
|
complete_prompt = (
|
|
57
|
-
f"-
|
|
159
|
+
f"- 如果任务已完成,只输出 {ot('!!!COMPLETE!!!')},不要输出其他任何内容。任务总结将会在后面的交互中被询问。"
|
|
58
160
|
if need_complete and self.agent.auto_complete
|
|
59
161
|
else ""
|
|
60
162
|
)
|
|
@@ -65,11 +167,14 @@ class PromptManager:
|
|
|
65
167
|
"", tool_registry if isinstance(tool_registry, ToolRegistry) else None
|
|
66
168
|
)
|
|
67
169
|
|
|
170
|
+
# 获取token元数据
|
|
171
|
+
token_metadata = self._format_token_metadata()
|
|
172
|
+
token_metadata_prompt = f"{token_metadata}\n" if token_metadata else ""
|
|
173
|
+
|
|
68
174
|
addon_prompt = f"""
|
|
69
175
|
<system_prompt>
|
|
70
|
-
请判断是否已经完成任务,如果已经完成:
|
|
71
|
-
- 直接输出完成原因,不需要再有新的操作,不要输出{ot(
|
|
72
|
-
{complete_prompt}
|
|
176
|
+
{token_metadata_prompt} 请判断是否已经完成任务,如果已经完成:
|
|
177
|
+
{complete_prompt if complete_prompt else f"- 直接输出完成原因,不需要再有新的操作,不要输出{ot('TOOL_CALL')}标签"}
|
|
73
178
|
如果没有完成,请进行下一步操作:
|
|
74
179
|
- 仅包含一个操作
|
|
75
180
|
- 如果信息不明确,请请求用户补充
|