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
@@ -0,0 +1,105 @@
1
+ """CodeAgent 后处理模块"""
2
+
3
+ import os
4
+ import subprocess
5
+
6
+ from jarvis.jarvis_utils.output import PrettyOutput
7
+
8
+ # -*- coding: utf-8 -*-
9
+ from typing import List
10
+
11
+ from jarvis.jarvis_code_agent.after_change import get_after_change_commands_for_files
12
+
13
+
14
+ class PostProcessManager:
15
+ """后处理管理器"""
16
+
17
+ def __init__(self, root_dir: str):
18
+ self.root_dir = root_dir
19
+
20
+ def post_process_modified_files(self, modified_files: List[str]) -> None:
21
+ """文件后处理(包括格式化、自动修复等)
22
+
23
+ Args:
24
+ modified_files: 修改的文件列表
25
+ """
26
+ # 获取变更后处理命令
27
+ after_change_commands = get_after_change_commands_for_files(
28
+ modified_files, self.root_dir
29
+ )
30
+ if not after_change_commands:
31
+ return
32
+
33
+ # 执行变更后处理命令
34
+ processed_files = set()
35
+ for file_path, command in after_change_commands:
36
+ # 从命令中提取工具名(第一个单词)用于日志
37
+ tool_name = command.split()[0] if command.split() else "unknown"
38
+ try:
39
+ # 检查文件是否存在
40
+ abs_file_path = (
41
+ os.path.join(self.root_dir, file_path)
42
+ if not os.path.isabs(file_path)
43
+ else file_path
44
+ )
45
+ if not os.path.exists(abs_file_path):
46
+ continue
47
+
48
+ # 执行变更后处理命令
49
+ result = subprocess.run(
50
+ command,
51
+ shell=True,
52
+ cwd=self.root_dir,
53
+ capture_output=True,
54
+ text=True,
55
+ encoding="utf-8",
56
+ errors="replace",
57
+ timeout=300, # 300秒超时
58
+ )
59
+
60
+ if result.returncode == 0:
61
+ processed_files.add(file_path)
62
+ PrettyOutput.auto_print(
63
+ f"✅ 已处理: {os.path.basename(file_path)} ({tool_name})"
64
+ )
65
+ else:
66
+ # 处理失败,记录但不中断流程
67
+ error_msg = (result.stderr or result.stdout or "").strip()
68
+ if error_msg:
69
+ PrettyOutput.auto_print(
70
+ f"⚠️ 处理失败 ({os.path.basename(file_path)}, {tool_name}): {error_msg[:200]}"
71
+ )
72
+ except subprocess.TimeoutExpired:
73
+ PrettyOutput.auto_print(
74
+ f"⚠️ 处理超时: {os.path.basename(file_path)} ({tool_name})"
75
+ )
76
+ except FileNotFoundError:
77
+ # 工具未安装,跳过
78
+ continue
79
+ except Exception as e:
80
+ # 其他错误,记录但继续
81
+ PrettyOutput.auto_print(
82
+ f"⚠️ 处理失败 ({os.path.basename(file_path)}, {tool_name}): {str(e)[:100]}"
83
+ )
84
+ continue
85
+
86
+ if processed_files:
87
+ PrettyOutput.auto_print(f"✅ 已处理 {len(processed_files)} 个文件")
88
+ # 暂存处理后的文件
89
+ try:
90
+ for file_path in processed_files:
91
+ abs_file_path = (
92
+ os.path.join(self.root_dir, file_path)
93
+ if not os.path.isabs(file_path)
94
+ else file_path
95
+ )
96
+ if os.path.exists(abs_file_path):
97
+ subprocess.run(
98
+ ["git", "add", file_path],
99
+ cwd=self.root_dir,
100
+ check=False,
101
+ stdout=subprocess.DEVNULL,
102
+ stderr=subprocess.DEVNULL,
103
+ )
104
+ except Exception:
105
+ pass
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ """CodeAgent 系统提示词模块"""
3
+
4
+
5
+ def get_system_prompt() -> str:
6
+ """获取代码工程师的系统提示词"""
7
+ return """
8
+ 你是Jarvis代码工程师,专注于**项目级代码分析、精准修改与问题排查**,核心原则:自主决策、高效精准、可回退、工具优先、禁止臆测。
9
+
10
+ ## 元指令
11
+ - 每次响应开头必须声明模式,格式`[MODE: MODE_NAME]`;默认 INTENT。
12
+ - 模式切换信号:ENTER INTENT/RESEARCH/INNOVATE/PLAN/EXECUTE/REVIEW。
13
+ - 简单任务直接执行;复杂任务才用 task_list_manager,避免过度拆分。
14
+ - **整体工作流必须严格按照 IIRIPER 流程顺序执行:INTENT → RESEARCH → INNOVATE → PLAN → EXECUTE → REVIEW。禁止跳过任意阶段或乱序进入后续模式,除非用户以非常明确的指令要求跳过,并且需要在回复中显式说明原因。**
15
+
16
+ ## 模式速览(IIRIPER)
17
+ - **INTENT**:澄清需求与约束,提炼目标与疑点,先问清楚再动手。
18
+ - **RESEARCH**:只读不改,定位文件/上下文/约束,不给方案。
19
+ - **INNOVATE**:头脑风暴多种方案,评估优劣,不写实现。
20
+ - **PLAN**:给出可执行技术方案,必要时用 task_list_manager 创建任务列表并切分大数据/多目录;禁止编写代码。
21
+ - **EXECUTE**:按计划实施;每次 `execute_task` 必须带非空 `additional_info`(背景+关键信息+约束+预期结果);已有任务列表时优先用 task_list_manager。单次回复只做一个工具调用(完成时除外)。
22
+ - **REVIEW**:核对完成度与影响面,必要时用 task_list_manager 获取任务状态。
23
+
24
+ ### IIRIPER 严格执行要求
25
+ - 任何任务都应从 **INTENT** 开始,对需求/约束对齐后,依次进入 **RESEARCH → INNOVATE → PLAN → EXECUTE → REVIEW**。
26
+ - **禁止**在未经过 PLAN 就直接进入 EXECUTE,更禁止从 INTENT 直接跳到 EXECUTE/REVIEW。
27
+ - 如因用户强制要求跳过某阶段,必须在当前回复中说明“跳过了哪个阶段、为什么合理、可能的风险”,并尽量补充最小必要分析。
28
+
29
+ ## 关键流程(闭环)
30
+ 1) 对齐需求与约束;锁定核心目录/技术栈/风格。
31
+ 2) 精准定位文件(搜索需带目录/后缀过滤;能不用就不盲读)。
32
+ 3) 读取并分析上下文,禁止凭空猜测。
33
+ 4) 设计最小可回退改动,先备份核心改动再动手。
34
+ 5) 先读后写:用 read_code 确认位置,再用 edit_file 精准修改;避免 sed/脚本处理复杂改动。
35
+ 6) 验证:语法/构建/关键路径/必要用例;清理临时文件与日志。
36
+
37
+ ## 工具与质量
38
+ - 搜索:必须过滤目录/后缀;只查相关代码。
39
+ - read_code:只读目标及直接相关依赖,避免日志/数据/依赖包。
40
+ - edit_file:保持原缩进与风格,不留多余空行。
41
+ - 质量底线:语法正确;不破坏已有功能;风格一致;改动可维护且必要处可加简短注释。
42
+
43
+ ## 禁止项
44
+ - 虚构代码/路径/依赖;无差别大范围读取;大删大改未授权;改非项目目录;复杂改动用 sed/python;提交临时文件。
45
+
46
+ """
@@ -0,0 +1,305 @@
1
+ """CodeAgent 规则管理模块"""
2
+
3
+ import os
4
+ import subprocess
5
+
6
+ from jarvis.jarvis_utils.output import PrettyOutput
7
+
8
+ # -*- coding: utf-8 -*-
9
+ from typing import List
10
+ from typing import Optional
11
+
12
+ import yaml
13
+
14
+ from jarvis.jarvis_code_agent.builtin_rules import get_builtin_rule
15
+ from jarvis.jarvis_utils.config import get_central_rules_repo
16
+ from jarvis.jarvis_utils.config import get_data_dir
17
+ from jarvis.jarvis_utils.config import get_rules_load_dirs
18
+ from jarvis.jarvis_utils.utils import daily_check_git_updates
19
+
20
+
21
+ class RulesManager:
22
+ """规则管理器,负责加载和管理各种规则"""
23
+
24
+ def __init__(self, root_dir: str):
25
+ self.root_dir = root_dir
26
+ # 初始化规则目录列表
27
+ self._init_rules_dirs()
28
+
29
+ def _init_rules_dirs(self) -> None:
30
+ """初始化规则目录列表,包括配置的目录和中心库"""
31
+ # 基础目录:全局数据目录下的 rules 目录
32
+ self.rules_dirs: List[str] = [os.path.join(get_data_dir(), "rules")]
33
+
34
+ # 添加配置的规则加载目录
35
+ self.rules_dirs.extend(get_rules_load_dirs())
36
+
37
+ # 中心规则仓库路径(单独存储,优先级最高)
38
+ self.central_repo_path: Optional[str] = None
39
+ central_repo = get_central_rules_repo()
40
+ if central_repo:
41
+ # 支持本地目录路径或Git仓库URL
42
+ expanded = os.path.expanduser(os.path.expandvars(central_repo))
43
+ if os.path.isdir(expanded):
44
+ # 直接使用本地目录(支持Git仓库的子目录)
45
+ self.central_repo_path = expanded
46
+ else:
47
+ # 中心规则仓库存储在数据目录下的特定位置
48
+ self.central_repo_path = os.path.join(
49
+ get_data_dir(), "central_rules_repo"
50
+ )
51
+
52
+ # 确保中心规则仓库被克隆/更新
53
+ if not os.path.exists(self.central_repo_path):
54
+ try:
55
+ PrettyOutput.auto_print(
56
+ f"ℹ️ 正在克隆中心规则仓库: {central_repo}"
57
+ )
58
+ subprocess.run(
59
+ ["git", "clone", central_repo, self.central_repo_path],
60
+ check=True,
61
+ )
62
+ except Exception as e:
63
+ PrettyOutput.auto_print(f"❌ 克隆中心规则仓库失败: {str(e)}")
64
+
65
+ # 执行每日更新检查(包括中心库)
66
+ all_dirs_for_update = self.rules_dirs.copy()
67
+ if self.central_repo_path:
68
+ all_dirs_for_update.append(self.central_repo_path)
69
+ daily_check_git_updates(all_dirs_for_update, "rules")
70
+
71
+ def read_project_rule(self) -> Optional[str]:
72
+ """读取 .jarvis/rule 文件内容,如果存在则返回字符串,否则返回 None"""
73
+ try:
74
+ rules_path = os.path.join(self.root_dir, ".jarvis", "rule")
75
+ if os.path.exists(rules_path) and os.path.isfile(rules_path):
76
+ with open(rules_path, "r", encoding="utf-8", errors="replace") as f:
77
+ content = f.read().strip()
78
+ return content if content else None
79
+ except Exception:
80
+ # 读取规则失败时忽略,不影响主流程
81
+ pass
82
+ return None
83
+
84
+ def read_global_rules(self) -> Optional[str]:
85
+ """读取数据目录 rules 内容,如果存在则返回字符串,否则返回 None"""
86
+ try:
87
+ rules_path = os.path.join(get_data_dir(), "rule")
88
+ if os.path.exists(rules_path) and os.path.isfile(rules_path):
89
+ with open(rules_path, "r", encoding="utf-8", errors="replace") as f:
90
+ content = f.read().strip()
91
+ return content if content else None
92
+ except Exception:
93
+ # 读取规则失败时忽略,不影响主流程
94
+ pass
95
+ return None
96
+
97
+ def _read_rule_from_dir(self, rules_dir: str, rule_name: str) -> Optional[str]:
98
+ """从 rules 目录中读取指定名称的规则文件
99
+
100
+ 参数:
101
+ rules_dir: rules 目录路径
102
+ rule_name: 规则名称(文件名)
103
+
104
+ 返回:
105
+ str: 规则内容,如果未找到则返回 None
106
+ """
107
+ try:
108
+ rule_file_path = os.path.join(rules_dir, rule_name)
109
+ if os.path.exists(rule_file_path) and os.path.isfile(rule_file_path):
110
+ with open(rule_file_path, "r", encoding="utf-8", errors="replace") as f:
111
+ content = f.read().strip()
112
+ return content if content else None
113
+ except Exception:
114
+ # 读取规则失败时忽略,不影响主流程
115
+ pass
116
+ return None
117
+
118
+ def _get_all_rules_dirs(self) -> List[str]:
119
+ """获取所有规则目录(包括项目目录和配置的目录)
120
+
121
+ 返回:
122
+ List[str]: 规则目录列表,按优先级排序(中心库 > 项目 > 配置目录)
123
+ """
124
+ all_dirs = []
125
+ # 优先级 1: 中心规则仓库(如果有同名规则,以中心仓库为准)
126
+ if (
127
+ self.central_repo_path
128
+ and os.path.exists(self.central_repo_path)
129
+ and os.path.isdir(self.central_repo_path)
130
+ ):
131
+ # 检查中心仓库中是否有 rules 子目录
132
+ central_rules_dir = os.path.join(self.central_repo_path, "rules")
133
+ if os.path.exists(central_rules_dir) and os.path.isdir(central_rules_dir):
134
+ all_dirs.append(central_rules_dir)
135
+ else:
136
+ # 如果没有 rules 子目录,直接使用中心仓库根目录
137
+ all_dirs.append(self.central_repo_path)
138
+ # 优先级 2: 项目 rules 目录
139
+ project_rules_dir = os.path.join(self.root_dir, ".jarvis", "rules")
140
+ if os.path.exists(project_rules_dir) and os.path.isdir(project_rules_dir):
141
+ all_dirs.append(project_rules_dir)
142
+ # 优先级 3-N: 配置的规则目录(不包括中心库)
143
+ all_dirs.extend(self.rules_dirs)
144
+ return all_dirs
145
+
146
+ def _get_all_rules_yaml_files(self) -> List[tuple[str, str]]:
147
+ """获取所有 rules.yaml 文件路径(描述,文件路径)
148
+
149
+ 返回:
150
+ List[tuple[str, str]]: (描述, 文件路径) 列表,按优先级排序(中心库 > 项目 > 全局)
151
+ """
152
+ yaml_files = []
153
+ # 优先级 1: 中心规则仓库的 rules.yaml(如果有同名规则,以中心仓库为准)
154
+ if self.central_repo_path and os.path.exists(self.central_repo_path):
155
+ central_rules_yaml = os.path.join(self.central_repo_path, "rules.yaml")
156
+ if os.path.exists(central_rules_yaml) and os.path.isfile(
157
+ central_rules_yaml
158
+ ):
159
+ yaml_files.append(("中心库", central_rules_yaml))
160
+ # 优先级 2: 项目 rules.yaml
161
+ project_rules_yaml = os.path.join(self.root_dir, ".jarvis", "rules.yaml")
162
+ if os.path.exists(project_rules_yaml) and os.path.isfile(project_rules_yaml):
163
+ yaml_files.append(("项目", project_rules_yaml))
164
+ # 优先级 3: 全局 rules.yaml
165
+ global_rules_yaml = os.path.join(get_data_dir(), "rules.yaml")
166
+ if os.path.exists(global_rules_yaml) and os.path.isfile(global_rules_yaml):
167
+ yaml_files.append(("全局", global_rules_yaml))
168
+ return yaml_files
169
+
170
+ def get_named_rule(self, rule_name: str) -> Optional[str]:
171
+ """从 rules.yaml 文件和 rules 目录中获取指定名称的规则
172
+
173
+ 查找优先级(从高到低):
174
+ 1. 中心规则仓库中的文件(如果有同名规则,以中心仓库为准)
175
+ 2. 项目 rules 目录中的文件
176
+ 3. 项目 rules.yaml 文件
177
+ 4. 配置的规则目录中的文件(按配置顺序,不包括中心库)
178
+ 5. 全局 rules.yaml 文件
179
+ 6. 内置规则(最低优先级,作为后备)
180
+
181
+ 参数:
182
+ rule_name: 规则名称
183
+
184
+ 返回:
185
+ str: 规则内容,如果未找到则返回 None
186
+ """
187
+ try:
188
+ # 优先级 1: 从所有规则目录读取(中心库 > 项目 > 配置目录)
189
+ for rules_dir in self._get_all_rules_dirs():
190
+ if os.path.exists(rules_dir) and os.path.isdir(rules_dir):
191
+ rule_content = self._read_rule_from_dir(rules_dir, rule_name)
192
+ if rule_content:
193
+ return rule_content
194
+
195
+ # 优先级 2: 从所有 rules.yaml 文件读取(中心库 > 项目 > 全局)
196
+ for desc, yaml_path in self._get_all_rules_yaml_files():
197
+ if os.path.exists(yaml_path) and os.path.isfile(yaml_path):
198
+ try:
199
+ with open(
200
+ yaml_path, "r", encoding="utf-8", errors="replace"
201
+ ) as f:
202
+ rules = yaml.safe_load(f) or {}
203
+ if rule_name in rules:
204
+ rule_value = rules[rule_name]
205
+ if isinstance(rule_value, str):
206
+ content = rule_value.strip()
207
+ else:
208
+ content = str(rule_value).strip()
209
+ if content:
210
+ return content
211
+ except Exception:
212
+ # 单个文件读取失败不影响其他文件
213
+ continue
214
+
215
+ # 优先级 3: 从内置规则中查找(最低优先级,作为后备)
216
+ builtin_rule = get_builtin_rule(rule_name)
217
+ if builtin_rule:
218
+ return builtin_rule
219
+
220
+ return None
221
+ except Exception as e:
222
+ # 读取规则失败时忽略,不影响主流程
223
+ PrettyOutput.auto_print(f"⚠️ 读取规则失败: {e}")
224
+ return None
225
+
226
+ def get_all_available_rule_names(self) -> dict[str, List[str]]:
227
+ """获取所有可用的规则名称,按来源分类
228
+
229
+ 返回:
230
+ dict[str, List[str]]: 按来源分类的规则名称字典
231
+ - "builtin": 内置规则列表
232
+ - "files": 规则目录中的文件规则列表
233
+ - "yaml": rules.yaml 文件中的规则列表
234
+ """
235
+ from jarvis.jarvis_code_agent.builtin_rules import list_builtin_rules
236
+
237
+ result = {
238
+ "builtin": list_builtin_rules(),
239
+ "files": [],
240
+ "yaml": [],
241
+ }
242
+
243
+ # 收集规则目录中的文件规则
244
+ for rules_dir in self._get_all_rules_dirs():
245
+ if os.path.exists(rules_dir) and os.path.isdir(rules_dir):
246
+ try:
247
+ for filename in os.listdir(rules_dir):
248
+ file_path = os.path.join(rules_dir, filename)
249
+ if os.path.isfile(file_path):
250
+ # 规则名称就是文件名
251
+ if filename not in result["files"]:
252
+ result["files"].append(filename)
253
+ except Exception:
254
+ continue
255
+
256
+ # 收集 rules.yaml 文件中的规则
257
+ for desc, yaml_path in self._get_all_rules_yaml_files():
258
+ if os.path.exists(yaml_path) and os.path.isfile(yaml_path):
259
+ try:
260
+ with open(yaml_path, "r", encoding="utf-8", errors="replace") as f:
261
+ rules = yaml.safe_load(f) or {}
262
+ if isinstance(rules, dict):
263
+ for rule_name in rules.keys():
264
+ if rule_name not in result["yaml"]:
265
+ result["yaml"].append(rule_name)
266
+ except Exception:
267
+ continue
268
+
269
+ return result
270
+
271
+ def load_all_rules(self, rule_names: Optional[str] = None) -> tuple[str, List[str]]:
272
+ """加载所有规则并合并
273
+
274
+ 参数:
275
+ rule_names: 规则名称列表(逗号分隔)
276
+
277
+ 返回:
278
+ (merged_rules, loaded_rule_names): 合并后的规则字符串和已加载的规则名称列表
279
+ """
280
+ combined_parts: List[str] = []
281
+ loaded_rule_names: List[str] = []
282
+
283
+ global_rules = self.read_global_rules()
284
+ project_rules = self.read_project_rule()
285
+
286
+ if global_rules:
287
+ combined_parts.append(global_rules)
288
+ loaded_rule_names.append("global_rule")
289
+ if project_rules:
290
+ combined_parts.append(project_rules)
291
+ loaded_rule_names.append("project_rule")
292
+
293
+ # 如果指定了 rule_names,从 rules.yaml 文件中读取并添加多个规则
294
+ if rule_names:
295
+ rule_list = [name.strip() for name in rule_names.split(",") if name.strip()]
296
+ for rule_name in rule_list:
297
+ named_rule = self.get_named_rule(rule_name)
298
+ if named_rule:
299
+ combined_parts.append(named_rule)
300
+ loaded_rule_names.append(rule_name)
301
+
302
+ if combined_parts:
303
+ merged_rules = "\n\n".join(combined_parts)
304
+ return merged_rules, loaded_rule_names
305
+ return "", []
@@ -3,63 +3,67 @@
3
3
  提供符号提取、依赖分析和上下文管理功能。
