vcode-analysis 0.16.2__tar.gz → 0.20.0__tar.gz

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 (180) hide show
  1. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/MANIFEST.in +2 -0
  2. {vcode_analysis-0.16.2/vcode_analysis.egg-info → vcode_analysis-0.20.0}/PKG-INFO +10 -7
  3. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/README.md +9 -6
  4. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/__init__.py +41 -38
  5. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/code_review.py +95 -1
  6. vcode_analysis-0.20.0/analyzers/standard_analyzer.py +190 -0
  7. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli.py +37 -1
  8. vcode_analysis-0.20.0/cli_hook.py +518 -0
  9. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_repos.py +358 -358
  10. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_review.py +368 -368
  11. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_review_commit.py +146 -146
  12. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_security.py +341 -341
  13. vcode_analysis-0.20.0/cli_standard.py +297 -0
  14. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/__init__.py +12 -1
  15. vcode_analysis-0.20.0/core/code_standards.py +882 -0
  16. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/config.py +40 -0
  17. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/git_batch.py +46 -14
  18. vcode_analysis-0.20.0/core/git_comment.py +253 -0
  19. vcode_analysis-0.20.0/core/git_handler.py +646 -0
  20. vcode_analysis-0.20.0/core/hook_generator.py +238 -0
  21. vcode_analysis-0.20.0/core/prompts/staged_review.md +39 -0
  22. vcode_analysis-0.20.0/core/prompts/standard_review.md +39 -0
  23. vcode_analysis-0.20.0/docs/SOP.md +24 -0
  24. vcode_analysis-0.20.0/docs/design/web-git-commit-diff.md +71 -0
  25. vcode_analysis-0.20.0/docs/design/web-git-hooks.md +85 -0
  26. vcode_analysis-0.20.0/docs/design/web-whl-packaging.md +97 -0
  27. vcode_analysis-0.20.0/docs/features/TEMPLATE.md +20 -0
  28. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/pyproject.toml +6 -2
  29. vcode_analysis-0.20.0/tests/test_code_standards.py +297 -0
  30. vcode_analysis-0.20.0/tests/test_hook_generator.py +194 -0
  31. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_prompt_manager.py +303 -301
  32. vcode_analysis-0.20.0/tests/test_web_git_api.py +393 -0
  33. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0/vcode_analysis.egg-info}/PKG-INFO +10 -7
  34. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_analysis.egg-info/SOURCES.txt +30 -1
  35. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_analysis.egg-info/entry_points.txt +1 -0
  36. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_analysis.egg-info/top_level.txt +3 -0
  37. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/server.py +1 -1
  38. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/tool_handler.py +2 -2
  39. vcode_analysis-0.20.0/web/__init__.py +5 -0
  40. vcode_analysis-0.20.0/web/app.py +727 -0
  41. vcode_analysis-0.20.0/web/config_store.py +321 -0
  42. vcode_analysis-0.20.0/web/config_yaml.py +221 -0
  43. vcode_analysis-0.20.0/web/static/app.js +1964 -0
  44. vcode_analysis-0.20.0/web/static/index.html +524 -0
  45. vcode_analysis-0.20.0/web/static/style.css +617 -0
  46. vcode_analysis-0.20.0/web/static/vendor/echarts.min.js +45 -0
  47. vcode_analysis-0.20.0/web/task_manager.py +127 -0
  48. vcode_analysis-0.20.0/web/task_repo_tools.py +121 -0
  49. vcode_analysis-0.20.0/web/task_runners.py +259 -0
  50. vcode_analysis-0.20.0/web/task_utils.py +34 -0
  51. vcode_analysis-0.20.0/web/webhook_handler.py +461 -0
  52. vcode_analysis-0.16.2/core/git_handler.py +0 -363
  53. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/LICENSE +0 -0
  54. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/_tuning_context.py +0 -0
  55. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/architecture.py +0 -0
  56. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/architecture_detect.py +0 -0
  57. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/architecture_models.py +0 -0
  58. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/context_builder.py +0 -0
  59. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/context_deps.py +0 -0
  60. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/context_models.py +0 -0
  61. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/directory.py +0 -0
  62. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/directory_models.py +0 -0
  63. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/directory_report.py +0 -0
  64. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/directory_rules.py +0 -0
  65. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/directory_tech.py +0 -0
  66. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/documentation.py +0 -0
  67. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/dup_detect.py +0 -0
  68. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/dup_models.py +0 -0
  69. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/dup_suggest.py +0 -0
  70. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/duplication.py +0 -0
  71. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/kg_extract.py +0 -0
  72. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/kg_helpers.py +0 -0
  73. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/kg_models.py +0 -0
  74. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/kg_render.py +0 -0
  75. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/knowledge_graph.py +0 -0
  76. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security.py +0 -0
  77. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security_ast.py +0 -0
  78. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security_context.py +0 -0
  79. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security_rules.py +0 -0
  80. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security_rules_dynamic.py +0 -0
  81. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/analyzers/security_rules_native.py +0 -0
  82. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_analysis.py +0 -0
  83. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_dup.py +0 -0
  84. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/cli_utils.py +0 -0
  85. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/analyzer.py +0 -0
  86. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/batch_analyzer.py +0 -0
  87. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/batch_planner.py +0 -0
  88. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/cache_manager.py +0 -0
  89. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/feedback_hub.py +0 -0
  90. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/git_models.py +0 -0
  91. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/ignore.py +0 -0
  92. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/json_utils.py +0 -0
  93. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/llm_client.py +0 -0
  94. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/metrics_store.py +0 -0
  95. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompt_manager.py +0 -0
  96. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/__init__.py +0 -0
  97. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/architecture.md +0 -0
  98. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/batch_review.md +0 -0
  99. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/code_review.md +0 -0
  100. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/code_review_v2.md +0 -0
  101. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/commit_review.md +0 -0
  102. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/documentation/api.md +0 -0
  103. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/documentation/module.md +0 -0
  104. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/documentation/readme.md +0 -0
  105. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/duplication_refactor.md +0 -0
  106. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/mcp/code_review_checklist.md +0 -0
  107. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/mcp/mr_review_template.md +0 -0
  108. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/mcp/vuln_tuning_advisor.md +0 -0
  109. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/prompts/security_analysis.md +0 -0
  110. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/report_generator.py +0 -0
  111. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/report_html_template.py +0 -0
  112. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/report_stats.py +0 -0
  113. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/core/token_estimator.py +0 -0
  114. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/2026-stage-highlights.md +0 -0
  115. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/PPT/345/244/247/347/272/262-VCode_Analysis_/346/231/272/350/203/275/344/273/243/347/240/201/345/210/206/346/236/220/345/267/245/345/205/267/345/210/206/344/272/253.md" +0 -0
  116. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/PPT/347/224/237/346/210/220/346/217/220/347/244/272/350/257/215-VCode_Analysis/345/210/206/344/272/253.md" +0 -0
  117. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/USER_MANUAL.md +0 -0
  118. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/batch-cache-optimization.md +0 -0
  119. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/c-parser-design.md +0 -0
  120. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/code-knowledge-graph.md +0 -0
  121. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/critical-severity.md +0 -0
  122. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/expert-review-response-2026-07.md +0 -0
  123. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/kotlin-parser-design.md +0 -0
  124. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/prompt-externalization.md +0 -0
  125. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/three-year-roadmap.md +0 -0
  126. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/design/vcode-analysis-tool.md +0 -0
  127. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/review-scenarios.md +0 -0
  128. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/security-sharing-article.md +0 -0
  129. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/severity-standard.md +0 -0
  130. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs/superpowers/plans/2026-07-22-expert-review-response.md +0 -0
  131. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/docs//350/207/252/350/215/220/344/272/256/347/202/271/350/257/264/346/230/216.md" +0 -0
  132. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/__init__.py +0 -0
  133. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/__init__.py +0 -0
  134. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/ast_parser.py +0 -0
  135. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/models.py +0 -0
  136. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/patterns.py +0 -0
  137. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/regex_func_parser.py +0 -0
  138. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/regex_parser.py +0 -0
  139. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c/regex_type_parser.py +0 -0
  140. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/c_parser.py +0 -0
  141. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/java_parser.py +0 -0
  142. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/javascript_models.py +0 -0
  143. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/javascript_parser.py +0 -0
  144. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/javascript_regex_fallback.py +0 -0
  145. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/__init__.py +0 -0
  146. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/ast_class_parser.py +0 -0
  147. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/ast_member_parser.py +0 -0
  148. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/ast_parser.py +0 -0
  149. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/models.py +0 -0
  150. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/patterns.py +0 -0
  151. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/regex_class_parser.py +0 -0
  152. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/regex_helpers.py +0 -0
  153. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/regex_member_parser.py +0 -0
  154. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/regex_parser.py +0 -0
  155. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin/regex_type_parser.py +0 -0
  156. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/kotlin_parser.py +0 -0
  157. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/python_parser.py +0 -0
  158. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/sql_parser.py +0 -0
  159. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/parsers/typescript_parser.py +0 -0
  160. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/requirements.txt +0 -0
  161. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/setup.cfg +0 -0
  162. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_batch_operations.py +0 -0
  163. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_c_parser.py +0 -0
  164. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_code_review.py +0 -0
  165. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_context_builder_sql.py +0 -0
  166. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_duplication.py +0 -0
  167. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_incremental_report_writer.py +0 -0
  168. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_kotlin_parser.py +0 -0
  169. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_llm_client.py +0 -0
  170. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_mcp_tools.py +0 -0
  171. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_metrics_store.py +0 -0
  172. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_report_generator.py +0 -0
  173. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_security_rules.py +0 -0
  174. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/tests/test_sql_parser.py +0 -0
  175. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_analysis.egg-info/dependency_links.txt +0 -0
  176. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_analysis.egg-info/requires.txt +0 -0
  177. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/__init__.py +0 -0
  178. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/prompt_handler.py +0 -0
  179. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/resource_handler.py +0 -0
  180. {vcode_analysis-0.16.2 → vcode_analysis-0.20.0}/vcode_mcp/transports/__init__.py +0 -0
