jarvis-ai-assistant 0.3.30__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +289 -87
  3. jarvis/jarvis_agent/agent_manager.py +17 -8
  4. jarvis/jarvis_agent/edit_file_handler.py +374 -86
  5. jarvis/jarvis_agent/event_bus.py +1 -1
  6. jarvis/jarvis_agent/file_context_handler.py +79 -0
  7. jarvis/jarvis_agent/jarvis.py +601 -43
  8. jarvis/jarvis_agent/main.py +32 -2
  9. jarvis/jarvis_agent/rewrite_file_handler.py +141 -0
  10. jarvis/jarvis_agent/run_loop.py +38 -5
  11. jarvis/jarvis_agent/share_manager.py +8 -1
  12. jarvis/jarvis_agent/stdio_redirect.py +295 -0
  13. jarvis/jarvis_agent/task_analyzer.py +5 -2
  14. jarvis/jarvis_agent/task_planner.py +496 -0
  15. jarvis/jarvis_agent/utils.py +5 -1
  16. jarvis/jarvis_agent/web_bridge.py +189 -0
  17. jarvis/jarvis_agent/web_output_sink.py +53 -0
  18. jarvis/jarvis_agent/web_server.py +751 -0
  19. jarvis/jarvis_c2rust/__init__.py +26 -0
  20. jarvis/jarvis_c2rust/cli.py +613 -0
  21. jarvis/jarvis_c2rust/collector.py +258 -0
  22. jarvis/jarvis_c2rust/library_replacer.py +1122 -0
  23. jarvis/jarvis_c2rust/llm_module_agent.py +1300 -0
  24. jarvis/jarvis_c2rust/optimizer.py +960 -0
  25. jarvis/jarvis_c2rust/scanner.py +1681 -0
  26. jarvis/jarvis_c2rust/transpiler.py +2325 -0
  27. jarvis/jarvis_code_agent/build_validation_config.py +133 -0
  28. jarvis/jarvis_code_agent/code_agent.py +1171 -94
  29. jarvis/jarvis_code_agent/code_analyzer/__init__.py +62 -0
  30. jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
  31. jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
  32. jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +102 -0
  33. jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +59 -0
  34. jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
  35. jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +69 -0
  36. jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +38 -0
  37. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +44 -0
  38. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +38 -0
  39. jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +50 -0
  40. jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +93 -0
  41. jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +129 -0
  42. jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +54 -0
  43. jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +154 -0
  44. jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
  45. jarvis/jarvis_code_agent/code_analyzer/context_manager.py +363 -0
  46. jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
  47. jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
  48. jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
  49. jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
  50. jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
  51. jarvis/jarvis_code_agent/code_analyzer/language_support.py +89 -0
  52. jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +31 -0
  53. jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +231 -0
  54. jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +183 -0
  55. jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +219 -0
  56. jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +209 -0
  57. jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +451 -0
  58. jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +77 -0
  59. jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +48 -0
  60. jarvis/jarvis_code_agent/lint.py +270 -8
  61. jarvis/jarvis_code_agent/utils.py +142 -0
  62. jarvis/jarvis_code_analysis/code_review.py +483 -569
  63. jarvis/jarvis_data/config_schema.json +97 -8
  64. jarvis/jarvis_git_utils/git_commiter.py +38 -26
  65. jarvis/jarvis_mcp/sse_mcp_client.py +2 -2
  66. jarvis/jarvis_mcp/stdio_mcp_client.py +1 -1
  67. jarvis/jarvis_memory_organizer/memory_organizer.py +1 -1
  68. jarvis/jarvis_multi_agent/__init__.py +239 -25
  69. jarvis/jarvis_multi_agent/main.py +37 -1
  70. jarvis/jarvis_platform/base.py +103 -51
  71. jarvis/jarvis_platform/openai.py +26 -1
  72. jarvis/jarvis_platform/yuanbao.py +1 -1
  73. jarvis/jarvis_platform_manager/service.py +2 -2
  74. jarvis/jarvis_rag/cli.py +4 -4
  75. jarvis/jarvis_sec/__init__.py +3605 -0
  76. jarvis/jarvis_sec/checkers/__init__.py +32 -0
  77. jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
  78. jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
  79. jarvis/jarvis_sec/cli.py +116 -0
  80. jarvis/jarvis_sec/report.py +257 -0
  81. jarvis/jarvis_sec/status.py +264 -0
  82. jarvis/jarvis_sec/types.py +20 -0
  83. jarvis/jarvis_sec/workflow.py +219 -0
  84. jarvis/jarvis_stats/cli.py +1 -1
  85. jarvis/jarvis_stats/stats.py +1 -1
  86. jarvis/jarvis_stats/visualizer.py +1 -1
  87. jarvis/jarvis_tools/cli/main.py +1 -0
  88. jarvis/jarvis_tools/execute_script.py +46 -9
  89. jarvis/jarvis_tools/generate_new_tool.py +3 -1
  90. jarvis/jarvis_tools/read_code.py +275 -12
  91. jarvis/jarvis_tools/read_symbols.py +141 -0
  92. jarvis/jarvis_tools/read_webpage.py +5 -3
  93. jarvis/jarvis_tools/registry.py +73 -35
  94. jarvis/jarvis_tools/search_web.py +15 -11
  95. jarvis/jarvis_tools/sub_agent.py +24 -42
  96. jarvis/jarvis_tools/sub_code_agent.py +14 -13
  97. jarvis/jarvis_tools/virtual_tty.py +1 -1
  98. jarvis/jarvis_utils/config.py +187 -35
  99. jarvis/jarvis_utils/embedding.py +3 -0
  100. jarvis/jarvis_utils/git_utils.py +181 -6
  101. jarvis/jarvis_utils/globals.py +3 -3
  102. jarvis/jarvis_utils/http.py +1 -1
  103. jarvis/jarvis_utils/input.py +78 -2
  104. jarvis/jarvis_utils/methodology.py +25 -19
  105. jarvis/jarvis_utils/utils.py +644 -359
  106. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/METADATA +85 -1
  107. jarvis_ai_assistant-0.7.0.dist-info/RECORD +192 -0
  108. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/entry_points.txt +4 -0
  109. jarvis/jarvis_agent/config.py +0 -92
  110. jarvis/jarvis_tools/edit_file.py +0 -179
  111. jarvis/jarvis_tools/rewrite_file.py +0 -191
  112. jarvis_ai_assistant-0.3.30.dist-info/RECORD +0 -137
  113. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/WHEEL +0 -0
  114. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/licenses/LICENSE +0 -0
  115. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/top_level.txt +0 -0