4
4
  """
5
5
 
6
- from .symbol_extractor import Symbol, SymbolTable, SymbolExtractor
7
- from .dependency_analyzer import Dependency, DependencyGraph, DependencyAnalyzer
8
- from .context_manager import ContextManager, EditContext, Reference
6
+ from .base_language import BaseLanguageSupport
7
+ from .context_manager import ContextManager
8
+ from .context_manager import EditContext
9
+ from .context_manager import Reference
9
10
  from .context_recommender import ContextRecommendation
11
+ from .dependency_analyzer import Dependency
12
+ from .dependency_analyzer import DependencyAnalyzer
13
+ from .dependency_analyzer import DependencyGraph
14
+ from .impact_analyzer import Edit
15
+ from .impact_analyzer import Impact
16
+ from .impact_analyzer import ImpactAnalyzer
17
+ from .impact_analyzer import ImpactReport
18
+ from .impact_analyzer import ImpactType
19
+ from .impact_analyzer import InterfaceChange
20
+ from .impact_analyzer import RiskLevel
21
+ from .impact_analyzer import TestDiscoverer
22
+ from .impact_analyzer import parse_git_diff_to_edits
23
+ from .language_registry import LanguageRegistry
24
+ from .language_registry import get_registry
25
+ from .language_registry import register_language
26
+ from .language_support import detect_language
27
+ from .language_support import get_dependency_analyzer
28
+ from .language_support import get_symbol_extractor
10
29
  from .llm_context_recommender import ContextRecommender
11
- from .language_support import detect_language, get_symbol_extractor, get_dependency_analyzer
12
- from .base_language import BaseLanguageSupport
13
- from .language_registry import LanguageRegistry, get_registry, register_language
14
- from .impact_analyzer import (
15
- ImpactAnalyzer,
16
- Impact,
17
- ImpactReport,
18
- ImpactType,
19
- RiskLevel,
20
- InterfaceChange,
21
- Edit,
22
- TestDiscoverer,
23
- parse_git_diff_to_edits,
24
- )
25
- from .structured_code import StructuredCodeExtractor
30
+ from .symbol_extractor import Symbol
31
+ from .symbol_extractor import SymbolExtractor
32
+ from .symbol_extractor import SymbolTable
26
33
 
27
34
  __all__ = [
28
35
  # Symbol extraction
29
- 'Symbol',
30
- 'SymbolTable',
31
- 'SymbolExtractor',
36
+ "Symbol",
37
+ "SymbolTable",
38
+ "SymbolExtractor",
32
39
  # Dependency analysis
33
- 'Dependency',
34
- 'DependencyGraph',
35
- 'DependencyAnalyzer',
40
+ "Dependency",
41
+ "DependencyGraph",
42
+ "DependencyAnalyzer",
36
43
  # Context management
37
- 'ContextManager',
38
- 'EditContext',
39
- 'Reference',
44
+ "ContextManager",
45
+ "EditContext",
46
+ "Reference",
40
47
  # Context recommendation
41
- 'ContextRecommender',
42
- 'ContextRecommendation',
48
+ "ContextRecommender",
49
+ "ContextRecommendation",
43
50
  # Language support
44
- 'detect_language',
45
- 'get_symbol_extractor',
46
- 'get_dependency_analyzer',
51
+ "detect_language",
52
+ "get_symbol_extractor",
53
+ "get_dependency_analyzer",
47
54
  # Language registry
48
- 'BaseLanguageSupport',
49
- 'LanguageRegistry',
50
- 'get_registry',
51
- 'register_language',
55
+ "BaseLanguageSupport",
56
+ "LanguageRegistry",
57
+ "get_registry",
58
+ "register_language",
52
59
  # Impact analysis
53
- 'ImpactAnalyzer',
54
- 'Impact',
55
- 'ImpactReport',
56
- 'ImpactType',
57
- 'RiskLevel',
58
- 'InterfaceChange',
59
- 'Edit',
60
- 'TestDiscoverer',
61
- 'parse_git_diff_to_edits',
62
- # Structured code extraction
63
- 'StructuredCodeExtractor',
60
+ "ImpactAnalyzer",
61
+ "Impact",
62
+ "ImpactReport",
63
+ "ImpactType",
64
+ "RiskLevel",
65
+ "InterfaceChange",
66
+ "Edit",
67
+ "TestDiscoverer",
68
+ "parse_git_diff_to_edits",
64
69
  ]
65
-
@@ -3,8 +3,10 @@
3
3
  定义所有语言支持需要实现的接口,便于扩展新的语言支持。
4
4
  """