@@ -8,6 +8,8 @@ recursive-include analyzers *.py
8
8
  recursive-include core *.py
9
9
  recursive-include parsers *.py
10
10
  recursive-include core/prompts *.md
11
+ recursive-include web *.py
12
+ recursive-include web/static *
11
13
 
12
14
  global-exclude __pycache__
13
15
  global-exclude *.py[cod]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vcode-analysis
3
- Version: 0.16.2
3
+ Version: 0.20.0
4
4
  Summary: 基于大模型的智能代码分析工具,支持代码审查、文档生成、架构分析和安全扫描
5
5
  Author-email: Wellchang <2483808264@qq.com>
6
6
  License: MIT
@@ -248,16 +248,19 @@ vcode-analysis git-status ./workspace
248
248
 
249
249
  ## Web 操作台(可视化)
250
250
 
251
- 提供浏览器操作界面,无需记忆 CLI 命令即可启动分析、查看结果、标记反馈、管理配置与查看指标:
251
+ 提供浏览器操作界面,无需记忆 CLI 命令即可启动分析、查看结果、标记反馈、管理配置与查看指标。
252
+
253
+ 安装 whl 后可直接启动(FastAPI / Uvicorn 已作为运行时依赖自动安装):
252
254
 
253
255
  ```bash
254
- # 安装 Web 依赖(如已用 uv:uv add fastapi "uvicorn[standard]")
255
- pip install fastapi "uvicorn[standard]"
256
+ vcode-web # 默认 http://127.0.0.1:8970
257
+ vcode-web --host 0.0.0.0 --port 8970 # 局域网共享
258
+ ```
256
259
 