@@ -363,9 +363,51 @@ class FileCompleter(Completer):
363
363
  return tag
364
364
 
365
365
 
366
+ # ---------------------
367
+ # 公共判定辅助函数(按当前Agent优先)
368
+ # ---------------------
369
+ def _get_current_agent_for_input():
370
+ try:
371
+ import jarvis.jarvis_utils.globals as g
372
+ current_name = getattr(g, "current_agent_name", "")
373
+ if current_name:
374
+ return g.get_agent(current_name)
375
+ except Exception:
376
+ pass
377
+ return None
378
+
379
+ def _is_non_interactive_for_current_agent() -> bool:
380
+ try:
381
+ from jarvis.jarvis_utils.config import is_non_interactive
382
+ ag = _get_current_agent_for_input()
383
+ try:
384
+ return bool(getattr(ag, "non_interactive", False)) if ag else bool(is_non_interactive())
385
+ except Exception:
386
+ return bool(is_non_interactive())
387
+ except Exception:
388
+ return False
389
+
390
+ def _is_auto_complete_for_current_agent() -> bool:
391
+ try:
392
+ from jarvis.jarvis_utils.config import GLOBAL_CONFIG_DATA
393
+ ag = _get_current_agent_for_input()
394
+ if ag is not None and hasattr(ag, "auto_complete"):
395
+ try:
396
+ return bool(getattr(ag, "auto_complete", False))
397
+ except Exception:
398
+ pass
399
+ env_v = os.getenv("JARVIS_AUTO_COMPLETE")
400
+ if env_v is not None:
401
+ return str(env_v).strip().lower() in ("1", "true", "yes", "on")
402
+ return bool(GLOBAL_CONFIG_DATA.get("JARVIS_AUTO_COMPLETE", False))
403
+ except Exception:
404
+ return False
405
+
366
406
  def user_confirm(tip: str, default: bool = True) -> bool:
367
- """提示用户确认是/否问题"""
407
+ """提示用户确认是/否问题(按当前Agent优先判断非交互)"""
368
408
  try:
409
+ if _is_non_interactive_for_current_agent():
410
+ return default
369
411
  suffix = "[Y/n]" if default else "[y/N]"
370
412
  ret = get_single_line_input(f"{tip} {suffix}: ")
371
413
  return default if ret == "" else ret.lower() == "y"