5
5
 
6
- from abc import ABC, abstractmethod
7
- from typing import Optional, Set
6
+ from abc import ABC
7
+ from abc import abstractmethod
8
+ from typing import Optional
9
+ from typing import Set
8
10
 
9
11
  from .dependency_analyzer import DependencyAnalyzer
10
12
  from .symbol_extractor import SymbolExtractor
@@ -12,7 +14,7 @@ from .symbol_extractor import SymbolExtractor
12
14
 
13
15
  class BaseLanguageSupport(ABC):
14
16
  """语言支持的基础抽象类。
15
-
17
+
16
18
  所有语言支持类都应该继承此类并实现所需的方法。
17
19
  """
18
20
 
@@ -31,7 +33,7 @@ class BaseLanguageSupport(ABC):
31
33
  @abstractmethod
32
34
  def create_symbol_extractor(self) -> Optional[SymbolExtractor]:
33
35
  """创建并返回该语言的符号提取器实例。
34
-
36
+
35
37
  Returns:
36
38
  SymbolExtractor实例,如果不支持符号提取则返回None
37
39
  """
@@ -40,7 +42,7 @@ class BaseLanguageSupport(ABC):
40
42
  @abstractmethod
41
43
  def create_dependency_analyzer(self) -> Optional[DependencyAnalyzer]:
42
44
  """创建并返回该语言的依赖分析器实例。
43
-
45
+
44
46
  Returns:
45
47
  DependencyAnalyzer实例,如果不支持依赖分析则返回None
46
48
  """
@@ -48,27 +50,27 @@ class BaseLanguageSupport(ABC):
48
50
 
49
51
  def is_source_file(self, file_path: str) -> bool:
50
52
  """检查文件是否为该语言的源文件。
51
-
53
+
52
54
  Args:
53
55
  file_path: 文件路径
54
-
56
+
55
57
  Returns:
56
58
  如果是该语言的源文件返回True,否则返回False
57
59
  """
58
60
  import os
61
+
59
62
  _, ext = os.path.splitext(file_path)
60
63
  return ext in self.file_extensions
61
64
 
62
65
  def detect_language(self, file_path: str) -> Optional[str]:
63
66
  """检测文件是否属于该语言。
64
-
67
+
65
68
  Args:
66
69
  file_path: 文件路径
67
-
70
+
68
71
  Returns:
69
72
  如果属于该语言返回language_name,否则返回None
70
73
  """
71
74
  if self.is_source_file(file_path):
72
75
  return self.language_name
73
76
  return None
74
-
@@ -8,20 +8,22 @@
8
8
  """
9
9
 
10
10
  # 导出主要接口
11
- from .base import BuildSystem, BuildResult, BuildValidatorBase
11
+ from .base import BuildResult
12
+ from .base import BuildSystem
13
+ from .base import BuildValidatorBase
14
+ from .cmake import CMakeBuildValidator
12
15
  from .detector import BuildSystemDetector
13
- from .validator import BuildValidator
16
+ from .fallback import FallbackBuildValidator
17
+ from .go import GoBuildValidator
18
+ from .java_gradle import JavaGradleBuildValidator
19
+ from .java_maven import JavaMavenBuildValidator
20
+ from .makefile import MakefileBuildValidator
21
+ from .nodejs import NodeJSBuildValidator
22
+ from .python import PythonBuildValidator
14
23
 
15
24
  # 导出各语言验证器(便于扩展)
16
25
  from .rust import RustBuildValidator
17
- from .python import PythonBuildValidator
18
- from .nodejs import NodeJSBuildValidator
19
- from .java_maven import JavaMavenBuildValidator
20
- from .java_gradle import JavaGradleBuildValidator
21
- from .go import GoBuildValidator
22
- from .cmake import CMakeBuildValidator
23
- from .makefile import MakefileBuildValidator
24
- from .fallback import FallbackBuildValidator
26
+ from .validator import BuildValidator
25
27
 
26
28
  __all__ = [
27
29
  # 主要接口
@@ -41,4 +43,3 @@ __all__ = [
41
43
  "MakefileBuildValidator",
42
44
  "FallbackBuildValidator",
43
45
  ]
44
-