257
- # 启动(默认 http://127.0.0.1:8970)
258
- python web/app.py
260
+ 在源码仓库中也可直接运行:
259
261
 
260
- # 局域网共享:python web/app.py --host 0.0.0.0 --port 8970
262
+ ```bash
263
+ python web/app.py
261
264
  ```
262
265
 
263
266
  - **控制台**:选路径 + 分析类型 + 高级选项,一键运行,实时进度/日志
@@ -203,16 +203,19 @@ vcode-analysis git-status ./workspace
203
203
 
204
204
  ## Web 操作台(可视化)
205
205
 
206
- 提供浏览器操作界面,无需记忆 CLI 命令即可启动分析、查看结果、标记反馈、管理配置与查看指标:
206
+ 提供浏览器操作界面,无需记忆 CLI 命令即可启动分析、查看结果、标记反馈、管理配置与查看指标。
207
+
208
+ 安装 whl 后可直接启动(FastAPI / Uvicorn 已作为运行时依赖自动安装):
207
209
 
208
210
  ```bash
209
- # 安装 Web 依赖(如已用 uv:uv add fastapi "uvicorn[standard]")
210
- pip install fastapi "uvicorn[standard]"
211
+ vcode-web # 默认 http://127.0.0.1:8970
212
+ vcode-web --host 0.0.0.0 --port 8970 # 局域网共享
213
+ ```
211
214
 
