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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
方法论管理模块
|
|
4
3
|
该模块提供了加载和搜索方法论的实用工具。
|
|
@@ -7,21 +6,27 @@
|
|
|
7
6
|
- 生成方法论临时文件
|
|
8
7
|
- 上传方法论文件到大模型
|
|
9
8
|
"""
|
|
9
|
+
|
|
10
10
|
import json
|
|
11
11
|
import os
|
|
12
|
+
|
|
13
|
+
from jarvis.jarvis_utils.output import PrettyOutput
|
|
14
|
+
|
|
15
|
+
# -*- coding: utf-8 -*-
|
|
12
16
|
import tempfile
|
|
13
|
-
from typing import Any
|
|
17
|
+
from typing import Any
|
|
18
|
+
from typing import Dict
|
|
19
|
+
from typing import List
|
|
20
|
+
from typing import Optional
|
|
14
21
|
|
|
15
22
|
from jarvis.jarvis_platform.base import BasePlatform
|
|
16
23
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
17
|
-
from jarvis.jarvis_utils.config import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
get_max_input_token_count,
|
|
22
|
-
)
|
|
23
|
-
from jarvis.jarvis_utils.utils import daily_check_git_updates
|
|
24
|
+
from jarvis.jarvis_utils.config import get_central_methodology_repo
|
|
25
|
+
from jarvis.jarvis_utils.config import get_cheap_max_input_token_count
|
|
26
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
27
|
+
from jarvis.jarvis_utils.config import get_methodology_dirs
|
|
24
28
|
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
29
|
+
from jarvis.jarvis_utils.utils import daily_check_git_updates
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
def _get_methodology_directory() -> str:
|
|
@@ -36,7 +41,7 @@ def _get_methodology_directory() -> str:
|
|
|
36
41
|
try:
|
|
37
42
|
os.makedirs(methodology_dir, exist_ok=True)
|
|
38
43
|
except Exception as e:
|
|
39
|
-
|
|
44
|
+
PrettyOutput.auto_print(f"❌ 创建方法论目录失败: {str(e)}")
|
|
40
45
|
return methodology_dir
|
|
41
46
|
|
|
42
47
|
|
|
@@ -68,12 +73,12 @@ def _load_all_methodologies() -> Dict[str, str]:
|
|
|
68
73
|
try:
|
|
69
74
|
import subprocess
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
PrettyOutput.auto_print(f"ℹ️ 正在克隆中心方法论仓库: {central_repo}")
|
|
72
77
|
subprocess.run(
|
|
73
78
|
["git", "clone", central_repo, central_repo_path], check=True
|
|
74
79
|
)
|
|
75
80
|
except Exception as e:
|
|
76
|
-
|
|
81
|
+
PrettyOutput.auto_print(f"❌ 克隆中心方法论仓库失败: {str(e)}")
|
|
77
82
|
|
|
78
83
|
# --- 全局每日更新检查 ---
|
|
79
84
|
daily_check_git_updates(methodology_dirs, "methodologies")
|
|
@@ -105,9 +110,9 @@ def _load_all_methodologies() -> Dict[str, str]:
|
|
|
105
110
|
|
|
106
111
|
# 统一打印目录警告与文件加载失败信息
|
|
107
112
|
if warn_dirs:
|
|
108
|
-
|
|
113
|
+
PrettyOutput.auto_print("⚠️ " + "\n⚠️ ".join(warn_dirs))
|
|
109
114
|
if error_lines:
|
|
110
|
-
|
|
115
|
+
PrettyOutput.auto_print("⚠️ " + "\n⚠️ ".join(error_lines))
|
|
111
116
|
return all_methodologies
|
|
112
117
|
|
|
113
118
|
|
|
@@ -140,7 +145,7 @@ def _create_methodology_temp_file(methodologies: Dict[str, str]) -> Optional[str
|
|
|
140
145
|
|
|
141
146
|
return temp_path
|
|
142
147
|
except Exception as e:
|
|
143
|
-
|
|
148
|
+
PrettyOutput.auto_print(f"❌ 创建方法论临时文件失败: {str(e)}")
|
|
144
149
|
return None
|
|
145
150
|
|
|
146
151
|
|
|
@@ -156,12 +161,12 @@ def upload_methodology(platform: BasePlatform, other_files: List[str] = []) -> b
|
|
|
156
161
|
"""
|
|
157
162
|
methodology_dir = _get_methodology_directory()
|
|
158
163
|
if not os.path.exists(methodology_dir):
|
|
159
|
-
|
|
164
|
+
PrettyOutput.auto_print("⚠️ 方法论文档不存在")
|
|
160
165
|
return False
|
|
161
166
|
|
|
162
167
|
methodologies = _load_all_methodologies()
|
|
163
168
|
if not methodologies:
|
|
164
|
-
|
|
169
|
+
PrettyOutput.auto_print("⚠️ 没有可用的方法论文档")
|
|
165
170
|
return False
|
|
166
171
|
|
|
167
172
|
temp_file_path = _create_methodology_temp_file(methodologies)
|
|
@@ -207,12 +212,12 @@ def load_methodology(
|
|
|
207
212
|
|
|
208
213
|
try:
|
|
209
214
|
# 加载所有方法论
|
|
210
|
-
|
|
215
|
+
PrettyOutput.auto_print("📁 加载方法论文件...")
|
|
211
216
|
methodologies = _load_all_methodologies()
|
|
212
217
|
if not methodologies:
|
|
213
|
-
|
|
218
|
+
PrettyOutput.auto_print("⚠️ 没有找到方法论文件")
|
|
214
219
|
return ""
|
|
215
|
-
|
|
220
|
+
PrettyOutput.auto_print(f"✅ 加载方法论文件完成 (共 {len(methodologies)} 个)")
|
|
216
221
|
|
|
217
222
|
if platform_name:
|
|
218
223
|
platform = PlatformRegistry().create_platform(platform_name)
|
|
@@ -223,7 +228,7 @@ def load_methodology(
|
|
|
223
228
|
platform = PlatformRegistry().get_cheap_platform()
|
|
224
229
|
|
|
225
230
|
if not platform:
|
|
226
|
-
|
|
231
|
+
PrettyOutput.auto_print("❌ 无法创建平台实例")
|
|
227
232
|
return ""
|
|
228
233
|
|
|
229
234
|
platform.set_suppress_output(True)
|
|
@@ -307,10 +312,10 @@ def load_methodology(
|
|
|
307
312
|
methodology_token_limit = None
|
|
308
313
|
except Exception:
|
|
309
314
|
pass
|
|
310
|
-
|
|
311
|
-
# 回退方案:使用输入窗口的2/3
|
|
315
|
+
|
|
316
|
+
# 回退方案:使用输入窗口的2/3(方法论使用cheap模型)
|
|
312
317
|
if methodology_token_limit is None:
|
|
313
|
-
max_input_tokens =
|
|
318
|
+
max_input_tokens = get_cheap_max_input_token_count()
|
|
314
319
|
methodology_token_limit = int(max_input_tokens * 2 / 3)
|
|
315
320
|
|
|
316
321
|
# 步骤3:将选择出来的方法论内容提供给大模型生成步骤
|
|
@@ -353,7 +358,9 @@ def load_methodology(
|
|
|
353
358
|
|
|
354
359
|
# 检查是否会超过token限制
|
|
355
360
|
if total_methodology_tokens + methodology_tokens > available_tokens:
|
|
356
|
-
|
|
361
|
+
PrettyOutput.auto_print(
|
|
362
|
+
f"ℹ️ 达到方法论token限制 ({total_methodology_tokens}/{available_tokens}),停止加载更多方法论"
|
|
363
|
+
)
|
|
357
364
|
break
|
|
358
365
|
|
|
359
366
|
final_prompt += methodology_text
|
|
@@ -362,16 +369,18 @@ def load_methodology(
|
|
|
362
369
|
|
|
363
370
|
# 如果一个方法论都没有加载成功
|
|
364
371
|
if selected_count == 0:
|
|
365
|
-
|
|
372
|
+
PrettyOutput.auto_print("⚠️ 警告:由于token限制,无法加载任何方法论内容")
|
|
366
373
|
return "没有历史方法论可参考"
|
|
367
374
|
|
|
368
375
|
final_prompt += suffix_prompt
|
|
369
376
|
|
|
370
|
-
|
|
377
|
+
PrettyOutput.auto_print(
|
|
378
|
+
f"ℹ️ 成功加载 {selected_count} 个方法论,总token数: {total_methodology_tokens}"
|
|
379
|
+
)
|
|
371
380
|
|
|
372
381
|
# 如果内容不大,直接使用chat_until_success
|
|
373
382
|
return platform.chat_until_success(final_prompt)
|
|
374
383
|
|
|
375
384
|
except Exception as e:
|
|
376
|
-
|
|
385
|
+
PrettyOutput.auto_print(f"❌ 加载方法论失败: {str(e)}")
|
|
377
386
|
return ""
|
jarvis/jarvis_utils/output.py
CHANGED
|
@@ -8,22 +8,28 @@
|
|
|
8
8
|
- 多种编程语言的语法高亮支持
|
|
9
9
|
- 结构化输出的面板显示
|
|
10
10
|
"""
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
from abc import ABC
|
|
13
|
+
from abc import abstractmethod
|
|
14
|
+
from dataclasses import dataclass
|
|
12
15
|
from enum import Enum
|
|
13
|
-
from typing import
|
|
16
|
+
from typing import Any
|
|
17
|
+
from typing import Dict
|
|
18
|
+
from typing import List
|
|
19
|
+
from typing import Optional
|
|
20
|
+
from typing import Tuple
|
|
21
|
+
from datetime import datetime
|
|
14
22
|
|
|
15
23
|
from pygments.lexers import guess_lexer
|
|
16
24
|
from pygments.util import ClassNotFound
|
|
17
|
-
from rich.box import SIMPLE
|
|
18
|
-
from rich.panel import Panel
|
|
19
25
|
from rich.style import Style as RichStyle
|
|
20
26
|
from rich.syntax import Syntax
|
|
21
27
|
from rich.text import Text
|
|
22
28
|
|
|
23
|
-
from jarvis.jarvis_utils.config import get_pretty_output
|
|
24
|
-
from jarvis.jarvis_utils.
|
|
25
|
-
from
|
|
26
|
-
from
|
|
29
|
+
from jarvis.jarvis_utils.config import get_pretty_output
|
|
30
|
+
from jarvis.jarvis_utils.config import is_print_error_traceback
|
|
31
|
+
from jarvis.jarvis_utils.globals import console
|
|
32
|
+
from jarvis.jarvis_utils.globals import get_agent_list
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
class OutputType(Enum):
|
|
@@ -97,12 +103,89 @@ class ConsoleOutputSink(OutputSink):
|
|
|
97
103
|
def emit(self, event: OutputEvent) -> None:
|
|
98
104
|
# 章节输出
|
|
99
105
|
if event.section is not None:
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
# 使用带背景色和样式的Text替代Panel
|
|
107
|
+
style_config = {
|
|
108
|
+
OutputType.SYSTEM: RichStyle(
|
|
109
|
+
color="cyan",
|
|
110
|
+
bgcolor="#1e2b3c",
|
|
111
|
+
frame=True,
|
|
112
|
+
meta={"icon": "🤖"},
|
|
113
|
+
),
|
|
114
|
+
OutputType.CODE: RichStyle(
|
|
115
|
+
color="dark_green",
|
|
116
|
+
bgcolor="#1c2b1c",
|
|
117
|
+
frame=True,
|
|
118
|
+
meta={"icon": "📝"},
|
|
119
|
+
),
|
|
120
|
+
OutputType.RESULT: RichStyle(
|
|
121
|
+
color="blue",
|
|
122
|
+
bgcolor="#1c1c2b",
|
|
123
|
+
frame=True,
|
|
124
|
+
meta={"icon": "✨"},
|
|
125
|
+
),
|
|
126
|
+
OutputType.ERROR: RichStyle(
|
|
127
|
+
color="dark_red", frame=True, bgcolor="#2b1c1c", meta={"icon": "❌"}
|
|
128
|
+
),
|
|
129
|
+
OutputType.INFO: RichStyle(
|
|
130
|
+
color="cyan",
|
|
131
|
+
frame=True,
|
|
132
|
+
bgcolor="#2b2b1c",
|
|
133
|
+
meta={"icon": "ℹ️"},
|
|
134
|
+
),
|
|
135
|
+
OutputType.PLANNING: RichStyle(
|
|
136
|
+
color="dark_magenta",
|
|
137
|
+
bold=True,
|
|
138
|
+
frame=True,
|
|
139
|
+
bgcolor="#2b1c2b",
|
|
140
|
+
meta={"icon": "📋"},
|
|
141
|
+
),
|
|
142
|
+
OutputType.PROGRESS: RichStyle(
|
|
143
|
+
color="bright_black",
|
|
144
|
+
encircle=True,
|
|
145
|
+
frame=True,
|
|
146
|
+
bgcolor="#1c1c1c",
|
|
147
|
+
meta={"icon": "⏳"},
|
|
148
|
+
),
|
|
149
|
+
OutputType.SUCCESS: RichStyle(
|
|
150
|
+
color="green",
|
|
151
|
+
bold=True,
|
|
152
|
+
strike=False,
|
|
153
|
+
bgcolor="#1c2b1c",
|
|
154
|
+
meta={"icon": "✅"},
|
|
155
|
+
),
|
|
156
|
+
OutputType.WARNING: RichStyle(
|
|
157
|
+
color="gold3",
|
|
158
|
+
bold=True,
|
|
159
|
+
blink2=True,
|
|
160
|
+
bgcolor="#2b2b1c",
|
|
161
|
+
meta={"icon": "⚠️"},
|
|
162
|
+
),
|
|
163
|
+
OutputType.DEBUG: RichStyle(
|
|
164
|
+
color="grey50",
|
|
165
|
+
dim=True,
|
|
166
|
+
conceal=True,
|
|
167
|
+
bgcolor="#1c1c1c",
|
|
168
|
+
meta={"icon": "🔍"},
|
|
169
|
+
),
|
|
170
|
+
OutputType.USER: RichStyle(
|
|
171
|
+
color="green4",
|
|
172
|
+
frame=True,
|
|
173
|
+
bgcolor="#1c2b2b",
|
|
174
|
+
meta={"icon": "👤"},
|
|
175
|
+
),
|
|
176
|
+
OutputType.TOOL: RichStyle(
|
|
177
|
+
color="sea_green3",
|
|
178
|
+
bgcolor="#1c2b2b",
|
|
179
|
+
frame=True,
|
|
180
|
+
meta={"icon": "🔧"},
|
|
181
|
+
),
|
|
182
|
+
}
|
|
183
|
+
style_obj = style_config.get(event.output_type, RichStyle(color="white"))
|
|
184
|
+
text = Text(f"\n{event.section}\n", style=style_obj, justify="center")
|
|
102
185
|
if get_pretty_output():
|
|
103
|
-
console.print(panel)
|
|
104
|
-
else:
|
|
105
186
|
console.print(text)
|
|
187
|
+
else:
|
|
188
|
+
console.print(Text(event.section, style=event.output_type.value))
|
|
106
189
|
return
|
|
107
190
|
|
|
108
191
|
# 普通内容输出
|
|
@@ -112,7 +195,23 @@ class ConsoleOutputSink(OutputSink):
|
|
|
112
195
|
else PrettyOutput._detect_language(event.text, default_lang="markdown")
|
|
113
196
|
)
|
|
114
197
|
|
|
115
|
-
#
|
|
198
|
+
# 文字颜色映射 - 使用柔和的暗色调
|
|
199
|
+
text_colors = {
|
|
200
|
+
OutputType.SYSTEM: "dark_cyan",
|
|
201
|
+
OutputType.CODE: "dark_green",
|
|
202
|
+
OutputType.RESULT: "dark_blue",
|
|
203
|
+
OutputType.ERROR: "dark_red",
|
|
204
|
+
OutputType.INFO: "blue",
|
|
205
|
+
OutputType.PLANNING: "purple",
|
|
206
|
+
OutputType.PROGRESS: "dim",
|
|
207
|
+
OutputType.SUCCESS: "green",
|
|
208
|
+
OutputType.WARNING: "orange3",
|
|
209
|
+
OutputType.DEBUG: "grey50",
|
|
210
|
+
OutputType.USER: "dark_sea_green",
|
|
211
|
+
OutputType.TOOL: "dark_olive_green",
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# 背景色映射(保持原有定义)
|
|
116
215
|
styles: Dict[OutputType, Dict[str, Any]] = {
|
|
117
216
|
OutputType.SYSTEM: dict(bgcolor="#1e2b3c"),
|
|
118
217
|
OutputType.CODE: dict(bgcolor="#1c2b1c"),
|
|
@@ -130,63 +229,63 @@ class ConsoleOutputSink(OutputSink):
|
|
|
130
229
|
|
|
131
230
|
header_styles = {
|
|
132
231
|
OutputType.SYSTEM: RichStyle(
|
|
133
|
-
color="
|
|
232
|
+
color="cyan", bgcolor="#1e2b3c", frame=True, meta={"icon": "🤖"}
|
|
134
233
|
),
|
|
135
234
|
OutputType.CODE: RichStyle(
|
|
136
|
-
color="
|
|
235
|
+
color="dark_green", bgcolor="#1c2b1c", frame=True, meta={"icon": "📝"}
|
|
137
236
|
),
|
|
138
237
|
OutputType.RESULT: RichStyle(
|
|
139
|
-
color="
|
|
238
|
+
color="blue", bgcolor="#1c1c2b", frame=True, meta={"icon": "✨"}
|
|
140
239
|
),
|
|
141
240
|
OutputType.ERROR: RichStyle(
|
|
142
|
-
color="
|
|
241
|
+
color="dark_red", frame=True, bgcolor="#2b1c1c", meta={"icon": "❌"}
|
|
143
242
|
),
|
|
144
243
|
OutputType.INFO: RichStyle(
|
|
145
|
-
color="
|
|
244
|
+
color="cyan", frame=True, bgcolor="#2b2b1c", meta={"icon": "ℹ️"}
|
|
146
245
|
),
|
|
147
246
|
OutputType.PLANNING: RichStyle(
|
|
148
|
-
color="
|
|
247
|
+
color="dark_magenta",
|
|
149
248
|
bold=True,
|
|
150
249
|
frame=True,
|
|
151
250
|
bgcolor="#2b1c2b",
|
|
152
251
|
meta={"icon": "📋"},
|
|
153
252
|
),
|
|
154
253
|
OutputType.PROGRESS: RichStyle(
|
|
155
|
-
color="
|
|
254
|
+
color="bright_black",
|
|
156
255
|
encircle=True,
|
|
157
256
|
frame=True,
|
|
158
257
|
bgcolor="#1c1c1c",
|
|
159
258
|
meta={"icon": "⏳"},
|
|
160
259
|
),
|
|
161
260
|
OutputType.SUCCESS: RichStyle(
|
|
162
|
-
color="
|
|
261
|
+
color="green",
|
|
163
262
|
bold=True,
|
|
164
263
|
strike=False,
|
|
165
264
|
bgcolor="#1c2b1c",
|
|
166
265
|
meta={"icon": "✅"},
|
|
167
266
|
),
|
|
168
267
|
OutputType.WARNING: RichStyle(
|
|
169
|
-
color="
|
|
268
|
+
color="gold3",
|
|
170
269
|
bold=True,
|
|
171
270
|
blink2=True,
|
|
172
271
|
bgcolor="#2b2b1c",
|
|
173
272
|
meta={"icon": "⚠️"},
|
|
174
273
|
),
|
|
175
274
|
OutputType.DEBUG: RichStyle(
|
|
176
|
-
color="
|
|
275
|
+
color="grey50",
|
|
177
276
|
dim=True,
|
|
178
277
|
conceal=True,
|
|
179
278
|
bgcolor="#1c1c1c",
|
|
180
279
|
meta={"icon": "🔍"},
|
|
181
280
|
),
|
|
182
281
|
OutputType.USER: RichStyle(
|
|
183
|
-
color="
|
|
282
|
+
color="green4",
|
|
184
283
|
frame=True,
|
|
185
284
|
bgcolor="#1c2b2b",
|
|
186
285
|
meta={"icon": "👤"},
|
|
187
286
|
),
|
|
188
287
|
OutputType.TOOL: RichStyle(
|
|
189
|
-
color="
|
|
288
|
+
color="sea_green3",
|
|
190
289
|
bgcolor="#1c2b2b",
|
|
191
290
|
frame=True,
|
|
192
291
|
meta={"icon": "🔧"},
|
|
@@ -204,14 +303,22 @@ class ConsoleOutputSink(OutputSink):
|
|
|
204
303
|
word_wrap=True,
|
|
205
304
|
background_color=styles[event.output_type]["bgcolor"],
|
|
206
305
|
)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
306
|
+
# 直接输出带背景色的内容,不再使用Panel包装
|
|
307
|
+
agent_name = PrettyOutput._format(event.output_type, event.timestamp)
|
|
308
|
+
header_text = Text(
|
|
309
|
+
agent_name,
|
|
310
|
+
style=RichStyle(color="grey58"),
|
|
212
311
|
)
|
|
213
312
|
if get_pretty_output():
|
|
214
|
-
|
|
313
|
+
# 合并header和content在同一行显示,应用文字颜色
|
|
314
|
+
combined_text = Text()
|
|
315
|
+
combined_text.append(header_text)
|
|
316
|
+
combined_text.append(" ") # 添加空格分隔
|
|
317
|
+
colored_content = Text(
|
|
318
|
+
event.text, style=RichStyle(color=text_colors[event.output_type])
|
|
319
|
+
)
|
|
320
|
+
combined_text.append(colored_content)
|
|
321
|
+
console.print(combined_text)
|
|
215
322
|
else:
|
|
216
323
|
console.print(content)
|
|
217
324
|
if event.traceback or (
|
|
@@ -311,7 +418,7 @@ class PrettyOutput:
|
|
|
311
418
|
"""
|
|
312
419
|
try:
|
|
313
420
|
lexer = guess_lexer(text)
|
|
314
|
-
detected_lang = lexer.name
|
|
421
|
+
detected_lang = lexer.name
|
|
315
422
|
return PrettyOutput._lang_map.get(detected_lang, default_lang)
|
|
316
423
|
except (ClassNotFound, Exception):
|
|
317
424
|
return default_lang
|
|
@@ -319,23 +426,24 @@ class PrettyOutput:
|
|
|
319
426
|
@staticmethod
|
|
320
427
|
def _format(output_type: OutputType, timestamp: bool = True) -> str:
|
|
321
428
|
"""
|
|
322
|
-
|
|
429
|
+
返回带时间戳前缀的Agent名字格式。
|
|
323
430
|
|
|
324
431
|
参数:
|
|
325
|
-
output_type:
|
|
432
|
+
output_type: 输出类型(不再使用)
|
|
326
433
|
timestamp: 是否包含时间戳
|
|
327
434
|
|
|
328
435
|
返回:
|
|
329
|
-
|
|
436
|
+
str: 包含时间戳和Agent名字的字符串
|
|
330
437
|
"""
|
|
331
|
-
icon = PrettyOutput._ICONS.get(output_type, "")
|
|
332
|
-
formatted = f"{icon} "
|
|
333
|
-
if timestamp:
|
|
334
|
-
formatted += f"[{datetime.now().strftime('%H:%M:%S')}][{output_type.value}]"
|
|
335
438
|
agent_info = get_agent_list()
|
|
336
|
-
if agent_info:
|
|
337
|
-
|
|
338
|
-
|
|
439
|
+
if not agent_info:
|
|
440
|
+
return ""
|
|
441
|
+
|
|
442
|
+
if timestamp:
|
|
443
|
+
current_time = datetime.now().strftime("%H:%M:%S")
|
|
444
|
+
return f"[{current_time}] {agent_info}"
|
|
445
|
+
else:
|
|
446
|
+
return agent_info
|
|
339
447
|
|
|
340
448
|
@staticmethod
|
|
341
449
|
def print(
|
|
@@ -423,5 +531,54 @@ class PrettyOutput:
|
|
|
423
531
|
colored_text = Text(
|
|
424
532
|
"\n".join(colored_lines), style=OutputType.TOOL.value, justify="center"
|
|
425
533
|
)
|
|
426
|
-
|
|
427
|
-
console.print(
|
|
534
|
+
# 直接输出渐变文本,不再使用Panel包装
|
|
535
|
+
console.print(colored_text)
|
|
536
|
+
|
|
537
|
+
@staticmethod
|
|
538
|
+
def auto_print(text: str, timestamp: bool = True) -> None:
|
|
539
|
+
"""
|
|
540
|
+
自动根据打印信息的前缀emoji判断类型并着色输出。
|
|
541
|
+
|
|
542
|
+
支持的emoji前缀映射:
|
|
543
|
+
- ⚠️ -> WARNING (黄色警告)
|
|
544
|
+
- ❌ -> ERROR (红色错误)
|
|
545
|
+
- ✅ -> SUCCESS (绿色成功)
|
|
546
|
+
- ℹ️ -> INFO (青色信息)
|
|
547
|
+
- 📋 -> PLANNING (紫色规划)
|
|
548
|
+
- ⏳ -> PROGRESS (白色进度)
|
|
549
|
+
- 🔍 -> DEBUG (灰色调试)
|
|
550
|
+
- 🤖 -> SYSTEM (青色系统)
|
|
551
|
+
- 📝 -> CODE (绿色代码)
|
|
552
|
+
- ✨ -> RESULT (蓝色结果)
|
|
553
|
+
- 👤 -> USER (绿色用户)
|
|
554
|
+
- 🔧 -> TOOL (绿色工具)
|
|
555
|
+
|
|
556
|
+
参数:
|
|
557
|
+
text: 要打印的文本
|
|
558
|
+
timestamp: 是否显示时间戳
|
|
559
|
+
"""
|
|
560
|
+
# 定义emoji到OutputType的映射
|
|
561
|
+
emoji_mapping = {
|
|
562
|
+
"⚠️": OutputType.WARNING,
|
|
563
|
+
"❌": OutputType.ERROR,
|
|
564
|
+
"✅": OutputType.SUCCESS,
|
|
565
|
+
"ℹ️": OutputType.INFO,
|
|
566
|
+
"📋": OutputType.PLANNING,
|
|
567
|
+
"⏳": OutputType.PROGRESS,
|
|
568
|
+
"🔍": OutputType.DEBUG,
|
|
569
|
+
"🤖": OutputType.SYSTEM,
|
|
570
|
+
"📝": OutputType.CODE,
|
|
571
|
+
"✨": OutputType.RESULT,
|
|
572
|
+
"👤": OutputType.USER,
|
|
573
|
+
"🔧": OutputType.TOOL,
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
# 检测emoji前缀
|
|
577
|
+
output_type = OutputType.INFO # 默认类型
|
|
578
|
+
for emoji, type_enum in emoji_mapping.items():
|
|
579
|
+
if text.startswith(emoji):
|
|
580
|
+
output_type = type_enum
|
|
581
|
+
break
|
|
582
|
+
|
|
583
|
+
# 使用现有的print方法进行着色输出
|
|
584
|
+
PrettyOutput.print(text=text, output_type=output_type, timestamp=timestamp)
|