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.
Files changed (279) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +567 -222
  3. jarvis/jarvis_agent/agent_manager.py +19 -12
  4. jarvis/jarvis_agent/builtin_input_handler.py +79 -11
  5. jarvis/jarvis_agent/config_editor.py +7 -2
  6. jarvis/jarvis_agent/event_bus.py +24 -13
  7. jarvis/jarvis_agent/events.py +19 -1
  8. jarvis/jarvis_agent/file_context_handler.py +67 -64
  9. jarvis/jarvis_agent/file_methodology_manager.py +38 -24
  10. jarvis/jarvis_agent/jarvis.py +186 -114
  11. jarvis/jarvis_agent/language_extractors/__init__.py +8 -1
  12. jarvis/jarvis_agent/language_extractors/c_extractor.py +7 -4
  13. jarvis/jarvis_agent/language_extractors/cpp_extractor.py +9 -4
  14. jarvis/jarvis_agent/language_extractors/go_extractor.py +7 -4
  15. jarvis/jarvis_agent/language_extractors/java_extractor.py +27 -20
  16. jarvis/jarvis_agent/language_extractors/javascript_extractor.py +22 -17
  17. jarvis/jarvis_agent/language_extractors/python_extractor.py +7 -4
  18. jarvis/jarvis_agent/language_extractors/rust_extractor.py +7 -4
  19. jarvis/jarvis_agent/language_extractors/typescript_extractor.py +22 -17
  20. jarvis/jarvis_agent/language_support_info.py +250 -219
  21. jarvis/jarvis_agent/main.py +19 -23
  22. jarvis/jarvis_agent/memory_manager.py +9 -6
  23. jarvis/jarvis_agent/methodology_share_manager.py +21 -15
  24. jarvis/jarvis_agent/output_handler.py +4 -2
  25. jarvis/jarvis_agent/prompt_builder.py +7 -6
  26. jarvis/jarvis_agent/prompt_manager.py +113 -8
  27. jarvis/jarvis_agent/prompts.py +317 -85
  28. jarvis/jarvis_agent/protocols.py +5 -2
  29. jarvis/jarvis_agent/run_loop.py +192 -32
  30. jarvis/jarvis_agent/session_manager.py +7 -3
  31. jarvis/jarvis_agent/share_manager.py +23 -13
  32. jarvis/jarvis_agent/shell_input_handler.py +12 -8
  33. jarvis/jarvis_agent/stdio_redirect.py +25 -26
  34. jarvis/jarvis_agent/task_analyzer.py +29 -23
  35. jarvis/jarvis_agent/task_list.py +869 -0
  36. jarvis/jarvis_agent/task_manager.py +26 -23
  37. jarvis/jarvis_agent/tool_executor.py +6 -5
  38. jarvis/jarvis_agent/tool_share_manager.py +24 -14
  39. jarvis/jarvis_agent/user_interaction.py +3 -3
  40. jarvis/jarvis_agent/utils.py +9 -1
  41. jarvis/jarvis_agent/web_bridge.py +37 -17
  42. jarvis/jarvis_agent/web_output_sink.py +5 -2
  43. jarvis/jarvis_agent/web_server.py +165 -36
  44. jarvis/jarvis_c2rust/__init__.py +1 -1
  45. jarvis/jarvis_c2rust/cli.py +260 -141
  46. jarvis/jarvis_c2rust/collector.py +37 -18
  47. jarvis/jarvis_c2rust/constants.py +60 -0
  48. jarvis/jarvis_c2rust/library_replacer.py +242 -1010
  49. jarvis/jarvis_c2rust/library_replacer_checkpoint.py +133 -0
  50. jarvis/jarvis_c2rust/library_replacer_llm.py +287 -0
  51. jarvis/jarvis_c2rust/library_replacer_loader.py +191 -0
  52. jarvis/jarvis_c2rust/library_replacer_output.py +134 -0
  53. jarvis/jarvis_c2rust/library_replacer_prompts.py +124 -0
  54. jarvis/jarvis_c2rust/library_replacer_utils.py +188 -0
  55. jarvis/jarvis_c2rust/llm_module_agent.py +98 -1044
  56. jarvis/jarvis_c2rust/llm_module_agent_apply.py +170 -0
  57. jarvis/jarvis_c2rust/llm_module_agent_executor.py +288 -0
  58. jarvis/jarvis_c2rust/llm_module_agent_loader.py +170 -0
  59. jarvis/jarvis_c2rust/llm_module_agent_prompts.py +268 -0
  60. jarvis/jarvis_c2rust/llm_module_agent_types.py +57 -0
  61. jarvis/jarvis_c2rust/llm_module_agent_utils.py +150 -0
  62. jarvis/jarvis_c2rust/llm_module_agent_validator.py +119 -0
  63. jarvis/jarvis_c2rust/loaders.py +28 -10
  64. jarvis/jarvis_c2rust/models.py +5 -2
  65. jarvis/jarvis_c2rust/optimizer.py +192 -1974
  66. jarvis/jarvis_c2rust/optimizer_build_fix.py +286 -0
  67. jarvis/jarvis_c2rust/optimizer_clippy.py +766 -0
  68. jarvis/jarvis_c2rust/optimizer_config.py +49 -0
  69. jarvis/jarvis_c2rust/optimizer_docs.py +183 -0
  70. jarvis/jarvis_c2rust/optimizer_options.py +48 -0
  71. jarvis/jarvis_c2rust/optimizer_progress.py +469 -0
  72. jarvis/jarvis_c2rust/optimizer_report.py +52 -0
  73. jarvis/jarvis_c2rust/optimizer_unsafe.py +309 -0
  74. jarvis/jarvis_c2rust/optimizer_utils.py +469 -0
  75. jarvis/jarvis_c2rust/optimizer_visibility.py +185 -0
  76. jarvis/jarvis_c2rust/scanner.py +229 -166
  77. jarvis/jarvis_c2rust/transpiler.py +531 -2732
  78. jarvis/jarvis_c2rust/transpiler_agents.py +503 -0
  79. jarvis/jarvis_c2rust/transpiler_build.py +1294 -0
  80. jarvis/jarvis_c2rust/transpiler_codegen.py +204 -0
  81. jarvis/jarvis_c2rust/transpiler_compile.py +146 -0
  82. jarvis/jarvis_c2rust/transpiler_config.py +178 -0
  83. jarvis/jarvis_c2rust/transpiler_context.py +122 -0
  84. jarvis/jarvis_c2rust/transpiler_executor.py +516 -0
  85. jarvis/jarvis_c2rust/transpiler_generation.py +278 -0
  86. jarvis/jarvis_c2rust/transpiler_git.py +163 -0
  87. jarvis/jarvis_c2rust/transpiler_mod_utils.py +225 -0
  88. jarvis/jarvis_c2rust/transpiler_modules.py +336 -0
  89. jarvis/jarvis_c2rust/transpiler_planning.py +394 -0
  90. jarvis/jarvis_c2rust/transpiler_review.py +1196 -0
  91. jarvis/jarvis_c2rust/transpiler_symbols.py +176 -0
  92. jarvis/jarvis_c2rust/utils.py +269 -79
  93. jarvis/jarvis_code_agent/after_change.py +233 -0
  94. jarvis/jarvis_code_agent/build_validation_config.py +37 -30
  95. jarvis/jarvis_code_agent/builtin_rules.py +68 -0
  96. jarvis/jarvis_code_agent/code_agent.py +976 -1517
  97. jarvis/jarvis_code_agent/code_agent_build.py +227 -0
  98. jarvis/jarvis_code_agent/code_agent_diff.py +246 -0
  99. jarvis/jarvis_code_agent/code_agent_git.py +525 -0
  100. jarvis/jarvis_code_agent/code_agent_impact.py +177 -0
  101. jarvis/jarvis_code_agent/code_agent_lint.py +283 -0
  102. jarvis/jarvis_code_agent/code_agent_llm.py +159 -0
  103. jarvis/jarvis_code_agent/code_agent_postprocess.py +105 -0
  104. jarvis/jarvis_code_agent/code_agent_prompts.py +46 -0
  105. jarvis/jarvis_code_agent/code_agent_rules.py +305 -0
  106. jarvis/jarvis_code_agent/code_analyzer/__init__.py +52 -48
  107. jarvis/jarvis_code_agent/code_analyzer/base_language.py +12 -10
  108. jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +12 -11
  109. jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +16 -12
  110. jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +26 -17
  111. jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +558 -104
  112. jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +27 -16
  113. jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +22 -18
  114. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +21 -16
  115. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +20 -16
  116. jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +27 -16
  117. jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +47 -23
  118. jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +71 -37
  119. jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +162 -35
  120. jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +111 -57
  121. jarvis/jarvis_code_agent/code_analyzer/build_validator.py +18 -12
  122. jarvis/jarvis_code_agent/code_analyzer/context_manager.py +185 -183
  123. jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +2 -1
  124. jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +24 -15
  125. jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +227 -141
  126. jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +321 -247
  127. jarvis/jarvis_code_agent/code_analyzer/language_registry.py +37 -29
  128. jarvis/jarvis_code_agent/code_analyzer/language_support.py +21 -13
  129. jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +15 -9
  130. jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +75 -45
  131. jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +87 -52
  132. jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +84 -51
  133. jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +94 -64
  134. jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +109 -71
  135. jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +97 -63
  136. jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +103 -69
  137. jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +271 -268
  138. jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +76 -64
  139. jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +92 -19
  140. jarvis/jarvis_code_agent/diff_visualizer.py +998 -0
  141. jarvis/jarvis_code_agent/lint.py +223 -524
  142. jarvis/jarvis_code_agent/rule_share_manager.py +158 -0
  143. jarvis/jarvis_code_agent/rules/clean_code.md +144 -0
  144. jarvis/jarvis_code_agent/rules/code_review.md +115 -0
  145. jarvis/jarvis_code_agent/rules/documentation.md +165 -0
  146. jarvis/jarvis_code_agent/rules/generate_rules.md +52 -0
  147. jarvis/jarvis_code_agent/rules/performance.md +158 -0
  148. jarvis/jarvis_code_agent/rules/refactoring.md +139 -0
  149. jarvis/jarvis_code_agent/rules/security.md +160 -0
  150. jarvis/jarvis_code_agent/rules/tdd.md +78 -0
  151. jarvis/jarvis_code_agent/test_rules/cpp_test.md +118 -0
  152. jarvis/jarvis_code_agent/test_rules/go_test.md +98 -0
  153. jarvis/jarvis_code_agent/test_rules/java_test.md +99 -0
  154. jarvis/jarvis_code_agent/test_rules/javascript_test.md +113 -0
  155. jarvis/jarvis_code_agent/test_rules/php_test.md +117 -0
  156. jarvis/jarvis_code_agent/test_rules/python_test.md +91 -0
  157. jarvis/jarvis_code_agent/test_rules/ruby_test.md +102 -0
  158. jarvis/jarvis_code_agent/test_rules/rust_test.md +86 -0
  159. jarvis/jarvis_code_agent/utils.py +36 -26
  160. jarvis/jarvis_code_analysis/checklists/loader.py +21 -21
  161. jarvis/jarvis_code_analysis/code_review.py +64 -33
  162. jarvis/jarvis_data/config_schema.json +285 -192
  163. jarvis/jarvis_git_squash/main.py +8 -6
  164. jarvis/jarvis_git_utils/git_commiter.py +53 -76
  165. jarvis/jarvis_mcp/__init__.py +5 -2
  166. jarvis/jarvis_mcp/sse_mcp_client.py +40 -30
  167. jarvis/jarvis_mcp/stdio_mcp_client.py +27 -19
  168. jarvis/jarvis_mcp/streamable_mcp_client.py +35 -26
  169. jarvis/jarvis_memory_organizer/memory_organizer.py +78 -55
  170. jarvis/jarvis_methodology/main.py +48 -39
  171. jarvis/jarvis_multi_agent/__init__.py +56 -23
  172. jarvis/jarvis_multi_agent/main.py +15 -18
  173. jarvis/jarvis_platform/base.py +179 -111
  174. jarvis/jarvis_platform/human.py +27 -16
  175. jarvis/jarvis_platform/kimi.py +52 -45
  176. jarvis/jarvis_platform/openai.py +101 -40
  177. jarvis/jarvis_platform/registry.py +51 -33
  178. jarvis/jarvis_platform/tongyi.py +68 -38
  179. jarvis/jarvis_platform/yuanbao.py +59 -43
  180. jarvis/jarvis_platform_manager/main.py +68 -76
  181. jarvis/jarvis_platform_manager/service.py +24 -14
  182. jarvis/jarvis_rag/README_CONFIG.md +314 -0
  183. jarvis/jarvis_rag/README_DYNAMIC_LOADING.md +311 -0
  184. jarvis/jarvis_rag/README_ONLINE_MODELS.md +230 -0
  185. jarvis/jarvis_rag/__init__.py +57 -4
  186. jarvis/jarvis_rag/cache.py +3 -1
  187. jarvis/jarvis_rag/cli.py +48 -68
  188. jarvis/jarvis_rag/embedding_interface.py +39 -0
  189. jarvis/jarvis_rag/embedding_manager.py +7 -230
  190. jarvis/jarvis_rag/embeddings/__init__.py +41 -0
  191. jarvis/jarvis_rag/embeddings/base.py +114 -0
  192. jarvis/jarvis_rag/embeddings/cohere.py +66 -0
  193. jarvis/jarvis_rag/embeddings/edgefn.py +117 -0
  194. jarvis/jarvis_rag/embeddings/local.py +260 -0
  195. jarvis/jarvis_rag/embeddings/openai.py +62 -0
  196. jarvis/jarvis_rag/embeddings/registry.py +293 -0
  197. jarvis/jarvis_rag/llm_interface.py +8 -6
  198. jarvis/jarvis_rag/query_rewriter.py +8 -9
  199. jarvis/jarvis_rag/rag_pipeline.py +61 -52
  200. jarvis/jarvis_rag/reranker.py +7 -75
  201. jarvis/jarvis_rag/reranker_interface.py +32 -0
  202. jarvis/jarvis_rag/rerankers/__init__.py +41 -0
  203. jarvis/jarvis_rag/rerankers/base.py +109 -0
  204. jarvis/jarvis_rag/rerankers/cohere.py +67 -0
  205. jarvis/jarvis_rag/rerankers/edgefn.py +140 -0
  206. jarvis/jarvis_rag/rerankers/jina.py +79 -0
  207. jarvis/jarvis_rag/rerankers/local.py +89 -0
  208. jarvis/jarvis_rag/rerankers/registry.py +293 -0
  209. jarvis/jarvis_rag/retriever.py +58 -43
  210. jarvis/jarvis_sec/__init__.py +66 -141
  211. jarvis/jarvis_sec/agents.py +21 -17
  212. jarvis/jarvis_sec/analysis.py +80 -33
  213. jarvis/jarvis_sec/checkers/__init__.py +7 -13
  214. jarvis/jarvis_sec/checkers/c_checker.py +356 -164
  215. jarvis/jarvis_sec/checkers/rust_checker.py +47 -29
  216. jarvis/jarvis_sec/cli.py +43 -21
  217. jarvis/jarvis_sec/clustering.py +430 -272
  218. jarvis/jarvis_sec/file_manager.py +99 -55
  219. jarvis/jarvis_sec/parsers.py +9 -6
  220. jarvis/jarvis_sec/prompts.py +4 -3
  221. jarvis/jarvis_sec/report.py +44 -22
  222. jarvis/jarvis_sec/review.py +180 -107
  223. jarvis/jarvis_sec/status.py +50 -41
  224. jarvis/jarvis_sec/types.py +3 -0
  225. jarvis/jarvis_sec/utils.py +160 -83
  226. jarvis/jarvis_sec/verification.py +411 -181
  227. jarvis/jarvis_sec/workflow.py +132 -21
  228. jarvis/jarvis_smart_shell/main.py +28 -41
  229. jarvis/jarvis_stats/cli.py +14 -12
  230. jarvis/jarvis_stats/stats.py +28 -19
  231. jarvis/jarvis_stats/storage.py +14 -8
  232. jarvis/jarvis_stats/visualizer.py +12 -7
  233. jarvis/jarvis_tools/base.py +5 -2
  234. jarvis/jarvis_tools/clear_memory.py +13 -9
  235. jarvis/jarvis_tools/cli/main.py +23 -18
  236. jarvis/jarvis_tools/edit_file.py +572 -873
  237. jarvis/jarvis_tools/execute_script.py +10 -7
  238. jarvis/jarvis_tools/file_analyzer.py +7 -8
  239. jarvis/jarvis_tools/meta_agent.py +287 -0
  240. jarvis/jarvis_tools/methodology.py +5 -3
  241. jarvis/jarvis_tools/read_code.py +305 -1438
  242. jarvis/jarvis_tools/read_symbols.py +50 -17
  243. jarvis/jarvis_tools/read_webpage.py +19 -18
  244. jarvis/jarvis_tools/registry.py +435 -156
  245. jarvis/jarvis_tools/retrieve_memory.py +16 -11
  246. jarvis/jarvis_tools/save_memory.py +8 -6
  247. jarvis/jarvis_tools/search_web.py +31 -31
  248. jarvis/jarvis_tools/sub_agent.py +32 -28
  249. jarvis/jarvis_tools/sub_code_agent.py +44 -60
  250. jarvis/jarvis_tools/task_list_manager.py +1811 -0
  251. jarvis/jarvis_tools/virtual_tty.py +29 -19
  252. jarvis/jarvis_utils/__init__.py +4 -0
  253. jarvis/jarvis_utils/builtin_replace_map.py +2 -1
  254. jarvis/jarvis_utils/clipboard.py +9 -8
  255. jarvis/jarvis_utils/collections.py +331 -0
  256. jarvis/jarvis_utils/config.py +699 -194
  257. jarvis/jarvis_utils/dialogue_recorder.py +294 -0
  258. jarvis/jarvis_utils/embedding.py +6 -3
  259. jarvis/jarvis_utils/file_processors.py +7 -1
  260. jarvis/jarvis_utils/fzf.py +9 -3
  261. jarvis/jarvis_utils/git_utils.py +71 -42
  262. jarvis/jarvis_utils/globals.py +116 -32
  263. jarvis/jarvis_utils/http.py +6 -2
  264. jarvis/jarvis_utils/input.py +318 -83
  265. jarvis/jarvis_utils/jsonnet_compat.py +119 -104
  266. jarvis/jarvis_utils/methodology.py +37 -28
  267. jarvis/jarvis_utils/output.py +201 -44
  268. jarvis/jarvis_utils/utils.py +986 -628
  269. {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/METADATA +49 -33
  270. jarvis_ai_assistant-1.0.2.dist-info/RECORD +304 -0
  271. jarvis/jarvis_code_agent/code_analyzer/structured_code.py +0 -556
  272. jarvis/jarvis_tools/generate_new_tool.py +0 -205
  273. jarvis/jarvis_tools/lsp_client.py +0 -1552
  274. jarvis/jarvis_tools/rewrite_file.py +0 -105
  275. jarvis_ai_assistant-0.7.16.dist-info/RECORD +0 -218
  276. {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/WHEEL +0 -0
  277. {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/entry_points.txt +0 -0
  278. {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/licenses/LICENSE +0 -0
  279. {jarvis_ai_assistant-0.7.16.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/top_level.txt +0 -0
@@ -1,23 +1,29 @@
1
- # -*- coding: utf-8 -*-
2
1
  """Jarvis平台管理器主模块。
3
2
 
4
3
  该模块提供了Jarvis平台管理器的主要入口点。
5
4
  """
5
+
6
6
  import os
7
7
  import sys
8
- from typing import Any, Dict, List, Optional
8
+
9
+ from jarvis.jarvis_utils.output import PrettyOutput
10
+
11
+ # -*- coding: utf-8 -*-
12
+ from typing import Any
13
+ from typing import Dict
14
+ from typing import List
15
+ from typing import Optional
9
16
 
10
17
  import typer
11
- from jarvis.jarvis_utils.config import (
12
- get_normal_platform_name,
13
- get_normal_model_name,
14
- )
15
18
 
16
19
  from jarvis.jarvis_platform.registry import PlatformRegistry
17
- from jarvis.jarvis_utils.input import get_multiline_input, get_single_line_input
18
- from jarvis.jarvis_utils.utils import init_env
19
20
  from jarvis.jarvis_platform_manager.service import start_service
21
+ from jarvis.jarvis_utils.config import get_normal_model_name
22
+ from jarvis.jarvis_utils.config import get_normal_platform_name
20
23
  from jarvis.jarvis_utils.fzf import fzf_select
24
+ from jarvis.jarvis_utils.input import get_multiline_input
25
+ from jarvis.jarvis_utils.input import get_single_line_input
26
+ from jarvis.jarvis_utils.utils import init_env
21
27
 
22
28
  app = typer.Typer(help="Jarvis AI 平台")
23
29
 
@@ -26,13 +32,13 @@ app = typer.Typer(help="Jarvis AI 平台")
26
32
  def list_platforms(
27
33
  platform: Optional[str] = typer.Option(
28
34
  None, "--platform", "-p", help="指定要查看的平台"
29
- )
35
+ ),
30
36
  ) -> None:
31
37
  """列出所有支持的平台和模型,或指定平台的详细信息。"""
32
38
  registry = PlatformRegistry.get_global_platform_registry()
33
39
  platform_names = [platform] if platform else registry.get_available_platforms()
34
40
 
35
- print("✅ Supported platforms and models")
41
+ PrettyOutput.auto_print("✅ Supported platforms and models")
36
42
 
37
43
  for platform_name in platform_names:
38
44
  try:
@@ -45,7 +51,7 @@ def list_platforms(
45
51
  models = platform_instance.get_model_list()
46
52
 
47
53
  # Print platform name
48
- print(f"✅ {platform_name}")
54
+ PrettyOutput.auto_print(f"✅ {platform_name}")
49
55
 
50
56
  output = ""
51
57
  # Print model list
@@ -55,17 +61,15 @@ def list_platforms(
55
61
  output += f" • {model_name} - {description}\n"
56
62
  else:
57
63
  output += f" • {model_name}\n"
58
- print(f"✅ {output}")
64
+ PrettyOutput.auto_print(f"✅ {output}")
59
65
  else:
60
- print("⚠️ • 没有可用的模型信息")
66
+ PrettyOutput.auto_print("⚠️ • 没有可用的模型信息")
61
67
 
62
68
  except Exception:
63
- print(f"⚠️ 创建 {platform_name} 平台失败")
69
+ PrettyOutput.auto_print(f"⚠️ 创建 {platform_name} 平台失败")
64
70
 
65
71
 
66
- def chat_with_model(
67
- platform_name: str, model_name: str, system_prompt: str
68
- ) -> None:
72
+ def chat_with_model(platform_name: str, model_name: str, system_prompt: str) -> None:
69
73
  """与指定平台和模型进行对话。
70
74
 
71
75
  参数:
@@ -83,7 +87,7 @@ def chat_with_model(
83
87
  platform.set_model_name(model_name)
84
88
 
85
89
  if not platform:
86
- print(f"⚠️ 创建平台 {platform_name} 失败")
90
+ PrettyOutput.auto_print(f"⚠️ 创建平台 {platform_name} 失败")
87
91
  return
88
92
 
89
93
  try:
@@ -92,8 +96,8 @@ def chat_with_model(
92
96
  if system_prompt:
93
97
  platform.set_system_prompt(system_prompt)
94
98
  platform.set_suppress_output(False)
95
- print(f"✅ 连接到 {platform_name} 平台 {model_name} 模型")
96
- print(
99
+ PrettyOutput.auto_print(f"✅ 连接到 {platform_name} 平台 {model_name} 模型")
100
+ PrettyOutput.auto_print(
97
101
  "ℹ️ 可用命令: /bye - 退出, /clear - 清除会话, /upload - 上传文件, "
98
102
  "/shell - 执行命令, /save - 保存对话, /saveall - 保存所有对话, "
99
103
  "/save_session - 保存会话状态, /load_session - 加载会话状态"
@@ -106,12 +110,12 @@ def chat_with_model(
106
110
 
107
111
  # Check if input is cancelled
108
112
  if user_input.strip() == "/bye":
109
- print("✅ 再见!")
113
+ PrettyOutput.auto_print("✅ 再见!")
110
114
  break
111
115
 
112
116
  # Check if input is empty
113
117
  if not user_input.strip():
114
- print("ℹ️ 检测到空输入,退出聊天")
118
+ PrettyOutput.auto_print("ℹ️ 检测到空输入,退出聊天")
115
119
  break
116
120
 
117
121
  # Parse command and arguments
@@ -123,12 +127,12 @@ def chat_with_model(
123
127
  # Check if it is a clear session command
124
128
  if command == "/clear":
125
129
  try:
126
- platform.reset() # type: ignore[no-untyped-call] # type: ignore[no-untyped-call] # type: ignore[no-untyped-call]
130
+ platform.reset()
127
131
  platform.set_model_name(model_name) # Reinitialize session
128
132
  conversation_history = [] # 重置对话记录
129
- print("✅ 会话已清除")
133
+ PrettyOutput.auto_print("✅ 会话已清除")
130
134
  except Exception as exc:
131
- print(f"❌ 清除会话失败: {str(exc)}")
135
+ PrettyOutput.auto_print(f"❌ 清除会话失败: {str(exc)}")
132
136
  continue
133
137
 
134
138
  # Check if it is an upload command
@@ -136,7 +140,7 @@ def chat_with_model(
136
140
  try:
137
141
  file_path = args
138
142
  if not file_path:
139
- print(
143
+ PrettyOutput.auto_print(
140
144
  '⚠️ 请指定要上传的文件路径,例如: /upload /path/to/file 或 /upload "/path/with spaces/file"'
141
145
  )
142
146
  continue
@@ -148,16 +152,16 @@ def chat_with_model(
148
152
  file_path = file_path[1:-1]
149
153
 
150
154
  if not platform.support_upload_files():
151
- print("❌ 平台不支持上传文件")
155
+ PrettyOutput.auto_print("❌ 平台不支持上传文件")
152
156
  continue
153
157
 
154
- print(f"ℹ️ 正在上传文件: {file_path}")
158
+ PrettyOutput.auto_print(f"ℹ️ 正在上传文件: {file_path}")
155
159
  if platform.upload_files([file_path]):
156
- print("✅ 文件上传成功")
160
+ PrettyOutput.auto_print("✅ 文件上传成功")
157
161
  else:
158
- print("❌ 文件上传失败")
162
+ PrettyOutput.auto_print("❌ 文件上传失败")
159
163
  except Exception as exc:
160
- print(f"❌ 上传文件失败: {str(exc)}")
164
+ PrettyOutput.auto_print(f"❌ 上传文件失败: {str(exc)}")
161
165
  continue
162
166
 
163
167
  # Check if it is a save command
@@ -165,7 +169,7 @@ def chat_with_model(
165
169
  try:
166
170
  file_path = args
167
171
  if not file_path:
168
- print(
172
+ PrettyOutput.auto_print(
169
173
  "⚠️ 请指定保存文件名,例如: /save last_message.txt"
170
174
  )
171
175
  continue
@@ -181,13 +185,13 @@ def chat_with_model(
181
185
  with open(file_path, "w", encoding="utf-8") as file_obj:
182
186
  last_entry = conversation_history[-1]
183
187
  file_obj.write(f"{last_entry['content']}\n")
184
- print(
188
+ PrettyOutput.auto_print(
185
189
  f"✅ 最后一条消息内容已保存到 {file_path}"
186
190
  )
187
191
  else:
188
- print("⚠️ 没有可保存的消息")
192
+ PrettyOutput.auto_print("⚠️ 没有可保存的消息")
189
193
  except Exception as exc:
190
- print(f"❌ 保存消息失败: {str(exc)}")
194
+ PrettyOutput.auto_print(f"❌ 保存消息失败: {str(exc)}")
191
195
  continue
192
196
 
193
197
  # Check if it is a saveall command
@@ -195,7 +199,7 @@ def chat_with_model(
195
199
  try:
196
200
  file_path = args
197
201
  if not file_path:
198
- print(
202
+ PrettyOutput.auto_print(
199
203
  "⚠️ 请指定保存文件名,例如: /saveall all_conversations.txt"
200
204
  )
201
205
  continue
@@ -211,13 +215,9 @@ def chat_with_model(
211
215
  for entry in conversation_history:
212
216
  file_obj.write(f"{entry['role']}: {entry['content']}\n\n")
213
217
 
214
- print(
215
- f"✅ 所有对话已保存到 {file_path}"
216
- )
218
+ PrettyOutput.auto_print(f"✅ 所有对话已保存到 {file_path}")
217
219
  except Exception as exc:
218
- print(
219
- f"❌ 保存所有对话失败: {str(exc)}"
220
- )
220
+ PrettyOutput.auto_print(f"❌ 保存所有对话失败: {str(exc)}")
221
221
  continue
222
222
 
223
223
  # Check if it is a save_session command
@@ -225,7 +225,7 @@ def chat_with_model(
225
225
  try:
226
226
  file_path = args
227
227
  if not file_path:
228
- print(
228
+ PrettyOutput.auto_print(
229
229
  "⚠️ 请指定保存会话的文件名,例如: /save_session session.json"
230
230
  )
231
231
  continue
@@ -237,13 +237,11 @@ def chat_with_model(
237
237
  file_path = file_path[1:-1]
238
238
 
239
239
  if platform.save(file_path):
240
- print(
241
- f"✅ 会话已保存到 {file_path}"
242
- )
240
+ PrettyOutput.auto_print(f"✅ 会话已保存到 {file_path}")
243
241
  else:
244
- print("❌ 保存会话失败")
242
+ PrettyOutput.auto_print("❌ 保存会话失败")
245
243
  except Exception as exc:
246
- print(f"❌ 保存会话失败: {str(exc)}")
244
+ PrettyOutput.auto_print(f"❌ 保存会话失败: {str(exc)}")
247
245
  continue
248
246
 
249
247
  # Check if it is a load_session command
@@ -251,7 +249,7 @@ def chat_with_model(
251
249
  try:
252
250
  file_path = args
253
251
  if not file_path:
254
- print(
252
+ PrettyOutput.auto_print(
255
253
  "⚠️ 请指定加载会话的文件名,例如: /load_session session.json"
256
254
  )
257
255
  continue
@@ -264,13 +262,11 @@ def chat_with_model(
264
262
 
265
263
  if platform.restore(file_path):
266
264
  conversation_history = [] # Clear local history after loading
267
- print(
268
- f"✅ 会话已从 {file_path} 加载"
269
- )
265
+ PrettyOutput.auto_print(f"✅ 会话已从 {file_path} 加载")
270
266
  else:
271
- print("❌ 加载会话失败")
267
+ PrettyOutput.auto_print("❌ 加载会话失败")
272
268
  except Exception as exc:
273
- print(f"❌ 加载会话失败: {str(exc)}")
269
+ PrettyOutput.auto_print(f"❌ 加载会话失败: {str(exc)}")
274
270
  continue
275
271
 
276
272
  # Check if it is a shell command
@@ -278,21 +274,21 @@ def chat_with_model(
278
274
  try:
279
275
  shell_command = args
280
276
  if not shell_command:
281
- print(
277
+ PrettyOutput.auto_print(
282
278
  "⚠️ 请指定要执行的shell命令,例如: /shell ls -l"
283
279
  )
284
280
  continue
285
281
 
286
- print(f"ℹ️ 执行命令: {shell_command}")
282
+ PrettyOutput.auto_print(f"ℹ️ 执行命令: {shell_command}")
287
283
  return_code = os.system(shell_command)
288
284
  if return_code == 0:
289
- print("✅ 命令执行完成")
285
+ pass # 命令执行成功,不显示提示
290
286
  else:
291
- print(
287
+ PrettyOutput.auto_print(
292
288
  f"❌ 命令执行失败(返回码: {return_code})"
293
289
  )
294
290
  except Exception as exc:
295
- print(f"❌ 执行命令失败: {str(exc)}")
291
+ PrettyOutput.auto_print(f"❌ 执行命令失败: {str(exc)}")
296
292
  continue
297
293
 
298
294
  try:
@@ -302,19 +298,19 @@ def chat_with_model(
302
298
  # Send to model and get reply
303
299
  response = platform.chat_until_success(user_input)
304
300
  if not response:
305
- print("⚠️ 没有有效的回复")
301
+ PrettyOutput.auto_print("⚠️ 没有有效的回复")
306
302
  else:
307
303
  conversation_history.append(
308
304
  {"role": "assistant", "content": response}
309
305
  ) # 记录模型回复
310
306
 
311
307
  except Exception as exc:
312
- print(f"❌ 聊天失败: {str(exc)}")
308
+ PrettyOutput.auto_print(f"❌ 聊天失败: {str(exc)}")
313
309
 
314
310
  except typer.Exit:
315
311
  raise
316
312
  except Exception as exc:
317
- print(f"❌ 初始化会话失败: {str(exc)}")
313
+ PrettyOutput.auto_print(f"❌ 初始化会话失败: {str(exc)}")
318
314
  sys.exit(1)
319
315
  finally:
320
316
  # Clean up resources
@@ -335,7 +331,7 @@ def validate_platform_model(platform: Optional[str], model: Optional[str]) -> bo
335
331
  bool: 如果平台和模型有效返回True,否则返回False。
336
332
  """
337
333
  if not platform or not model:
338
- print(
334
+ PrettyOutput.auto_print(
339
335
  "⚠️ 请指定平台和模型。使用 'jarvis info' 查看可用平台和模型。"
340
336
  )
341
337
  return False
@@ -348,7 +344,6 @@ def chat_command(
348
344
  None, "--platform", "-p", help="指定要使用的平台"
349
345
  ),
350
346
  model: Optional[str] = typer.Option(None, "--model", "-m", help="指定要使用的模型"),
351
-
352
347
  llm_group: Optional[str] = typer.Option(
353
348
  None, "-g", "--llm-group", help="使用的模型组,覆盖配置文件中的设置"
354
349
  ),
@@ -393,7 +388,7 @@ def load_role_config(config_path: str) -> Dict[str, Any]:
393
388
  import yaml
394
389
 
395
390
  if not os.path.exists(config_path):
396
- print(f"❌ 角色配置文件 {config_path} 不存在")
391
+ PrettyOutput.auto_print(f"❌ 角色配置文件 {config_path} 不存在")
397
392
  return {}
398
393
 
399
394
  with open(config_path, "r", encoding="utf-8", errors="ignore") as file_obj:
@@ -401,7 +396,7 @@ def load_role_config(config_path: str) -> Dict[str, Any]:
401
396
  config = yaml.safe_load(file_obj)
402
397
  return config if config else {}
403
398
  except yaml.YAMLError as exc:
404
- print(f"❌ 角色配置文件解析失败: {str(exc)}")
399
+ PrettyOutput.auto_print(f"❌ 角色配置文件解析失败: {str(exc)}")
405
400
  return {}
406
401
 
407
402
 
@@ -419,7 +414,6 @@ def role_command(
419
414
  model: Optional[str] = typer.Option(
420
415
  None, "--model", "-m", help="指定要使用的模型,覆盖角色配置"
421
416
  ),
422
-
423
417
  llm_group: Optional[str] = typer.Option(
424
418
  None, "-g", "--llm-group", help="使用的模型组,覆盖配置文件中的设置"
425
419
  ),
@@ -428,21 +422,21 @@ def role_command(
428
422
  config_path = os.path.expanduser(config_file)
429
423
  config = load_role_config(config_path)
430
424
  if not config or "roles" not in config:
431
- print("❌ 无效的角色配置文件")
425
+ PrettyOutput.auto_print("❌ 无效的角色配置文件")
432
426
  return
433
427
 
434
428
  # 显示可选角色列表
435
- print("✅ 可用角色")
429
+ PrettyOutput.auto_print("✅ 可用角色")
436
430
  output_str = "\n".join(
437
431
  [
438
432
  f"{i}. {role['name']} - {role.get('description', '')}"
439
433
  for i, role in enumerate(config["roles"], 1)
440
434
  ]
441
435
  )
442
- print(f"ℹ️ {output_str}")
436
+ PrettyOutput.auto_print(f"ℹ️ {output_str}")
443
437
 
444
438
  # 让用户选择角色(优先 fzf,回退编号输入)
445
- selected_role = None # type: ignore[var-annotated]
439
+ selected_role = None
446
440
  fzf_options = [
447
441
  f"{i:>3} | {role['name']} - {role.get('description', '')}"
448
442
  for i, role in enumerate(config["roles"], 1)
@@ -460,17 +454,15 @@ def role_command(
460
454
  if selected_role is None:
461
455
  raw_choice = get_single_line_input("请选择角色(输入编号,直接回车退出): ")
462
456
  if not raw_choice.strip():
463
- print("ℹ️ 已取消,退出程序")
457
+ PrettyOutput.auto_print("ℹ️ 已取消,退出程序")
464
458
  raise typer.Exit(code=0)
465
459
  try:
466
460
  choice = int(raw_choice)
467
461
  selected_role = config["roles"][choice - 1]
468
462
  except (ValueError, IndexError):
469
- print("❌ 无效的选择")
463
+ PrettyOutput.auto_print("❌ 无效的选择")
470
464
  return
471
465
 
472
-
473
-
474
466
  # 初始化平台和模型
475
467
  # 如果提供了platform或model参数,优先使用命令行参数
476
468
  # 否则,如果提供了 llm_group,则从配置中获取
@@ -498,7 +490,7 @@ def role_command(
498
490
  system_prompt = selected_role.get("system_prompt", "")
499
491
 
500
492
  # 开始对话
501
- print(f"✅ 已选择角色: {selected_role['name']}")
493
+ PrettyOutput.auto_print(f"✅ 已选择角色: {selected_role['name']}")
502
494
  chat_with_model(platform_name, model_name, system_prompt)
503
495
 
504
496
 
@@ -1,23 +1,33 @@
1
- # -*- coding: utf-8 -*-
2
1
  """Jarvis Platform Manager Service Module.
3
2
 
4
3
  This module provides an OpenAI-compatible API service for the Jarvis platform.
5
4
  """
5
+
6
6
  import asyncio
7
7
  import json
8
+
9
+ from jarvis.jarvis_utils.output import PrettyOutput
10
+
11
+ # -*- coding: utf-8 -*-
8
12
  import os
9
- import time
10
13
  import threading
14
+ import time
11
15
  import uuid
12
16
  from datetime import datetime
13
- from typing import Any, Dict, List, Optional
17
+ from typing import Any
18
+ from typing import Dict
19
+ from typing import List
20
+ from typing import Optional
14
21
 
15
22
  import uvicorn
16
- from fastapi import FastAPI, HTTPException
23
+ from fastapi import FastAPI
24
+ from fastapi import HTTPException
17
25
  from fastapi.middleware.cors import CORSMiddleware
18
26
  from fastapi.responses import StreamingResponse
19
- from pydantic import BaseModel, Field
20
- from starlette.responses import JSONResponse, Response
27
+ from pydantic import BaseModel
28
+ from pydantic import Field
29
+ from starlette.responses import JSONResponse
30
+ from starlette.responses import Response
21
31
 
22
32
  from jarvis.jarvis_platform.registry import PlatformRegistry
23
33
 
@@ -73,7 +83,7 @@ def start_service(
73
83
  """Start OpenAI-compatible API server."""
74
84
  # Create logs directory if it doesn't exist
75
85
  # Prefer environment variable, then user directory, fall back to CWD
76
- logs_dir = os.environ.get("JARVIS_LOG_DIR")
86
+ logs_dir = os.environ.get("log_dir")
77
87
  if not logs_dir:
78
88
  logs_dir = os.path.join(os.path.expanduser("~"), ".jarvis", "logs")
79
89
  try:
@@ -96,11 +106,11 @@ def start_service(
96
106
 
97
107
  registry = PlatformRegistry.get_global_platform_registry()
98
108
 
99
- print(f"✅ Starting Jarvis API server on {host}:{port}")
100
- print("ℹ️ 本服务提供与 OpenAI 兼容的 API")
109
+ PrettyOutput.auto_print(f"✅ Starting Jarvis API server on {host}:{port}")
110
+ PrettyOutput.auto_print("ℹ️ 本服务提供与 OpenAI 兼容的 API")
101
111
 
102
112
  if default_platform and default_model:
103
- print(
113
+ PrettyOutput.auto_print(
104
114
  f"ℹ️ Default platform: {default_platform}, model: {default_model}"
105
115
  )
106
116
 
@@ -147,7 +157,7 @@ def start_service(
147
157
  if response:
148
158
  f.write(f"\nResponse:\n{response}\n")
149
159
 
150
- print(f"ℹ️ 会话已记录到 {log_file}")
160
+ PrettyOutput.auto_print(f"ℹ️ 会话已记录到 {log_file}")
151
161
 
152
162
  @app.get("/v1/models")
153
163
  async def list_models() -> Dict[str, Any]:
@@ -172,7 +182,7 @@ def start_service(
172
182
  }
173
183
  )
174
184
  except Exception as exc:
175
- print(
185
+ PrettyOutput.auto_print(
176
186
  f"❌ Error getting models for {default_platform}: {str(exc)}"
177
187
  )
178
188
 
@@ -238,7 +248,7 @@ def start_service(
238
248
  if stream:
239
249
  # Return streaming response
240
250
  return StreamingResponse(
241
- stream_chat_response(platform, message_text, model), # type: ignore
251
+ stream_chat_response(platform, message_text, model),
242
252
  media_type="text/event-stream",
243
253
  headers={"Cache-Control": "no-cache", "Connection": "keep-alive"},
244
254
  )
@@ -339,7 +349,7 @@ def start_service(
339
349
 
340
350
  if isinstance(item, dict) and "__error__" in item:
341
351
  error_msg = f"Error during streaming: {item['__error__']}"
342
- print(f"❌ {error_msg}")
352
+ PrettyOutput.auto_print(f"❌ {error_msg}")
343
353
 
344
354
  # Send error information in the stream
345
355
  error_chunk = {