212
- # 启动(默认 http://127.0.0.1:8970)
213
- python web/app.py
215
+ 在源码仓库中也可直接运行:
214
216
 
215
- # 局域网共享:python web/app.py --host 0.0.0.0 --port 8970
217
+ ```bash
218
+ python web/app.py
216
219
  ```
217
220
 
218
221
  - **控制台**:选路径 + 分析类型 + 高级选项,一键运行,实时进度/日志
@@ -1,38 +1,41 @@
1
- """分析器模块"""
2
-
3
- from .code_review import CodeReviewAnalyzer, CodeReviewResult
4
- from .documentation import DocumentationAnalyzer, DocumentationResult
5
- from .architecture import ArchitectureAnalyzer, ArchitectureResult, ModuleInfo, DependencyInfo
6
- from .security import SecurityAnalyzer, SecurityResult, SecurityIssue
7
- from .directory import DirectoryAnalyzer, DirectoryAnalysisResult, ProjectInfo
8
- from .context_builder import ContextBuilder, AnalysisContext
9
- from .knowledge_graph import KnowledgeGraphAnalyzer, KnowledgeGraph, KGEntity, KGRelation, KGBusinessRule
10
- from .duplication import DuplicationAnalyzer, DuplicationResult, DuplicateGroup, DupOccurrence
11
-
12
- __all__ = [
13
- "CodeReviewAnalyzer",
14
- "CodeReviewResult",
15
- "DocumentationAnalyzer",
16
- "DocumentationResult",
17
- "ArchitectureAnalyzer",
18
- "ArchitectureResult",
19
- "ModuleInfo",
20
- "DependencyInfo",
21
- "SecurityAnalyzer",
22
- "SecurityResult",
23
- "SecurityIssue",
24
- "DirectoryAnalyzer",
25
- "DirectoryAnalysisResult",
26
- "ProjectInfo",
27
- "ContextBuilder",
28
- "AnalysisContext",
29
- "KnowledgeGraphAnalyzer",
30
- "KnowledgeGraph",
31
- "KGEntity",
32
- "KGRelation",
33
- "KGBusinessRule",
34
- "DuplicationAnalyzer",
35
- "DuplicationResult",
36
- "DuplicateGroup",
37
- "DupOccurrence",
38
- ]
1
+ """分析器模块"""
2
+
3
+ from .code_review import CodeReviewAnalyzer, CodeReviewResult
4
+ from .documentation import DocumentationAnalyzer, DocumentationResult
5
+ from .architecture import ArchitectureAnalyzer, ArchitectureResult, ModuleInfo, DependencyInfo
6
+ from .security import SecurityAnalyzer, SecurityResult, SecurityIssue
7
+ from .directory import DirectoryAnalyzer, DirectoryAnalysisResult, ProjectInfo
8
+ from .context_builder import ContextBuilder, AnalysisContext
9
+ from .knowledge_graph import KnowledgeGraphAnalyzer, KnowledgeGraph, KGEntity, KGRelation, KGBusinessRule
10
+ from .duplication import DuplicationAnalyzer, DuplicationResult, DuplicateGroup, DupOccurrence
11
+ from .standard_analyzer import StandardAnalyzer, StandardReviewResult
12
+
13
+ __all__ = [
14
+ "CodeReviewAnalyzer",
15
+ "CodeReviewResult",
16
+ "DocumentationAnalyzer",
17
+ "DocumentationResult",
18
+ "ArchitectureAnalyzer",
19
+ "ArchitectureResult",
20
+ "ModuleInfo",
21
+ "DependencyInfo",
22
+ "SecurityAnalyzer",
23
+ "SecurityResult",
24
+ "SecurityIssue",
25
+ "DirectoryAnalyzer",
26
+ "DirectoryAnalysisResult",
27
+ "ProjectInfo",
28
+ "ContextBuilder",
29
+ "AnalysisContext",
30
+ "KnowledgeGraphAnalyzer",
31
+ "KnowledgeGraph",
32
+ "KGEntity",
33
+ "KGRelation",
34
+ "KGBusinessRule",
35
+ "DuplicationAnalyzer",
36
+ "DuplicationResult",
37
+ "DuplicateGroup",
38
+ "DupOccurrence",
39
+ "StandardAnalyzer",
40
+ "StandardReviewResult",
41
+ ]
@@ -72,10 +72,11 @@ def normalize_issues(issues: list, max_line: Optional[int] = None) -> list[dict]
72
72
  class CodeReviewAnalyzer:
