jarvis-ai-assistant 0.7.8__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.8.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.8.dist-info/RECORD +0 -218
  276. {jarvis_ai_assistant-0.7.8.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/WHEEL +0 -0
  277. {jarvis_ai_assistant-0.7.8.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/entry_points.txt +0 -0
  278. {jarvis_ai_assistant-0.7.8.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/licenses/LICENSE +0 -0
  279. {jarvis_ai_assistant-0.7.8.dist-info → jarvis_ai_assistant-1.0.2.dist-info}/top_level.txt +0 -0
@@ -12,7 +12,8 @@ from .symbol_extractor import Symbol
12
12
  @dataclass
13
13
  class ContextRecommendation:
14
14
  """上下文推荐结果
15
-
15
+
16
16
  推荐符号在文件中的位置信息。
17
17
  """
18
+
18
19
  recommended_symbols: List[Symbol] # 推荐的符号列表(包含文件路径和行号)
@@ -5,18 +5,24 @@
5
5
 
6
6
  import os
7
7
  from dataclasses import dataclass
8
- from typing import Dict, List, Set, Optional
8
+ from typing import Dict
9
+ from typing import List
10
+ from typing import Optional
11
+ from typing import Set
9
12
 
10
13
  from .file_ignore import filter_walk_dirs
11
14
 
15
+
12
16
  @dataclass
13
17
  class Dependency:
14
18
  """Represents an import dependency."""
19
+
15
20
  from_module: str
16
21
  imported_symbol: Optional[str] = None # None means import entire module
17
22
  file_path: str = ""
18
23
  line: int = 0
19
24
 
25
+
20
26
  class DependencyGraph:
21
27
  """Represents the dependency graph of a project."""
22
28
 
@@ -59,7 +65,10 @@ class DependencyGraph:
59
65
  if file_path in self.dependents:
60
66
  dependents_to_remove = self.dependents.pop(file_path)
61
67
  for dep_file in dependents_to_remove:
62
- if dep_file in self.dependencies and file_path in self.dependencies[dep_file]:
68
+ if (
69
+ dep_file in self.dependencies
70
+ and file_path in self.dependencies[dep_file]
71
+ ):
63
72
  self.dependencies[dep_file].remove(file_path)
64
73
  if not self.dependencies[dep_file]:
65
74
  del self.dependencies[dep_file]
@@ -67,7 +76,7 @@ class DependencyGraph:
67
76
 
68
77
  class DependencyAnalyzer:
69
78
  """Analyzes import dependencies in a source code file.
70
-
79
+
71
80
  这是依赖分析器的基类,具体语言的实现应该在各自的语言支持模块中。
72
81
  例如:PythonDependencyAnalyzer 在 languages/python_language.py 中。
73
82
  """
@@ -76,11 +85,11 @@ class DependencyAnalyzer:
76
85
  """
77
86
  Analyzes the import statements in the code.
78
87
  This method should be implemented by language-specific subclasses.
79
-
88
+
80
89
  Args:
81
90
  file_path: 文件路径
82
91
  content: 文件内容
83
-
92
+
84
93
  Returns:
85
94
  依赖列表
86
95
  """
@@ -90,29 +99,29 @@ class DependencyAnalyzer:
90
99
  """
91
100
  Builds a dependency graph for the entire project.
92
101
  This would involve iterating over all source files.
93
-
102
+
94
103
  Args:
95
104
  project_root: 项目根目录
96
-
105
+
97
106
  Returns:
98
107
  依赖图
99
108
  """
100
109
  graph = DependencyGraph()
101
-
110
+
102
111
  # Walk through all source files in the project
103
112
  for root, dirs, files in os.walk(project_root):
104
113
  # Skip hidden directories and common ignore patterns
105
114
  dirs[:] = filter_walk_dirs(dirs)
106
-
115
+
107
116
  for file in files:
108
117
  file_path = os.path.join(root, file)
109
118
  if not self._is_source_file(file_path):
110
119
  continue
111
-
120
+
112
121
  try:
113
- with open(file_path, 'r', encoding='utf-8', errors='replace') as f:
122
+ with open(file_path, "r", encoding="utf-8", errors="replace") as f:
114
123
  content = f.read()
115
-
124
+
116
125
  dependencies = self.analyze_imports(file_path, content)
117
126
  for dep in dependencies:
118
127
  # Resolve dependency path (this should be done by language-specific analyzer)
@@ -121,12 +130,12 @@ class DependencyAnalyzer:
121
130
  except Exception:
122
131
  # Skip files that can't be read or parsed
123
132
  continue
124
-
133
+
125
134
  return graph
126
135
 
127
136
  def _is_source_file(self, file_path: str) -> bool:
128
137
  """Check if a file is a source file that should be analyzed.
129
-
138
+
130
139
  This should be overridden by subclasses.
131
140
  """
132
- return False
141
+ return False
@@ -4,187 +4,275 @@
4
4
  """
5
5
 
6
6
  from pathlib import Path
7
- from typing import List, Set, Optional, Callable
7
+ from typing import Callable
8
+ from typing import List
9
+ from typing import Optional
10
+ from typing import Set
8
11
 
9
12
 
10
13
  class FileIgnorePatterns:
11
14
  """文件忽略模式集合。
12
-
15
+
13
16
  定义了各种常见的需要忽略的文件和目录模式。
14
17
  """
15
-
18
+
16
19
  # 隐藏目录/文件(以 . 开头)
17
- HIDDEN_PATTERNS: Set[str] = {'.git', '.svn', '.hg', '.bzr'}
18
-
20
+ HIDDEN_PATTERNS: Set[str] = {".git", ".svn", ".hg", ".bzr"}
21
+
19
22
  # 版本控制目录
20
- VCS_DIRS: Set[str] = {'.git', '.svn', '.hg', '.bzr', '.gitignore'}
21
-
23
+ VCS_DIRS: Set[str] = {".git", ".svn", ".hg", ".bzr", ".gitignore"}
24
+
22
25
  # Python 相关
23
26
  PYTHON_DIRS: Set[str] = {
24
- '__pycache__', '.pytest_cache', '.mypy_cache', '.ruff_cache',
25
- '.tox', '.coverage', 'htmlcov', '.hypothesis', '.ipynb_checkpoints',
26
- '.pyre', '.pytype', 'develop-eggs', 'downloads', 'eggs', '.eggs',
27
- 'lib', 'lib64', 'parts', 'sdist', 'var', 'wheels', 'pip-wheel-metadata',
28
- 'share', '*.egg-info', '.installed.cfg', 'MANIFEST'
27
+ "__pycache__",
28
+ ".pytest_cache",
29
+ ".mypy_cache",
30
+ ".ruff_cache",
31
+ ".tox",
32
+ ".coverage",
33
+ "htmlcov",
34
+ ".hypothesis",
35
+ ".ipynb_checkpoints",
36
+ ".pyre",
37
+ ".pytype",
38
+ "develop-eggs",
39
+ "downloads",
40
+ "eggs",
41
+ ".eggs",
42
+ "lib",
43
+ "lib64",
44
+ "parts",
45
+ "sdist",
46
+ "var",
47
+ "wheels",
48
+ "pip-wheel-metadata",
49
+ "share",
50
+ "*.egg-info",
51
+ ".installed.cfg",
52
+ "MANIFEST",
29
53
  }
30
- PYTHON_VENV_DIRS: Set[str] = {'venv', 'env', '.venv', 'virtualenv', 'ENV'}
31
-
54
+ PYTHON_VENV_DIRS: Set[str] = {"venv", "env", ".venv", "virtualenv", "ENV"}
55
+
32
56
  # Rust 相关
33
- RUST_DIRS: Set[str] = {'target', 'Cargo.lock'}
34
-
57
+ RUST_DIRS: Set[str] = {"target", "Cargo.lock"}
58
+
35
59
  # Go 相关
36
- GO_DIRS: Set[str] = {'vendor', 'bin', 'coverage.out'}
37
-
60
+ GO_DIRS: Set[str] = {"vendor", "bin", "coverage.out"}
61
+
38
62
  # Node.js 相关
39
63
  NODE_DIRS: Set[str] = {
40
- 'node_modules', '.npm', '.yarn', '.pnpm', '.turbo', '.next', '.nuxt',
41
- 'out', 'dist', 'coverage', 'build'
64
+ "node_modules",
65
+ ".npm",
66
+ ".yarn",
67
+ ".pnpm",
68
+ ".turbo",
69
+ ".next",
70
+ ".nuxt",
71
+ "out",
72
+ "dist",
73
+ "coverage",
74
+ "build",
42
75
  }
43
-
76
+
44
77
  # Java 相关
45
- JAVA_DIRS: Set[str] = {'target', '.gradle', 'build', 'out', '*.class'}
46
-
78
+ JAVA_DIRS: Set[str] = {"target", ".gradle", "build", "out", "*.class"}
79
+
47
80
  # C/C++ 相关
48
81
  C_CPP_DIRS: Set[str] = {
49
- 'build', 'cmake-build-*', 'out', 'bin', 'obj', '*.o', '*.a', '*.so',
50
- '*.obj', '*.dll', '*.dylib', '*.exe', '*.pdb'
82
+ "build",
83
+ "cmake-build-*",
84
+ "out",
85
+ "bin",
86
+ "obj",
87
+ "*.o",
88
+ "*.a",
89
+ "*.so",
90
+ "*.obj",
91
+ "*.dll",
92
+ "*.dylib",
93
+ "*.exe",
94
+ "*.pdb",
51
95
  }
52
-
96
+
53
97
  # .NET 相关
54
- DOTNET_DIRS: Set[str] = {'bin', 'obj', 'packages'}
55
-
98
+ DOTNET_DIRS: Set[str] = {"bin", "obj", "packages"}
99
+
56
100
  # 构建产物目录(通用)
57
101
  BUILD_DIRS: Set[str] = {
58
- 'build', 'out', 'target', 'dist', 'bin', 'obj', 'cmake-build-*'
102
+ "build",
103
+ "out",
104
+ "target",
105
+ "dist",
106
+ "bin",
107
+ "obj",
108
+ "cmake-build-*",
59
109
  }
60
-
110
+
61
111
  # 依赖目录(通用)
62
112
  DEPENDENCY_DIRS: Set[str] = {
63
- 'third_party', 'vendor', 'deps', 'dependencies', 'libs', 'libraries',
64
- 'external', 'node_modules', 'packages'
113
+ "third_party",
114
+ "vendor",
115
+ "deps",
116
+ "dependencies",
117
+ "libs",
118
+ "libraries",
119
+ "external",
120
+ "node_modules",
121
+ "packages",
65
122
  }
66
-
123
+
67
124
  # 测试目录
68
125
  TEST_DIRS: Set[str] = {
69
- 'test', 'tests', '__tests__', 'spec', 'testsuite', 'testdata',
70
- 'test_data', 'testdata', 'fixtures', 'mocks'
126
+ "test",
127
+ "tests",
128
+ "__tests__",
129
+ "spec",
130
+ "testsuite",
131
+ "testdata",
132
+ "test_data",
133
+ "testdata",
134
+ "fixtures",
135
+ "mocks",
71
136
  }
72
-
137
+
73
138
  # 性能测试目录
74
139
  BENCHMARK_DIRS: Set[str] = {
75
- 'benchmark', 'benchmarks', 'perf', 'performance', 'bench', 'benches',
76
- 'profiling', 'profiler'
140
+ "benchmark",
141
+ "benchmarks",
142
+ "perf",
143
+ "performance",
144
+ "bench",
145
+ "benches",
146
+ "profiling",
147
+ "profiler",
77
148
  }
78
-
149
+
79
150
  # 示例目录
80
151
  EXAMPLE_DIRS: Set[str] = {
81
- 'example', 'examples', 'samples', 'sample', 'demo', 'demos'
152
+ "example",
153
+ "examples",
154
+ "samples",
155
+ "sample",
156
+ "demo",
157
+ "demos",
82
158
  }
83
-
159
+
84
160
  # 临时/缓存目录
85
161
  TEMP_DIRS: Set[str] = {
86
- 'tmp', 'temp', 'cache', '.cache', '*.tmp', '*.log', '*.swp', '*.swo'
162
+ "tmp",
163
+ "temp",
164
+ "cache",
165
+ ".cache",
166
+ "*.tmp",
167
+ "*.log",
168
+ "*.swp",
169
+ "*.swo",
87
170
  }
88
-
171
+
89
172
  # 文档目录
90
- DOC_DIRS: Set[str] = {'docs', 'doc', 'documentation'}
91
-
173
+ DOC_DIRS: Set[str] = {"docs", "doc", "documentation"}
174
+
92
175
  # 生成代码目录
93
- GENERATED_DIRS: Set[str] = {'generated', 'gen', 'auto-generated'}
94
-
176
+ GENERATED_DIRS: Set[str] = {"generated", "gen", "auto-generated"}
177
+
95
178
  # 其他
96
179
  OTHER_DIRS: Set[str] = {
97
- 'playground', 'sandbox', '.idea', '.vscode', '.DS_Store', 'Thumbs.db'
180
+ "playground",
181
+ "sandbox",
182
+ ".idea",
183
+ ".vscode",
184
+ ".DS_Store",
185
+ "Thumbs.db",
98
186
  }
99
-
187
+
100
188
  # Jarvis 特定
101
- JARVIS_DIRS: Set[str] = {'.jarvis'}
102
-
189
+ dirs: Set[str] = {".jarvis"}
190
+
103
191
  @classmethod
104
192
  def get_all_ignore_dirs(cls) -> Set[str]:
105
193
  """获取所有需要忽略的目录名称集合。
106
-
194
+
107
195
  Returns:
108
196
  所有忽略目录名称的集合
109
197
  """
110
198
  return (
111
- cls.VCS_DIRS |
112
- cls.PYTHON_DIRS |
113
- cls.PYTHON_VENV_DIRS |
114
- cls.RUST_DIRS |
115
- cls.GO_DIRS |
116
- cls.NODE_DIRS |
117
- cls.JAVA_DIRS |
118
- cls.C_CPP_DIRS |
119
- cls.DOTNET_DIRS |
120
- cls.BUILD_DIRS |
121
- cls.DEPENDENCY_DIRS |
122
- cls.TEST_DIRS |
123
- cls.BENCHMARK_DIRS |
124
- cls.EXAMPLE_DIRS |
125
- cls.TEMP_DIRS |
126
- cls.DOC_DIRS |
127
- cls.GENERATED_DIRS |
128
- cls.OTHER_DIRS |
129
- cls.JARVIS_DIRS
199
+ cls.VCS_DIRS
200
+ | cls.PYTHON_DIRS
201
+ | cls.PYTHON_VENV_DIRS
202
+ | cls.RUST_DIRS
203
+ | cls.GO_DIRS
204
+ | cls.NODE_DIRS
205
+ | cls.JAVA_DIRS
206
+ | cls.C_CPP_DIRS
207
+ | cls.DOTNET_DIRS
208
+ | cls.BUILD_DIRS
209
+ | cls.DEPENDENCY_DIRS
210
+ | cls.TEST_DIRS
211
+ | cls.BENCHMARK_DIRS
212
+ | cls.EXAMPLE_DIRS
213
+ | cls.TEMP_DIRS
214
+ | cls.DOC_DIRS
215
+ | cls.GENERATED_DIRS
216
+ | cls.OTHER_DIRS
217
+ | cls.dirs
130
218
  )
131
-
219
+
132
220
  @classmethod
133
221
  def get_code_analysis_ignore_dirs(cls) -> Set[str]:
134
222
  """获取代码分析时应该忽略的目录(不包含测试目录)。
135
-
223
+
136
224
  Returns:
137
225
  代码分析忽略目录集合
138
226
  """
139
227
  return (
140
- cls.VCS_DIRS |
141
- cls.PYTHON_DIRS |
142
- cls.PYTHON_VENV_DIRS |
143
- cls.RUST_DIRS |
144
- cls.GO_DIRS |
145
- cls.NODE_DIRS |
146
- cls.JAVA_DIRS |
147
- cls.C_CPP_DIRS |
148
- cls.DOTNET_DIRS |
149
- cls.BUILD_DIRS |
150
- cls.DEPENDENCY_DIRS |
151
- cls.BENCHMARK_DIRS |
152
- cls.EXAMPLE_DIRS |
153
- cls.TEMP_DIRS |
154
- cls.DOC_DIRS |
155
- cls.GENERATED_DIRS |
156
- cls.OTHER_DIRS |
157
- cls.JARVIS_DIRS
228
+ cls.VCS_DIRS
229
+ | cls.PYTHON_DIRS
230
+ | cls.PYTHON_VENV_DIRS
231
+ | cls.RUST_DIRS
232
+ | cls.GO_DIRS
233
+ | cls.NODE_DIRS
234
+ | cls.JAVA_DIRS
235
+ | cls.C_CPP_DIRS
236
+ | cls.DOTNET_DIRS
237
+ | cls.BUILD_DIRS
238
+ | cls.DEPENDENCY_DIRS
239
+ | cls.BENCHMARK_DIRS
240
+ | cls.EXAMPLE_DIRS
241
+ | cls.TEMP_DIRS
242
+ | cls.DOC_DIRS
243
+ | cls.GENERATED_DIRS
244
+ | cls.OTHER_DIRS
245
+ | cls.dirs
158
246
  )
159
-
247
+
160
248
  @classmethod
161
249
  def get_dependency_analysis_ignore_dirs(cls) -> Set[str]:
162
250
  """获取依赖分析时应该忽略的目录。
163
-
251
+
164
252
  Returns:
165
253
  依赖分析忽略目录集合
166
254
  """
167
255
  return (
168
- cls.VCS_DIRS |
169
- cls.BUILD_DIRS |
170
- cls.DEPENDENCY_DIRS |
171
- cls.TEST_DIRS |
172
- cls.BENCHMARK_DIRS |
173
- cls.EXAMPLE_DIRS |
174
- cls.TEMP_DIRS |
175
- cls.DOC_DIRS |
176
- cls.GENERATED_DIRS |
177
- cls.OTHER_DIRS |
178
- cls.JARVIS_DIRS
256
+ cls.VCS_DIRS
257
+ | cls.BUILD_DIRS
258
+ | cls.DEPENDENCY_DIRS
259
+ | cls.TEST_DIRS
260
+ | cls.BENCHMARK_DIRS
261
+ | cls.EXAMPLE_DIRS
262
+ | cls.TEMP_DIRS
263
+ | cls.DOC_DIRS
264
+ | cls.GENERATED_DIRS
265
+ | cls.OTHER_DIRS
266
+ | cls.dirs
179
267
  )
180
268
 
181
269
 
182
270
  class FileIgnoreFilter:
183
271
  """文件忽略过滤器。
184
-
272
+
185
273
  提供统一的文件/目录过滤逻辑。
186
274
  """
187
-
275
+
188
276
  def __init__(
189
277
  self,
190
278
  ignore_dirs: Optional[Set[str]] = None,
@@ -192,7 +280,7 @@ class FileIgnoreFilter:
192
280
  custom_filter: Optional[Callable[[str], bool]] = None,
193
281
  ):
194
282
  """初始化文件忽略过滤器。
195
-
283
+
196
284
  Args:
197
285
  ignore_dirs: 要忽略的目录名称集合,如果为None则使用默认集合
198
286
  ignore_hidden: 是否忽略隐藏目录(以 . 开头)
@@ -200,72 +288,72 @@ class FileIgnoreFilter:
200
288
  """
201
289
  if ignore_dirs is None:
202
290
  ignore_dirs = FileIgnorePatterns.get_code_analysis_ignore_dirs()
203
-
291
+
204
292
  self.ignore_dirs = ignore_dirs
205
293
  self.ignore_hidden = ignore_hidden
206
294
  self.custom_filter = custom_filter
207
-
295
+
208
296
  def should_ignore_dir(self, dir_name: str) -> bool:
209
297
  """判断是否应该忽略某个目录。
210
-
298
+
211
299
  Args:
212
300
  dir_name: 目录名称(不包含路径)
213
-
301
+
214
302
  Returns:
215
303
  如果应该忽略返回True,否则返回False
216
304
  """
217
305
  # 检查隐藏目录
218
- if self.ignore_hidden and dir_name.startswith('.'):
306
+ if self.ignore_hidden and dir_name.startswith("."):
219
307
  return True
220
-
308
+
221
309
  # 检查忽略目录集合
222
310
  if dir_name in self.ignore_dirs:
223
311
  return True
224
-
312
+
225
313
  # 检查自定义过滤器
226
314
  if self.custom_filter and self.custom_filter(dir_name):
227
315
  return True
228
-
316
+
229
317
  return False
230
-
318
+
231
319
  def should_ignore_path(self, path: str) -> bool:
232
320
  """判断是否应该忽略某个路径(文件或目录)。
233
-
321
+
234
322
  Args:
235
323
  path: 文件或目录路径
236
-
324
+
237
325
  Returns:
238
326
  如果应该忽略返回True,否则返回False
239
327
  """
240
328
  path_obj = Path(path)
241
-
329
+
242
330
  # 检查路径中的任何部分是否应该被忽略
243
331
  for part in path_obj.parts:
244
332
  if self.should_ignore_dir(part):
245
333
  return True
246
-
334
+
247
335
  return False
248
-
336
+
249
337
  def filter_dirs(self, dirs: List[str]) -> List[str]:
250
338
  """过滤目录列表,移除应该忽略的目录。
251
-
339
+
252
340
  这个方法可以直接用于 os.walk 的 dirs 列表修改:
253
341
  dirs[:] = filter.filter_dirs(dirs)
254
-
342
+
255
343
  Args:
256
344
  dirs: 目录名称列表
257
-
345
+
258
346
  Returns:
259
347
  过滤后的目录列表
260
348
  """
261
349
  return [d for d in dirs if not self.should_ignore_dir(d)]
262
-
350
+
263
351
  def filter_paths(self, paths: List[str]) -> List[str]:
264
352
  """过滤路径列表,移除应该忽略的路径。
265
-
353
+
266
354
  Args:
267
355
  paths: 路径列表
268
-
356
+
269
357
  Returns:
270
358
  过滤后的路径列表
271
359
  """
@@ -287,44 +375,42 @@ ALL_IGNORE_FILTER = FileIgnoreFilter(
287
375
 
288
376
  def should_ignore_dir(dir_name: str, ignore_dirs: Optional[Set[str]] = None) -> bool:
289
377
  """便捷函数:判断是否应该忽略目录。
290
-
378
+
291
379
  Args:
292
380
  dir_name: 目录名称
293
381
  ignore_dirs: 忽略目录集合,如果为None使用默认集合
294
-
382
+
295
383
  Returns:
296
384
  如果应该忽略返回True
297
385
  """
298
386
  if ignore_dirs is None:
299
387
  ignore_dirs = FileIgnorePatterns.get_code_analysis_ignore_dirs()
300
-
388
+
301
389
  # 隐藏目录
302
- if dir_name.startswith('.'):
390
+ if dir_name.startswith("."):
303
391
  return True
304
-
392
+
305
393
  # 忽略目录集合
306
394
  return dir_name in ignore_dirs
307
395
 
308
396
 
309
- def filter_walk_dirs(dirs: List[str], ignore_dirs: Optional[Set[str]] = None) -> List[str]:
397
+ def filter_walk_dirs(
398
+ dirs: List[str], ignore_dirs: Optional[Set[str]] = None
399
+ ) -> List[str]:
310
400
  """便捷函数:过滤 os.walk 的 dirs 列表。
311
-
401
+
312
402
  用法:
313
403
  for root, dirs, files in os.walk(path):
314
404
  dirs[:] = filter_walk_dirs(dirs)
315
-
405
+
316
406
  Args:
317
407
  dirs: os.walk 返回的目录列表
318
408
  ignore_dirs: 忽略目录集合,如果为None使用默认集合
319
-
409
+
320
410
  Returns:
321
411
  过滤后的目录列表
322
412
  """
323
413
  if ignore_dirs is None:
324
414
  ignore_dirs = FileIgnorePatterns.get_code_analysis_ignore_dirs()
325
-
326
- return [
327
- d for d in dirs
328
- if not (d.startswith('.') or d in ignore_dirs)
329
- ]
330
415
 
416
+ return [d for d in dirs if not (d.startswith(".") or d in ignore_dirs)]