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,20 +1,20 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """任务管理模块,负责加载和选择预定义任务"""
3
+
3
4
  import os
4
5
  from typing import Dict
5
6
 
6
- import yaml # type: ignore
7
+ import yaml
7
8
  from prompt_toolkit import prompt
8
- from rich.table import Table
9
9
  from rich.console import Console
10
+ from rich.table import Table
10
11
 
11
- from jarvis.jarvis_agent import (
12
- get_multiline_input,
13
- user_confirm,
14
- )
12
+ from jarvis.jarvis_agent import get_multiline_input
13
+ from jarvis.jarvis_agent import user_confirm
15
14
  from jarvis.jarvis_agent.utils import join_prompts
16
15
  from jarvis.jarvis_utils.config import get_data_dir
17
16
  from jarvis.jarvis_utils.fzf import fzf_select
17
+ from jarvis.jarvis_utils.output import PrettyOutput
18
18
 
19
19
 
20
20
  class TaskManager:
@@ -29,7 +29,7 @@ class TaskManager:
29
29
  data_dir = get_data_dir()
30
30
  pre_command_path = os.path.join(data_dir, "pre-command")
31
31
  if os.path.exists(pre_command_path):
32
- print(f"ℹ️ 从{pre_command_path}加载预定义任务...")
32
+ PrettyOutput.auto_print(f"ℹ️ 从{pre_command_path}加载预定义任务...")
33
33
  try:
34
34
  with open(
35
35
  pre_command_path, "r", encoding="utf-8", errors="ignore"
@@ -39,15 +39,15 @@ class TaskManager:
39
39
  for name, desc in user_tasks.items():
40
40
  if desc:
41
41
  tasks[str(name)] = str(desc)
42
- print(f"✅ 预定义任务加载完成 {pre_command_path}")
42
+ PrettyOutput.auto_print(f"✅ 预定义任务加载完成 {pre_command_path}")
43
43
  except (yaml.YAMLError, OSError):
44
- print(f"❌ 预定义任务加载失败 {pre_command_path}")
44
+ PrettyOutput.auto_print(f"❌ 预定义任务加载失败 {pre_command_path}")
45
45
 
46
46
  # Check .jarvis/pre-command in current directory
47
47
  pre_command_path = ".jarvis/pre-command"
48
48
  if os.path.exists(pre_command_path):
49
49
  abs_path = os.path.abspath(pre_command_path)
50
- print(f"ℹ️ 从{abs_path}加载预定义任务...")
50
+ PrettyOutput.auto_print(f"ℹ️ 从{abs_path}加载预定义任务...")
51
51
  try:
52
52
  with open(
53
53
  pre_command_path, "r", encoding="utf-8", errors="ignore"
@@ -57,9 +57,9 @@ class TaskManager:
57
57
  for name, desc in local_tasks.items():
58
58
  if desc:
59
59
  tasks[str(name)] = str(desc)
60
- print(f"✅ 预定义任务加载完成 {pre_command_path}")
60
+ PrettyOutput.auto_print(f"✅ 预定义任务加载完成 {pre_command_path}")
61
61
  except (yaml.YAMLError, OSError):
62
- print(f"❌ 预定义任务加载失败 {pre_command_path}")
62
+ PrettyOutput.auto_print(f"❌ 预定义任务加载失败 {pre_command_path}")
63
63
 
64
64
  return tasks
65
65
 
@@ -77,7 +77,7 @@ class TaskManager:
77
77
  for i, name in enumerate(task_names, 1):
78
78
  table.add_row(str(i), name)
79
79
  Console().print(table)
80
- print("ℹ️ [0] 跳过预定义任务")
80
+ PrettyOutput.auto_print("ℹ️ [0] 跳过预定义任务")
81
81
 
82
82
  # Try fzf selection first (with numbered options and a skip option)
83
83
  fzf_list = [f"{0:>3} | 跳过预定义任务"] + [
@@ -92,13 +92,17 @@ class TaskManager:
92
92
  return ""
93
93
  if 1 <= idx <= len(task_names):
94
94
  selected_task = tasks[task_names[idx - 1]]
95
- print(f"ℹ️ 将要执行任务:\n {selected_task}")
95
+ PrettyOutput.auto_print(f"ℹ️ 将要执行任务:\n {selected_task}")
96
96
  # 询问是否需要补充信息
97
- need_additional = user_confirm("需要为此任务添加补充信息吗?", default=False)
97
+ need_additional = user_confirm(
98
+ "需要为此任务添加补充信息吗?", default=False
99
+ )
98
100
  if need_additional:
99
101
  additional_input = get_multiline_input("请输入补充信息:")
100
102
  if additional_input:
101
- selected_task = join_prompts([selected_task, f"补充信息:\n{additional_input}"])
103
+ selected_task = join_prompts(
104
+ [selected_task, f"补充信息:\n{additional_input}"]
105
+ )
102
106
  return selected_task
103
107
  except Exception:
104
108
  # 如果解析失败,则回退到手动输入
@@ -117,7 +121,7 @@ class TaskManager:
117
121
  return ""
118
122
  if 1 <= choice <= len(task_names):
119
123
  selected_task = tasks[task_names[choice - 1]]
120
- print(f"ℹ️ 将要执行任务:\n {selected_task}")
124
+ PrettyOutput.auto_print(f"ℹ️ 将要执行任务:\n {selected_task}")
121
125
  # 询问是否需要补充信息
122
126
  need_additional = user_confirm(
123
127
  "需要为此任务添加补充信息吗?", default=False
@@ -125,14 +129,13 @@ class TaskManager:
125
129
  if need_additional:
126
130
  additional_input = get_multiline_input("请输入补充信息:")
127
131
  if additional_input:
128
- selected_task = join_prompts([
129
- selected_task,
130
- f"补充信息:\n{additional_input}"
131
- ])
132
+ selected_task = join_prompts(
133
+ [selected_task, f"补充信息:\n{additional_input}"]
134
+ )
132
135
  return selected_task
133
- print("⚠️ 无效的选择。请选择列表中的一个号码。")
136
+ PrettyOutput.auto_print("⚠️ 无效的选择。请选择列表中的一个号码。")
134
137
 
135
138
  except (KeyboardInterrupt, EOFError):
136
139
  return ""
137
140
  except ValueError as val_err:
138
- print(f"❌ 选择任务失败: {str(val_err)}")
141
+ PrettyOutput.auto_print(f"❌ 选择任务失败: {str(val_err)}")
@@ -1,7 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
- from typing import Any, Tuple, TYPE_CHECKING
2
+ from typing import TYPE_CHECKING
3
+ from typing import Any
4
+ from typing import Tuple
3
5
 
4
6
  from jarvis.jarvis_utils.input import user_confirm
7
+ from jarvis.jarvis_utils.output import PrettyOutput
5
8
 
6
9
  if TYPE_CHECKING:
7
10
  from jarvis.jarvis_agent import Agent
@@ -30,7 +33,7 @@ def execute_tool_call(response: str, agent: "Agent") -> Tuple[bool, Any]:
30
33
  f"操作失败:检测到多个操作。一次只能执行一个操作。"
31
34
  f"尝试执行的操作:{', '.join([handler.name() for handler in tool_list])}"
32
35
  )
33
- print(f"⚠️ {error_message}")
36
+ PrettyOutput.auto_print(f"⚠️ {error_message}")
34
37
  return False, error_message
35
38
 
36
39
  if not tool_list:
@@ -41,12 +44,10 @@ def execute_tool_call(response: str, agent: "Agent") -> Tuple[bool, Any]:
41
44
  f"需要执行{tool_to_execute.name()}确认执行?", True
42
45
  ):
43
46
  try:
44
- print(f"🔧 正在执行{tool_to_execute.name()}...")
45
47
  result = tool_to_execute.handle(response, agent)
46
- print(f"✅ {tool_to_execute.name()}执行完成")
47
48
  return result
48
49
  except Exception as e:
49
- print(f"❌ 工具执行失败: {str(e)}")
50
+ PrettyOutput.auto_print(f"❌ 工具执行失败: {str(e)}")
50
51
  return False, str(e)
51
52
 
52
53
  return False, ""
@@ -1,15 +1,21 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """工具分享管理模块"""
3
- import os
3
+
4
4
  import glob
5
+ import os
5
6
  import shutil
6
- from typing import List, Dict, Any, Set
7
+ from typing import Any
8
+ from typing import Dict
9
+ from typing import List
10
+ from typing import Set
7
11
 
8
12
  import typer
9
13
 
10
14
  from jarvis.jarvis_agent import user_confirm
11
15
  from jarvis.jarvis_agent.share_manager import ShareManager
12
- from jarvis.jarvis_utils.config import get_central_tool_repo, get_data_dir
16
+ from jarvis.jarvis_utils.config import get_central_tool_repo
17
+ from jarvis.jarvis_utils.config import get_data_dir
18
+ from jarvis.jarvis_utils.output import PrettyOutput
13
19
 
14
20
 
15
21
  class ToolShareManager(ShareManager):
@@ -18,8 +24,8 @@ class ToolShareManager(ShareManager):
18
24
  def __init__(self):
19
25
  central_repo = get_central_tool_repo()
20
26
  if not central_repo:
21
- print("❌ 错误:未配置中心工具仓库(JARVIS_CENTRAL_TOOL_REPO)")
22
- print("ℹ️ 请在配置文件中设置中心工具仓库的Git地址")
27
+ PrettyOutput.auto_print("❌ 错误:未配置中心工具仓库(central_tool_repo)")
28
+ PrettyOutput.auto_print("ℹ️ 请在配置文件中设置中心工具仓库的Git地址")
23
29
  raise typer.Exit(code=1)
24
30
 
25
31
  super().__init__(central_repo, "central_tool_repo")
@@ -47,7 +53,7 @@ class ToolShareManager(ShareManager):
47
53
  # 只从数据目录的tools目录获取工具
48
54
  local_tools_dir = os.path.join(get_data_dir(), "tools")
49
55
  if not os.path.exists(local_tools_dir):
50
- print(f"⚠️ 本地工具目录不存在: {local_tools_dir}")
56
+ PrettyOutput.auto_print(f"⚠️ 本地工具目录不存在: {local_tools_dir}")
51
57
  return []
52
58
 
53
59
  # 收集本地工具文件(排除已存在的)
@@ -76,8 +82,8 @@ class ToolShareManager(ShareManager):
76
82
  share_list = ["\n将要分享以下工具到中心仓库(注意:文件将被移动而非复制):"]
77
83
  for tool in resources:
78
84
  share_list.append(f"- {tool['tool_name']} ({tool['filename']})")
79
- joined_list = '\n'.join(share_list)
80
- print(f"⚠️ {joined_list}")
85
+ joined_list = "\n".join(share_list)
86
+ PrettyOutput.auto_print(f"⚠️ {joined_list}")
81
87
 
82
88
  if not user_confirm("确认移动这些工具到中心仓库吗?(原文件将被删除)"):
83
89
  return []
@@ -101,7 +107,9 @@ class ToolShareManager(ShareManager):
101
107
  # 获取本地资源
102
108
  local_resources = self.get_local_resources()
103
109
  if not local_resources:
104
- print("⚠️ 没有找到新的工具文件(所有工具可能已存在于中心仓库)")
110
+ PrettyOutput.auto_print(
111
+ "⚠️ 没有找到新的工具文件(所有工具可能已存在于中心仓库)"
112
+ )
105
113
  return
106
114
 
107
115
  # 选择要分享的资源
@@ -113,15 +121,17 @@ class ToolShareManager(ShareManager):
113
121
  moved_list = self.share_resources(selected_resources)
114
122
  if moved_list:
115
123
  # 一次性显示所有移动结果
116
- joined_moved = '\n'.join(moved_list)
117
- print(f"✅ {joined_moved}")
124
+ joined_moved = "\n".join(moved_list)
125
+ PrettyOutput.auto_print(f"✅ {joined_moved}")
118
126
 
119
127
  # 提交并推送
120
128
  self.commit_and_push(len(selected_resources))
121
129
 
122
- print("✅ 工具已成功分享到中心仓库!")
123
- print(f"ℹ️ 原文件已从 {os.path.join(get_data_dir(), 'tools')} 移动到中心仓库")
130
+ PrettyOutput.auto_print("✅ 工具已成功分享到中心仓库!")
131
+ PrettyOutput.auto_print(
132
+ f"ℹ️ 原文件已从 {os.path.join(get_data_dir(), 'tools')} 移动到中心仓库"
133
+ )
124
134
 
125
135
  except Exception as e:
126
- print(f"❌ 分享工具时出错: {str(e)}")
136
+ PrettyOutput.auto_print(f"❌ 分享工具时出错: {str(e)}")
127
137
  raise typer.Exit(code=1)
@@ -6,8 +6,8 @@ UserInteractionHandler: 抽象用户交互(多行输入与确认)逻辑,
6
6
  - 仅提供封装,不直接修改 Agent 的现有调用
7
7
  - 后续步骤在 Agent 中以旁路方式接入,保持向后兼容
8
8
  """
9
- from typing import Callable
10
9
 
10
+ from typing import Callable
11
11
 
12
12
 
13
13
  class UserInteractionHandler:
@@ -31,9 +31,9 @@ class UserInteractionHandler:
31
31
  2) func(tip)
32
32
  """
33
33
  try:
34
- return self._multiline_inputer(tip, print_on_empty=print_on_empty) # type: ignore[call-arg]
34
+ return self._multiline_inputer(tip, print_on_empty=print_on_empty)
35
35
  except TypeError:
36
- return self._multiline_inputer(tip) # type: ignore[misc]
36
+ return self._multiline_inputer(tip)
37
37
 
38
38
  def confirm(self, tip: str, default: bool = True) -> bool:
39
39
  """
@@ -5,10 +5,15 @@
5
5
  - join_prompts: 统一的提示拼接策略(仅拼接非空段落,使用双换行)
6
6
  - is_auto_complete: 统一的自动完成标记检测
7
7
  """
8
- from typing import Iterable, List, Any
8
+
9
9
  from enum import Enum
10
+ from typing import Any
11
+ from typing import Iterable
12
+ from typing import List
13
+
10
14
  from jarvis.jarvis_utils.tag import ot
11
15
 
16
+
12
17
  def join_prompts(parts: Iterable[str]) -> str:
13
18
  """
14
19
  将多个提示片段按统一规则拼接:
@@ -23,6 +28,7 @@ def join_prompts(parts: Iterable[str]) -> str:
23
28
  return ""
24
29
  return "\n\n".join(non_empty)
25
30
 
31
+
26
32
  def is_auto_complete(response: str) -> bool:
27
33
  """
28
34
  检测是否包含自动完成标记。
@@ -34,6 +40,7 @@ def is_auto_complete(response: str) -> bool:
34
40
  # 防御性处理:即使 ot 出现异常,也不阻塞主流程
35
41
  return "!!!COMPLETE!!!" in response
36
42
 
43
+
37
44
  def normalize_next_action(next_action: Any) -> str:
38
45
  """
39
46
  规范化下一步动作为字符串:
@@ -51,4 +58,5 @@ def normalize_next_action(next_action: Any) -> str:
51
58
  except Exception:
52
59
  return ""
53
60
 
61
+
54
62
  __all__ = ["join_prompts", "is_auto_complete", "normalize_next_action"]
@@ -12,12 +12,18 @@ WebBridge: WebSocket 交互桥
12
12
  * {"type":"user_input","request_id":"...","text":"..."}
13
13
  * {"type":"confirm_response","request_id":"...","value": true/false}
14
14
  """
15
+
15
16
  from __future__ import annotations
16
17
 
17
18
  import threading
18
19
  import uuid
19
- from queue import Queue, Empty
20
- from typing import Callable, Dict, Optional, Set, Any
20
+ from queue import Empty
21
+ from queue import Queue
22
+ from typing import Any
23
+ from typing import Callable
24
+ from typing import Dict
25
+ from typing import Optional
26
+ from typing import Set
21
27
 
22
28
  DEFAULT_WAIT_TIMEOUT = None # 阻塞等待直到收到响应(可按需改为秒数)
23
29
 
@@ -80,7 +86,12 @@ class WebBridge:
80
86
  # ---------------------------
81
87
  # 输入/确认 请求-响应 管理
82
88
  # ---------------------------
83
- def request_multiline_input(self, tip: str, print_on_empty: bool = True, timeout: Optional[float] = DEFAULT_WAIT_TIMEOUT) -> str:
89
+ def request_multiline_input(
90
+ self,
91
+ tip: str,
92
+ print_on_empty: bool = True,
93
+ timeout: Optional[float] = DEFAULT_WAIT_TIMEOUT,
94
+ ) -> str:
84
95
  """
85
96
  发起一个多行输入请求并阻塞等待浏览器返回。
86
97
  返回用户输入的文本(可能为空字符串,表示取消)。
@@ -90,13 +101,15 @@ class WebBridge:
90
101
  with self._pending_lock:
91
102
  self._pending_inputs[req_id] = q
92
103
 
93
- self.broadcast({
94
- "type": "input_request",
95
- "mode": "multiline",
96
- "tip": tip,
97
- "print_on_empty": bool(print_on_empty),
98
- "request_id": req_id,
99
- })
104
+ self.broadcast(
105
+ {
106
+ "type": "input_request",
107
+ "mode": "multiline",
108
+ "tip": tip,
109
+ "print_on_empty": bool(print_on_empty),
110
+ "request_id": req_id,
111
+ }
112
+ )
100
113
 
101
114
  try:
102
115
  if timeout is None:
@@ -112,7 +125,12 @@ class WebBridge:
112
125
  # 规范化为字符串
113
126
  return str(result or "")
114
127
 
115
- def request_confirm(self, tip: str, default: bool = True, timeout: Optional[float] = DEFAULT_WAIT_TIMEOUT) -> bool:
128
+ def request_confirm(
129
+ self,
130
+ tip: str,
131
+ default: bool = True,
132
+ timeout: Optional[float] = DEFAULT_WAIT_TIMEOUT,
133
+ ) -> bool:
116
134
  """
117
135
  发起一个确认请求并阻塞等待浏览器返回。
118
136
  返回 True/False,若超时则回退为 default。
@@ -122,12 +140,14 @@ class WebBridge:
122
140
  with self._pending_lock:
123
141
  self._pending_confirms[req_id] = q
124
142
 
125
- self.broadcast({
126
- "type": "confirm_request",
127
- "tip": tip,
128
- "default": bool(default),
129
- "request_id": req_id,
130
- })
143
+ self.broadcast(
144
+ {
145
+ "type": "confirm_request",
146
+ "tip": tip,
147
+ "default": bool(default),
148
+ "request_id": req_id,
149
+ }
150
+ )
131
151
 
132
152
  try:
133
153
  if timeout is None:
@@ -22,12 +22,15 @@ WebSocketOutputSink: 将 PrettyOutput 的输出事件通过 WebBridge 广播给
22
22
  }
23
23
  }
24
24
  """
25
+
25
26
  from __future__ import annotations
26
27
 
27
- from typing import Any, Dict
28
+ from typing import Any
29
+ from typing import Dict
28
30
 
29
- from jarvis.jarvis_utils.output import OutputSink, OutputEvent
30
31
  from jarvis.jarvis_agent.web_bridge import WebBridge
32
+ from jarvis.jarvis_utils.output import OutputEvent
33
+ from jarvis.jarvis_utils.output import OutputSink
31
34
 
32
35
 
33
36
  class WebSocketOutputSink(OutputSink):