@@ -482,7 +524,7 @@ def _get_multiline_input_internal(
482
524
  """Handle Ctrl+O by exiting the prompt and returning the sentinel value."""
483
525
  event.app.exit(result=CTRL_O_SENTINEL)
484
526
 
485
- @bindings.add("c-t", filter=has_focus(DEFAULT_BUFFER))
527
+ @bindings.add("c-t", filter=has_focus(DEFAULT_BUFFER), eager=True)
486
528
  def _(event):
487
529
  """Return a shell command like '!bash' for upper input_handler to execute."""
488
530
 
@@ -663,6 +705,40 @@ def get_multiline_input(tip: str, print_on_empty: bool = True) -> str:
663
705
  preset: Optional[str] = None
664
706
  preset_cursor: Optional[int] = None
665
707
  while True:
708
+ # 基于“当前Agent”精确判断非交互与自动完成,避免多Agent相互干扰
709
+ if _is_non_interactive_for_current_agent():
710
+ # 在多Agent系统中,无论是否启用自动完成,均提示可用智能体并建议使用 SEND_MESSAGE 转移控制权
711
+ hint = ""
712
+ try:
713
+ ag = _get_current_agent_for_input()
714
+ ohs = getattr(ag, "output_handler", [])
715
+ available_agents: List[str] = []
716
+ for oh in (ohs or []):
717
+ cfgs = getattr(oh, "agents_config", None)
718
+ if isinstance(cfgs, list):
719
+ for c in cfgs:
720
+ try:
721
+ name = c.get("name")
722
+ except Exception:
723
+ name = None
724
+ if isinstance(name, str) and name.strip():
725
+ available_agents.append(name.strip())
726
+ if available_agents:
727
+ # 去重但保留顺序
728
+ seen = set()
729
+ ordered = []
730
+ for n in available_agents:
731
+ if n not in seen:
732
+ seen.add(n)
733
+ ordered.append(n)
734
+ hint = "\n当前可用智能体: " + ", ".join(ordered) + f"\n如需将任务交给其他智能体,请使用 {ot('SEND_MESSAGE')} 块。"
735
+ except Exception:
736
+ hint = ""
737
+ if _is_auto_complete_for_current_agent():
738
+ base_msg = "我无法与你交互,所有的事情你都自我决策,如果无法决策,就完成任务。输出" + ot("!!!COMPLETE!!!")
739
+ return base_msg + hint
740
+ else:
741
+ return "我无法与你交互,所有的事情你都自我决策" + hint
666
742
  user_input = _get_multiline_input_internal(
667
743
  tip, preset=preset, preset_cursor=preset_cursor
668
744
  )
@@ -54,25 +54,31 @@ def _load_all_methodologies() -> Dict[str, str]:
54
54
  # 如果配置了中心方法论仓库,将其添加到加载路径
55
55
  central_repo = get_central_methodology_repo()
56
56
  if central_repo:
57
- # 中心方法论仓库存储在数据目录下的特定位置
58
- central_repo_path = os.path.join(get_data_dir(), "central_methodology_repo")
59
- methodology_dirs.append(central_repo_path)
60
-
61
- # 确保中心方法论仓库被克隆/更新
62
- if not os.path.exists(central_repo_path):
63
- try:
64
- import subprocess
65
-
66
- PrettyOutput.print(
67
- f"正在克隆中心方法论仓库: {central_repo}", OutputType.INFO
68
- )
69
- subprocess.run(
70
- ["git", "clone", central_repo, central_repo_path], check=True
71
- )
72
- except Exception as e:
73
- PrettyOutput.print(
74
- f"克隆中心方法论仓库失败: {str(e)}", OutputType.ERROR
75
- )
57
+ # 支持本地目录路径或Git仓库URL
58
+ expanded = os.path.expanduser(os.path.expandvars(central_repo))
59
+ if os.path.isdir(expanded):
60
+ # 直接使用本地目录(支持Git仓库的子目录)
61
+ methodology_dirs.append(expanded)
62
+ else:
63
+ # 中心方法论仓库存储在数据目录下的特定位置
64
+ central_repo_path = os.path.join(get_data_dir(), "central_methodology_repo")
65
+ methodology_dirs.append(central_repo_path)
66
+
67
+ # 确保中心方法论仓库被克隆/更新
68
+ if not os.path.exists(central_repo_path):
69
+ try:
70
+ import subprocess
71
+
72
+ PrettyOutput.print(
73
+ f"正在克隆中心方法论仓库: {central_repo}", OutputType.INFO
74
+ )
75
+ subprocess.run(
76
+ ["git", "clone", central_repo, central_repo_path], check=True
77
+ )
78
+ except Exception as e:
79
+ PrettyOutput.print(
80
+ f"克隆中心方法论仓库失败: {str(e)}", OutputType.ERROR
81
+ )
76
82
 
77
83
  # --- 全局每日更新检查 ---
78
84
  daily_check_git_updates(methodology_dirs, "methodologies")