73
73
  """代码审查分析器"""
74
74
 
75
- def __init__(self, analyzer: Analyzer, metrics_store=None):
75
+ def __init__(self, analyzer: Analyzer, metrics_store=None, standard_manager=None):
76
76
  self.analyzer = analyzer
77
77
  self.metrics_store = metrics_store
78
78
  self._current_run_id = None
79
+ self.standard_manager = standard_manager
79
80
 
80
81
  def review_file(self, file_info: FileInfo) -> CodeReviewResult:
81
82
  """审查单个文件"""
@@ -137,6 +138,99 @@ class CodeReviewAnalyzer:
137
138
 
138
139
  return self._parse_response(commit_hash, response)
139
140
 
141
+ def review_staged(self) -> CodeReviewResult:
142
+ """审查暂存区(staged)变更 — 用于 pre-commit hook
143
+
144
+ 审查 git diff --cached 的内容,在提交前拦截问题代码。
145
+ """
146
+ git = self.analyzer.git
147
+ if not git:
148
+ return self._failure_result("staged", "目标路径不是有效的 Git 仓库")
149
+
150
+ diffs = git.get_staged_diff()
151
+ if not diffs:
152
+ return CodeReviewResult(
153
+ file_path="staged",
154
+ score=10,
155
+ issues=[],
156
+ suggestions=[],
157
+ summary="暂存区无变更",
158
+ success=True,
159
+ )
160
+
161
+ staged_files = git.get_staged_files()
162
+
163
+ diff_content = ""
164
+ for diff in diffs:
165
+ diff_content += f"\n### {diff.file_path}\n"
166
+ diff_content += f"状态: {diff.status} (+{diff.additions}/-{diff.deletions})\n"
167
+ diff_content += f"```diff\n{diff.diff}\n```\n"
168
+
169
+ standards_context = ""
170
+ if self.standard_manager:
171
+ standards_context = self.standard_manager.format_for_prompt()
172
+
173
+ prompt = _get_pm().render(
174
+ "staged_review",
175
+ diff=diff_content,
176
+ staged_files="\n".join(staged_files),
177
+ standards_context=standards_context,
178
+ )
179
+ prompt = _get_pm().append_tuning_section(prompt, "staged_review")
180
+
181
+ try:
182
+ response = self.analyzer.llm.simple_chat(prompt)
183
+ except Exception as e:
184
+ return self._failure_result("staged", str(e), summary="LLM 调用失败")
185
+
186
+ return self._parse_response("staged", response)
187
+
188
+ def review_commit_range(self, range_spec: str) -> CodeReviewResult:
189
+ """审查提交范围内的累积变更 — 用于 pre-push hook
190
+
191
+ Args:
192
+ range_spec: Git 范围表达式,如 "remote_sha..local_sha"
193
+ """
194
+ git = self.analyzer.git
195
+ if not git:
196
+ return self._failure_result(range_spec, "目标路径不是有效的 Git 仓库")
197
+
198
+ diffs = git.get_commit_range_diff(range_spec)
199
+ if not diffs:
200
+ return CodeReviewResult(
201
+ file_path=range_spec,
202
+ score=10,
203
+ issues=[],
204
+ suggestions=[],
205
+ summary="提交范围内无变更",
206
+ success=True,
207
+ )
208
+
209
+ diff_content = ""
210
+ for diff in diffs:
211
+ diff_content += f"\n### {diff.file_path}\n"
212
+ diff_content += f"状态: {diff.status} (+{diff.additions}/-{diff.deletions})\n"
213
+ diff_content += f"```diff\n{diff.diff}\n```\n"
214
+
215
+ standards_context = ""
216
+ if self.standard_manager:
217
+ standards_context = self.standard_manager.format_for_prompt()
218
+
219
+ prompt = _get_pm().render(
220
+ "staged_review",
221
+ diff=diff_content,
222
+ staged_files=f"提交范围: {range_spec}",
223
+ standards_context=standards_context,
224
+ )
225
+ prompt = _get_pm().append_tuning_section(prompt, "staged_review")
226
+
227
+ try:
228
+ response = self.analyzer.llm.simple_chat(prompt)
229
+ except Exception as e:
230
+ return self._failure_result(range_spec, str(e), summary="LLM 调用失败")
231
+
232
+ return self._parse_response(range_spec, response)
233
+
140
234
  def _build_commit_schema_context(self, git, commit_hash: str, diffs: list) -> str:
141
235
  """解析本次提交涉及的所有 SQL/DDL 文件,生成 schema 摘要文本。
142
236
 
@@ -0,0 +1,190 @@
1
+ """代码规范分析器 — 基于规则检测 + LLM 确认的代码规范审查"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from dataclasses import dataclass, field
7
+ from typing import Optional
8
+
9
+ from core.code_standards import StandardManager, StandardRule
10
+ from core.json_utils import parse_llm_json
11
+
12
+ logger = logging.getLogger("standard_analyzer")
13
+
14
+
15
+ def _get_pm():
16
+ """延迟导入 PromptManager"""
17
+ from core.prompt_manager import get_prompt_manager
18
+ return get_prompt_manager()
19
+
20
+
21
+ @dataclass
22
+ class StandardReviewResult:
23
+ """规范审查结果"""
24
+ file_path: str
25
+ score: int = 10
26
+ violations: list[dict] = field(default_factory=list) # 基于规则检测的违规
27
+ llm_issues: list[dict] = field(default_factory=list) # LLM 审查发现的问题
28
+ mandatory_violations: list[dict] = field(default_factory=list) # 必须遵守的违规
29
+ advisory_violations: list[dict] = field(default_factory=list) # 建议遵守的违规
30
+ summary: str = ""
31
+ success: bool = True
32
+
33
+ @property
34
+ def has_mandatory_violations(self) -> bool:
35
+ return len(self.mandatory_violations) > 0
36
+
37
+ @property
38
+ def total_violations(self) -> int:
39
+ return len(self.violations) + len(self.llm_issues)
40
+
41
+
42
+ class StandardAnalyzer:
43
+ """代码规范分析器
44
+
45
+ 工作流程:
46
+ 1. 基于正则模式的规则检测(快速、确定性)
47
+ 2. LLM 审查(结合规范上下文,理解语义层面的违规)
48
+ 3. 合并结果,区分 mandatory / advisory
49
+ """
50
+
51
+ def __init__(self, standard_manager: StandardManager, analyzer=None):
52
+ """
53
+ Args:
54
+ standard_manager: 规范管理器
55
+ analyzer: Analyzer 实例(用于 LLM 调用),None 则仅做规则检测
56
+ """
57
+ self.manager = standard_manager
58
+ self.analyzer = analyzer
59
+
60
+ def check_content(
61
+ self,
62
+ content: str,
63
+ file_path: str = "",
64
+ language: Optional[str] = None,
65
+ ) -> StandardReviewResult:
66
+ """对代码内容执行规范检测(仅规则检测,不调用 LLM)
67
+
68
+ Args:
69
+ content: 代码内容
70
+ file_path: 文件路径(用于结果标注)
71
+ language: 代码语言
72
+
73
+ Returns:
74
+ StandardReviewResult
75
+ """
76
+ violations = self.manager.check_content(content, language)
77
+ mandatory = self.manager.get_mandatory_violations(violations)
78
+ advisory = [v for v in violations if v.get("severity") == "advisory"]
79
+
80
+ score = self._calculate_score(mandatory, advisory)
81
+
82
+ return StandardReviewResult(
83
+ file_path=file_path,
84
+ score=score,
85
+ violations=violations,
86
+ mandatory_violations=mandatory,
87
+ advisory_violations=advisory,
88
+ summary=self._build_summary(mandatory, advisory),
89
+ )
90
+
91
+ def check_file(self, file_path: str, language: Optional[str] = None) -> StandardReviewResult:
92
+ """对文件执行规范检测"""
93
+ try:
94
+ with open(file_path, "r", encoding="utf-8") as f:
95
+ content = f.read()
96
+ except Exception as e:
97
+ return StandardReviewResult(
98
+ file_path=file_path,
99
+ score=0,
100
+ summary=f"读取文件失败: {e}",
101
+ success=False,
102
+ )
103
+
104
+ return self.check_content(content, file_path, language)
105
+
106
+ def review_with_llm(
107
+ self,
108
+ diff_content: str,
109
+ staged_files: str,
110
+ language: Optional[str] = None,
111
+ ) -> StandardReviewResult:
112
+ """结合 LLM 进行规范审查(用于 staged/commit range 审查)
113
+
114
+ Args:
115
+ diff_content: Git diff 内容
116
+ staged_files: 变更文件列表文本
117
+ language: 主要语言(用于筛选适用规范)
118
+
119
+ Returns:
120
+ StandardReviewResult
121
+ """
122
+ # 1. 先执行基于规则的检测
123
+ rule_violations = self.manager.check_content(diff_content, language)
124
+ mandatory_rule = self.manager.get_mandatory_violations(rule_violations)
125
+ advisory_rule = [v for v in rule_violations if v.get("severity") == "advisory"]
126
+
127
+ # 2. 构建规范上下文并调用 LLM
128
+ standards_context = self.manager.format_for_prompt(language)
129
+
130
+ llm_issues = []
131
+ llm_summary = ""
132
+ if self.analyzer and standards_context:
133
+ try:
134
+ prompt = _get_pm().render(
135
+ "standard_review",
136
+ diff=diff_content,
137
+ staged_files=staged_files,
138
+ standards_context=standards_context,
139
+ )
140
+ response = self.analyzer.llm.simple_chat(prompt)
141
+ data = parse_llm_json(response)
142
+ llm_issues = data.get("issues", [])
143
+ llm_summary = data.get("summary", "")
144
+ except Exception as e:
145
+ logger.warning(f"LLM 规范审查失败: {e}")
146
+ llm_summary = f"LLM 审查失败: {e}"
147
+
148
+ # 3. 从 LLM issues 中提取规范违规
149
+ mandatory_llm = []
150
+ advisory_llm = []
151
+ for issue in llm_issues:
152
+ std_severity = issue.get("standard_severity", "")
153
+ if std_severity == "mandatory" or issue.get("severity") == "high":
154
+ mandatory_llm.append(issue)
155
+ else:
156
+ advisory_llm.append(issue)
157
+
158
+ # 4. 合并结果
159
+ all_mandatory = mandatory_rule + mandatory_llm
160
+ all_advisory = advisory_rule + advisory_llm
161
+
162
+ score = self._calculate_score(all_mandatory, all_advisory)
163
+
164
+ return StandardReviewResult(
165
+ file_path="staged",
166
+ score=score,
167
+ violations=rule_violations,
168
+ llm_issues=llm_issues,
169
+ mandatory_violations=all_mandatory,
170
+ advisory_violations=all_advisory,
171
+ summary=llm_summary or self._build_summary(all_mandatory, all_advisory),
172
+ )
173
+
174
+ def _calculate_score(self, mandatory: list, advisory: list) -> int:
175
+ """根据违规数量计算评分"""
176
+ score = 10
177
+ score -= len(mandatory) * 2
178
+ score -= len(advisory) * 0.5
179
+ return max(1, int(score))
180
+
181
+ def _build_summary(self, mandatory: list, advisory: list) -> str:
182
+ """生成审查摘要"""
183
+ parts = []
184
+ if mandatory:
185
+ parts.append(f"发现 {len(mandatory)} 个必须遵守的规范违规(需修复后方可提交)")
186
+ if advisory:
187
+ parts.append(f"发现 {len(advisory)} 个建议遵守的规范违规")
188
+ if not parts:
189
+ return "代码规范检查通过"
190
+ return ";".join(parts)
@@ -4,6 +4,12 @@
4
4
  Usage:
5
5
  vcode-analysis review <path> [--max-tokens <n>] [-w <n>] [--no-cache] [--no-batch] [--context] [--metrics] [options]
6
6
  vcode-analysis review-commit <commit> [--path <path>] [--metrics] [options]
7
+ vcode-analysis review-staged [--path <path>] [--gate] [--output <file>] [options]
8
+ vcode-analysis review-commit-range <range> [--path <path>] [--gate] [--output <file>] [options]
9
+ vcode-analysis hook install --type <pre-commit|pre-push> [--path <path>] [--force] [options]
10
+ vcode-analysis hook uninstall --type <pre-commit|pre-push> [--path <path>] [options]
11
+ vcode-analysis hook list [--path <path>] [options]
12
+ vcode-analysis webhook [--port <port>] [--host <host>] [--secret <token>] [--comment-platform <platform>] [--comment-api-url <url>] [--comment-token <token>] [options]
7
13
  vcode-analysis doc <path> [--type <type>] [--output <file>] [options]
8
14
  vcode-analysis arch <path> [--output <file>] [options]
9
15
  vcode-analysis security <path> [--deep] [--metrics] [--workers <n>] [--output <file>] [options]
@@ -19,11 +25,19 @@ Usage:
19
25
  vcode-analysis feedback pending [--limit <n>] [options]
20
26
  vcode-analysis feedback import <file> [options]
21
27
  vcode-analysis config [--show] [--init] [options]
28
+ vcode-analysis standard list [--source <name>] [--category <name>] [--severity <level>] [--language <lang>] [options]
29
+ vcode-analysis standard check <path> [--gate] [--output <file>] [options]
30
+ vcode-analysis standard init [--output <file>] [options]
31
+ vcode-analysis standard stats [options]
22
32
  vcode-analysis --version
23
33
 
24
34
  Commands:
25
35
  review 代码审查
26
36
  review-commit 审查指定提交
37
+ review-staged 审查暂存区变更(pre-commit hook 用)
38
+ review-commit-range 审查提交范围(pre-push hook 用)
39
+ hook Git hook 管理(install/uninstall/list)
40
+ webhook 启动 Webhook 服务(接收 Git 平台事件)
27
41
  doc 生成文档
28
42
  arch 架构分析
29
43
  security 安全漏洞扫描
@@ -37,6 +51,7 @@ Commands:
37
51
  metrics 查询量化指标
38
52
  feedback 反馈管理(标记误报/确认/导入)
39
53
  config 配置管理
54
+ standard 代码开发规范管理(list/check/init/stats)
40
55
 
41
56
  Options:
42
57
  -c, --config <file> 配置文件路径
@@ -77,6 +92,14 @@ Options:
77
92
  --status <status> 问题状态 (feedback 使用: confirmed/false_positive/fixed/wontfix)
78
93
  --note <text> 备注 (feedback 使用)
79
94
  --limit <n> 限制数量 (feedback pending 使用)
95
+ --gate 启用门禁模式(审查不通过时返回非零退出码)
96
+ --force 强制覆盖已存在的 hook
97
+ --port <n> Webhook 服务监听端口 (默认: 8765)
98
+ --host <host> Webhook 服务监听地址 (默认: 0.0.0.0)
99
+ --secret <token> Webhook 验证密钥
100
+ --comment-platform <p> 评论回写平台 (gitlab/gitea/atomgit/generic)
101
+ --comment-api-url <url> 评论回写 API 地址
102
+ --comment-token <tok> 评论回写认证 Token
80
103
  """
81
104
 
82
105
 
@@ -112,13 +135,15 @@ import cli_utils
112
135
  from cli_utils import IncrementalReportWriter # noqa: F401 (re-export,兼容既有引用)
113
136
  from cli_review import cmd_review
114
137
  from cli_review_commit import cmd_review_commit
138
+ from cli_hook import cmd_hook, cmd_review_staged, cmd_review_commit_range
115
139
  from cli_analysis import cmd_doc, cmd_arch, cmd_kg, cmd_scan_dir
116
140
  from cli_security import cmd_security, cmd_metrics, cmd_feedback
117
141
  from cli_repos import cmd_clone, cmd_batch_clone, cmd_batch_pull, cmd_git_status
118
142
  from cli_dup import cmd_dup
143
+ from cli_standard import cmd_standard
119
144
 
120
145
 
121
- __version__ = "0.16.2"
146
+ __version__ = "0.20.0"
122
147
 
123
148
 
124
149
  def cmd_config(args: dict) -> int:
@@ -284,6 +309,15 @@ def main():
284
309
  return cmd_review(args)
285
310
  elif args.get("review-commit"):
286
311
  return cmd_review_commit(args)
312
+ elif args.get("review-staged"):
313
+ return cmd_review_staged(args)
314
+ elif args.get("review-commit-range"):
315
+ return cmd_review_commit_range(args)
316
+ elif args.get("hook"):
317
+ return cmd_hook(args)
318
+ elif args.get("webhook"):
319
+ from cli_hook import cmd_webhook
320
+ return cmd_webhook(args)
287
321
  elif args.get("doc"):
288
322
  return cmd_doc(args)
289
323
  elif args.get("arch"):
@@ -310,6 +344,8 @@ def main():
310
344
  return cmd_feedback(args)
311
345
  elif args.get("config"):
312
346
  return cmd_config(args)
347
+ elif args.get("standard"):
348
+ return cmd_standard(args)
313
349
 
314
350
  return 0
315
351