vcode-analysis 0.9.0__tar.gz → 0.10.1__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 (105) hide show
  1. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/MANIFEST.in +1 -1
  2. {vcode_analysis-0.9.0/vcode_analysis.egg-info → vcode_analysis-0.10.1}/PKG-INFO +8 -6
  3. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/README.md +7 -5
  4. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/cli.py +129 -27
  5. vcode_analysis-0.10.1/core/json_utils.py +125 -0
  6. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/prompt_manager.py +6 -5
  7. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/pyproject.toml +4 -4
  8. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/vcode_analysis.egg-info}/PKG-INFO +8 -6
  9. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_analysis.egg-info/SOURCES.txt +13 -13
  10. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_analysis.egg-info/top_level.txt +0 -1
  11. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/server.py +1 -1
  12. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/tool_handler.py +2 -2
  13. vcode_analysis-0.9.0/core/json_utils.py +0 -65
  14. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/LICENSE +0 -0
  15. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/__init__.py +0 -0
  16. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/_tuning_context.py +0 -0
  17. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/architecture.py +0 -0
  18. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/code_review.py +0 -0
  19. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/context_builder.py +0 -0
  20. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/directory.py +0 -0
  21. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/documentation.py +0 -0
  22. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/knowledge_graph.py +0 -0
  23. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/security.py +0 -0
  24. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/analyzers/security_ast.py +0 -0
  25. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/__init__.py +0 -0
  26. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/analyzer.py +0 -0
  27. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/batch_analyzer.py +0 -0
  28. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/batch_planner.py +0 -0
  29. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/cache_manager.py +0 -0
  30. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/config.py +0 -0
  31. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/feedback_hub.py +0 -0
  32. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/git_handler.py +0 -0
  33. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/ignore.py +0 -0
  34. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/llm_client.py +0 -0
  35. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/metrics_store.py +0 -0
  36. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/__init__.py +0 -0
  37. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/architecture.md +0 -0
  38. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/batch_review.md +0 -0
  39. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/code_review.md +0 -0
  40. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/code_review_v2.md +0 -0
  41. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/commit_review.md +0 -0
  42. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/documentation/api.md +0 -0
  43. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/documentation/module.md +0 -0
  44. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/documentation/readme.md +0 -0
  45. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/mcp/code_review_checklist.md +0 -0
  46. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/mcp/mr_review_template.md +0 -0
  47. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/mcp/vuln_tuning_advisor.md +0 -0
  48. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1/core}/prompts/security_analysis.md +0 -0
  49. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/report_generator.py +0 -0
  50. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/core/token_estimator.py +0 -0
  51. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/2026-stage-highlights.md +0 -0
  52. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/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
  53. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/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
  54. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/USER_MANUAL.md +0 -0
  55. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/batch-cache-optimization.md +0 -0
  56. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/c-parser-design.md +0 -0
  57. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/code-knowledge-graph.md +0 -0
  58. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/critical-severity.md +0 -0
  59. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/expert-review-response-2026-07.md +0 -0
  60. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/kotlin-parser-design.md +0 -0
  61. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/prompt-externalization.md +0 -0
  62. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/three-year-roadmap.md +0 -0
  63. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/design/vcode-analysis-tool.md +0 -0
  64. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/review-scenarios.md +0 -0
  65. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/security-sharing-article.md +0 -0
  66. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/severity-standard.md +0 -0
  67. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs/superpowers/plans/2026-07-22-expert-review-response.md +0 -0
  68. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/docs//350/207/252/350/215/220/344/272/256/347/202/271/350/257/264/346/230/216.md" +0 -0
  69. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/__init__.py +0 -0
  70. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c/__init__.py +0 -0
  71. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c/ast_parser.py +0 -0
  72. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c/models.py +0 -0
  73. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c/patterns.py +0 -0
  74. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c/regex_parser.py +0 -0
  75. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/c_parser.py +0 -0
  76. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/java_parser.py +0 -0
  77. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/javascript_parser.py +0 -0
  78. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin/__init__.py +0 -0
  79. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin/ast_parser.py +0 -0
  80. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin/models.py +0 -0
  81. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin/patterns.py +0 -0
  82. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin/regex_parser.py +0 -0
  83. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/kotlin_parser.py +0 -0
  84. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/python_parser.py +0 -0
  85. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/sql_parser.py +0 -0
  86. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/parsers/typescript_parser.py +0 -0
  87. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/requirements.txt +0 -0
  88. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/setup.cfg +0 -0
  89. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_batch_operations.py +0 -0
  90. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_c_parser.py +0 -0
  91. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_context_builder_sql.py +0 -0
  92. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_kotlin_parser.py +0 -0
  93. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_mcp_tools.py +0 -0
  94. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_metrics_store.py +0 -0
  95. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_prompt_manager.py +0 -0
  96. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_report_generator.py +0 -0
  97. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_security_rules.py +0 -0
  98. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/tests/test_sql_parser.py +0 -0
  99. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_analysis.egg-info/dependency_links.txt +0 -0
  100. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_analysis.egg-info/entry_points.txt +0 -0
  101. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_analysis.egg-info/requires.txt +0 -0
  102. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/__init__.py +0 -0
  103. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/prompt_handler.py +0 -0
  104. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/resource_handler.py +0 -0
  105. {vcode_analysis-0.9.0 → vcode_analysis-0.10.1}/vcode_mcp/transports/__init__.py +0 -0
@@ -7,7 +7,7 @@ recursive-include docs *.md
7
7
  recursive-include analyzers *.py
8
8
  recursive-include core *.py
9
9
  recursive-include parsers *.py
10
- recursive-include prompts *.md
10
+ recursive-include core/prompts *.md
11
11
 
12
12
  global-exclude __pycache__
13
13
  global-exclude *.py[cod]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vcode-analysis
3
- Version: 0.9.0
3
+ Version: 0.10.1
4
4
  Summary: 基于大模型的智能代码分析工具,支持代码审查、文档生成、架构分析和安全扫描
5
5
  Author-email: Wellchang <2483808264@qq.com>
6
6
  License: MIT
@@ -115,14 +115,13 @@ vcode-analysis review ./src
115
115
  # 审查单个文件
116
116
  vcode-analysis review ./src/main.py
117
117
 
118
- # 指定输出格式
119
- vcode-analysis review ./src -o report.md -f markdown
120
- vcode-analysis review ./src -o report.html -f html
118
+ # 指定输出路径(默认生成 Markdown 报告,并自动生成同目录 .html 交互报告)
119
+ vcode-analysis review ./src -o report.md
121
120
 
122
121
  # 启用上下文增强(提升分析质量)
123
122
  vcode-analysis review ./src --context
124
123
 
125
- # 审查 Git 提交
124
+ # 审查 Git 提交(结果默认保存到 result/ 目录,-o 可指定路径)
126
125
  vcode-analysis review-commit abc1234
127
126
  ```
128
127
 
@@ -209,9 +208,12 @@ MCP Server 提供 8 个 Tool、3 个 Resource、3 个 Prompt:
209
208
  ### 6. Git 操作
210
209
 
211
210
  ```bash
212
- # 克隆并分析
211
+ # 克隆并分析(结果默认保存到 result/ 目录,-o 可指定路径)
213
212
  vcode-analysis clone https://github.com/user/repo.git
214
213
 
214
+ # 克隆后自动执行代码审查并保存报告
215
+ vcode-analysis clone https://github.com/user/repo.git --analyze
216
+
215
217
  # 批量克隆(从文件读取 URL 列表)
216
218
  vcode-analysis batch-clone repos.txt ./workspace
217
219
 
@@ -73,14 +73,13 @@ vcode-analysis review ./src
73
73
  # 审查单个文件
74
74
  vcode-analysis review ./src/main.py
75
75
 
76
- # 指定输出格式
77
- vcode-analysis review ./src -o report.md -f markdown
78
- vcode-analysis review ./src -o report.html -f html
76
+ # 指定输出路径(默认生成 Markdown 报告,并自动生成同目录 .html 交互报告)
77
+ vcode-analysis review ./src -o report.md
79
78
 
80
79
  # 启用上下文增强(提升分析质量)
81
80
  vcode-analysis review ./src --context
82
81
 
83
- # 审查 Git 提交
82
+ # 审查 Git 提交(结果默认保存到 result/ 目录,-o 可指定路径)
84
83
  vcode-analysis review-commit abc1234
85
84
  ```
86
85
 
@@ -167,9 +166,12 @@ MCP Server 提供 8 个 Tool、3 个 Resource、3 个 Prompt:
167
166
  ### 6. Git 操作
168
167
 
169
168
  ```bash
170
- # 克隆并分析
169
+ # 克隆并分析(结果默认保存到 result/ 目录,-o 可指定路径)
171
170
  vcode-analysis clone https://github.com/user/repo.git
172
171
 
172
+ # 克隆后自动执行代码审查并保存报告
173
+ vcode-analysis clone https://github.com/user/repo.git --analyze
174
+
173
175
  # 批量克隆(从文件读取 URL 列表)
174
176
  vcode-analysis batch-clone repos.txt ./workspace
175
177
 
@@ -70,6 +70,8 @@ Options:
70
70
  --limit <n> 限制数量 (feedback pending 使用)
71
71
  """
72
72
 
73
+ from __future__ import annotations
74
+
73
75
  import sys
74
76
  import json
75
77
  import time
@@ -111,7 +113,7 @@ from analyzers import (
111
113
  )
112
114
 
113
115
 
114
- __version__ = "0.9.0"
116
+ __version__ = "0.10.1"
115
117
 
116
118
 
117
119
  def _timestamp() -> str:
@@ -247,6 +249,17 @@ def get_default_output_path(target_path: str, prefix: str) -> Path:
247
249
  return result_dir / filename
248
250
 
249
251
 
252
+ def _save_output_to_file(args: dict, content: str, prefix: str) -> str:
253
+ """将输出内容保存到文件(未指定 --output 时生成默认路径并返回)。
254
+
255
+ 用于 metrics/feedback/clone 等命令:既保存到 result/ 目录,也保留终端输出。
256
+ """
257
+ output_path = args.get("--output") or str(get_default_output_path(".", prefix))
258
+ Path(output_path).write_text(content, encoding="utf-8")
259
+ _log(f"结果已保存到: {output_path}")
260
+ return output_path
261
+
262
+
250
263
  def format_review_result(result, output_format: str = "markdown") -> str:
251
264
  """格式化审查结果"""
252
265
  if output_format == "json":
@@ -517,7 +530,7 @@ def cmd_review(args: dict) -> int:
517
530
  reviewer.metrics_store = _metrics_store
518
531
  reviewer._current_run_id = _metrics_store.record_scan_run(ScanRun(
519
532
  repo_path=str(Path(target_path).resolve()),
520
- analyzer="code_review", tool_version="0.9.0",
533
+ analyzer="code_review", tool_version="0.10.1",
521
534
  ))
522
535
  _log_section("分析中(逐文件模式)")
523
536
  _log(f"开始分析 {total} 个文件...", "START")
@@ -627,7 +640,7 @@ def cmd_review(args: dict) -> int:
627
640
  _metrics_store = MetricsStore(_metrics_db)
628
641
  _run_id = _metrics_store.record_scan_run(ScanRun(
629
642
  repo_path=str(Path(target_path).resolve()),
630
- analyzer="code_review", tool_version="0.9.0",
643
+ analyzer="code_review", tool_version="0.10.1",
631
644
  ))
632
645
  for r in results:
633
646
  if r.success and r.issues:
@@ -761,6 +774,9 @@ def cmd_review_commit(args: dict) -> int:
761
774
  if target_path is True:
762
775
  target_path = "."
763
776
 
777
+ # 默认输出路径(未指定 --output 时自动生成)
778
+ output_file = args.get("--output") or str(get_default_output_path(target_path, "commit_review"))
779
+
764
780
  config = Config.create(
765
781
  config_file=args.get("--config"),
766
782
  prompts_dir=args.get("--prompts-dir"),
@@ -790,7 +806,7 @@ def cmd_review_commit(args: dict) -> int:
790
806
  _metrics_store = MetricsStore(_metrics_db)
791
807
  _run_id = _metrics_store.record_scan_run(ScanRun(
792
808
  repo_path=str(Path(target_path).resolve()),
793
- analyzer="code_review", tool_version="0.9.0",
809
+ analyzer="code_review", tool_version="0.10.1",
794
810
  ))
795
811
 
796
812
  with Analyzer(config) as analyzer:
@@ -829,6 +845,41 @@ def cmd_review_commit(args: dict) -> int:
829
845
  if result.summary:
830
846
  print(f"## 总结\n {result.summary}")
831
847
 
848
+ # 构建并保存报告文件
849
+ report_lines = [
850
+ "# 提交审查报告",
851
+ "",
852
+ f"- **提交**: {commit_hash}",
853
+ f"- **仓库路径**: {target_path}",
854
+ f"- **评分**: {result.score}/10",
855
+ f"- **审查时间**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}",
856
+ "",
857
+ ]
858
+ if result.issues:
859
+ report_lines.append("## 问题列表")
860
+ report_lines.append("")
861
+ for issue in result.issues:
862
+ sev = issue.get("severity", "low")
863
+ file_ = issue.get("file", "")
864
+ line = issue.get("line", 0)
865
+ desc = issue.get("description", "")
866
+ loc = f"{file_}:{line}" if file_ else f"行 {line}"
867
+ report_lines.append(f"- [{sev.upper()}] {issue.get('type', '')}: {desc} ({loc})")
868
+ report_lines.append("")
869
+ if result.suggestions:
870
+ report_lines.append("## 改进建议")
871
+ report_lines.append("")
872
+ for i, s in enumerate(result.suggestions, 1):
873
+ report_lines.append(f"{i}. {s}")
874
+ report_lines.append("")
875
+ if result.summary:
876
+ report_lines.append("## 总结")
877
+ report_lines.append("")
878
+ report_lines.append(result.summary)
879
+ report_lines.append("")
880
+ Path(output_file).write_text("\n".join(report_lines), encoding="utf-8")
881
+ _log(f"结果已保存到: {output_file}")
882
+
832
883
  _log_section("审查完成")
833
884
  _log(f"总耗时: {_format_duration(elapsed)}")
834
885
  if args.get("--metrics") and _metrics_db:
@@ -1004,12 +1055,14 @@ def cmd_metrics(args: dict) -> int:
1004
1055
  lines.append(f"| {item['key']} | {item['count']} |")
1005
1056
  content = "\n".join(lines)
1006
1057
 
1007
- if output_path:
1008
- with open(output_path, "w", encoding="utf-8") as f:
1009
- f.write(content)
1010
- _log(f"[OK] 指标报告已保存到 {output_path}")
1011
- else:
1012
- print(content)
1058
+ # 默认保存到文件(未指定 --output 时生成默认路径)
1059
+ if not output_path:
1060
+ output_path = str(get_default_output_path(".", "metrics"))
1061
+
1062
+ with open(output_path, "w", encoding="utf-8") as f:
1063
+ f.write(content)
1064
+ _log(f"[OK] 指标报告已保存到 {output_path}")
1065
+ print(content) # 同时保留终端输出
1013
1066
 
1014
1067
  return 0
1015
1068
 
@@ -1027,6 +1080,9 @@ def cmd_feedback(args: dict) -> int:
1027
1080
  )
1028
1081
  store = MetricsStore(Path(db_path))
1029
1082
 
1083
+ # 收集输出文本,统一在末尾保存到默认文件
1084
+ output_lines: list[str] = []
1085
+
1030
1086
  if args.get("pending"):
1031
1087
  limit = int(args.get("--limit") or 50)
1032
1088
  conn = store._get_conn()
@@ -1037,12 +1093,17 @@ def cmd_feedback(args: dict) -> int:
1037
1093
  ).fetchall()
1038
1094
  conn.close()
1039
1095
  if not rows:
1040
- print("无待复核 issue")
1096
+ output_lines.append("无待复核 issue")
1041
1097
  else:
1042
- print(f"{'ID':<12} {'规则':<25} {'严重度':<10} {'文件':<30} {'行号':<6}")
1043
- print("-" * 90)
1098
+ output_lines.append(f"{'ID':<12} {'规则':<25} {'严重度':<10} {'文件':<30} {'行号':<6}")
1099
+ output_lines.append("-" * 90)
1044
1100
  for r in rows:
1045
- print(f"{r[0][:10]:<12} {r[1] or '':<25} {r[2] or '':<10} {r[3]:<30} {r[4]:<6}")
1101
+ output_lines.append(
1102
+ f"{r[0][:10]:<12} {r[1] or '':<25} {r[2] or '':<10} {r[3]:<30} {r[4]:<6}"
1103
+ )
1104
+ output = "\n".join(output_lines)
1105
+ print(output)
1106
+ _save_output_to_file(args, output, "feedback")
1046
1107
  return 0
1047
1108
 
1048
1109
  if args.get("import"):
@@ -1056,7 +1117,9 @@ def cmd_feedback(args: dict) -> int:
1056
1117
  item.get("reviewer", "import"), item.get("note", ""),
1057
1118
  )
1058
1119
  count += 1
1059
- print(f"[OK] 已导入 {count} 条反馈")
1120
+ output = f"[OK] 已导入 {count} 条反馈"
1121
+ print(output)
1122
+ _save_output_to_file(args, output, "feedback")
1060
1123
  return 0
1061
1124
 
1062
1125
  # 单条标记
@@ -1067,7 +1130,9 @@ def cmd_feedback(args: dict) -> int:
1067
1130
  print("用法: vcode-analysis feedback <issue-id> --status <status> [--note <text>]")
1068
1131
  return 1
1069
1132
  store.update_issue_status(issue_id, status, "cli", note)
1070
- print(f"[OK] issue {issue_id[:10]} 状态已更新为 {status}")
1133
+ output = f"[OK] issue {issue_id[:10]} 状态已更新为 {status}"
1134
+ print(output)
1135
+ _save_output_to_file(args, output, "feedback")
1071
1136
  return 0
1072
1137
 
1073
1138
 
@@ -1277,7 +1342,7 @@ def cmd_security(args: dict) -> int:
1277
1342
  security.metrics_store = _metrics_store
1278
1343
  security._current_run_id = _metrics_store.record_scan_run(ScanRun(
1279
1344
  repo_path=str(Path(target_path).resolve()),
1280
- analyzer="security", tool_version="0.9.0",
1345
+ analyzer="security", tool_version="0.10.1",
1281
1346
  ))
1282
1347
  results = security.scan_project(target_path, deep=deep_scan, log_callback=_log)
1283
1348
  scan_time = time.time() - scan_start
@@ -1419,6 +1484,10 @@ def cmd_clone(args: dict) -> int:
1419
1484
  analyze = args.get("--analyze", False)
1420
1485
  output_file = args.get("--output")
1421
1486
 
1487
+ # 默认输出路径(未指定 --output 时生成)
1488
+ if not output_file:
1489
+ output_file = str(get_default_output_path(".", "clone"))
1490
+
1422
1491
  _log(f"克隆仓库: {repo_url}", "START")
1423
1492
 
1424
1493
  # 克隆仓库
@@ -1445,6 +1514,8 @@ def cmd_clone(args: dict) -> int:
1445
1514
  ("总耗时", _format_duration(total_time)),
1446
1515
  ],
1447
1516
  )
1517
+ # 默认保存克隆报告
1518
+ _save_output_to_file(args, f"# 克隆报告\n\n- 仓库: {repo_url}\n- 路径: {repo_path}\n- 耗时: {_format_duration(clone_time)}\n", "clone")
1448
1519
  return 0
1449
1520
 
1450
1521
  # 执行分析
@@ -1462,6 +1533,7 @@ def cmd_clone(args: dict) -> int:
1462
1533
  )
1463
1534
 
1464
1535
  analyze_start = time.time()
1536
+ review_results = []
1465
1537
  with Analyzer(config) as analyzer:
1466
1538
  # 代码审查
1467
1539
  _log_section("代码审查")
@@ -1473,6 +1545,7 @@ def cmd_clone(args: dict) -> int:
1473
1545
  for i, file_info in enumerate(file_infos[:5], 1): # 限制数量
1474
1546
  _log(f"[{i}] {file_info.relative_path}")
1475
1547
  result = reviewer.review_file(file_info)
1548
+ review_results.append((file_info, result))
1476
1549
  if result.success:
1477
1550
  _log(f" 评分: {result.score}/10")
1478
1551
  analyze_time = time.time() - analyze_start
@@ -1488,6 +1561,27 @@ def cmd_clone(args: dict) -> int:
1488
1561
  ],
1489
1562
  )
1490
1563
 
1564
+ # 保存分析报告
1565
+ report_lines = [
1566
+ "# 克隆分析报告",
1567
+ "",
1568
+ f"- **仓库**: {repo_url}",
1569
+ f"- **分支**: {branch or '默认分支'}",
1570
+ f"- **克隆路径**: {repo_path}",
1571
+ f"- **分析文件数**: {len(review_results)}",
1572
+ f"- **总耗时**: {_format_duration(total_time)}",
1573
+ "",
1574
+ "## 审查结果",
1575
+ "",
1576
+ ]
1577
+ for file_info, result in review_results:
1578
+ if result.success:
1579
+ report_lines.append(f"- {file_info.relative_path}: **{result.score}/10**")
1580
+ else:
1581
+ report_lines.append(f"- {file_info.relative_path}: 分析失败")
1582
+ report_lines.append("")
1583
+ _save_output_to_file(args, "\n".join(report_lines), "clone")
1584
+
1491
1585
  return 0
1492
1586
 
1493
1587
 
@@ -1500,6 +1594,10 @@ def cmd_batch_clone(args: dict) -> int:
1500
1594
  analyze = args.get("--analyze", False)
1501
1595
  output_file = args.get("--output")
1502
1596
 
1597
+ # 默认输出路径(未指定 --output 时生成)
1598
+ if not output_file:
1599
+ output_file = str(get_default_output_path(target_dir, "batch_clone"))
1600
+
1503
1601
  # 读取 URL 列表
1504
1602
  urls = []
1505
1603
  try:
@@ -1531,7 +1629,7 @@ def cmd_batch_clone(args: dict) -> int:
1531
1629
  target_dir=target_dir,
1532
1630
  parallel=parallel,
1533
1631
  max_workers=4,
1534
- progress_callback=progress_callback if not output_file else None,
1632
+ progress_callback=progress_callback if not args.get("--output") else None,
1535
1633
  )
1536
1634
  clone_time = time.time() - clone_start
1537
1635
 
@@ -1562,9 +1660,10 @@ def cmd_batch_clone(args: dict) -> int:
1562
1660
 
1563
1661
  report = "\n".join(lines)
1564
1662
 
1565
- if output_file:
1566
- Path(output_file).write_text(report, encoding="utf-8")
1567
- _log(f"报告已保存到: {output_file}")
1663
+ # 保存报告(默认已生成 output_file)
1664
+ Path(output_file).write_text(report, encoding="utf-8")
1665
+ _log(f"报告已保存到: {output_file}")
1666
+ print(report)
1568
1667
 
1569
1668
  # 如果需要分析
1570
1669
  analyze_time = 0
@@ -1594,6 +1693,10 @@ def cmd_batch_pull(args: dict) -> int:
1594
1693
  repos_str = args.get("--repos")
1595
1694
  output_file = args.get("--output")
1596
1695
 
1696
+ # 默认输出路径(未指定 --output 时生成)
1697
+ if not output_file:
1698
+ output_file = str(get_default_output_path(dir_path, "batch_pull"))
1699
+
1597
1700
  # 解析指定仓库
1598
1701
  repos = None
1599
1702
  if repos_str:
@@ -1626,12 +1729,11 @@ def cmd_batch_pull(args: dict) -> int:
1626
1729
  # 生成报告
1627
1730
  report = handler.generate_status_report(repo_infos)
1628
1731
 
1629
- if output_file:
1630
- Path(output_file).write_text(report, encoding="utf-8")
1631
- _log(f"报告已保存到: {output_file}")
1632
- else:
1633
- print("\n" + "=" * 50)
1634
- print(report)
1732
+ # 保存报告(默认已生成 output_file)
1733
+ Path(output_file).write_text(report, encoding="utf-8")
1734
+ _log(f"报告已保存到: {output_file}")
1735
+ print("\n" + "=" * 50)
1736
+ print(report)
1635
1737
 
1636
1738
  total_time = time.time() - start_time
1637
1739
  _log_section("批量拉取完成")
@@ -0,0 +1,125 @@
1
+ """JSON 解析工具函数
2
+
3
+ 处理 LLM 生成的 JSON 中常见的格式问题。
4
+ """
5
+
6
+ import re
7
+
8
+ # JSON 中合法的单字符转义(\uXXXX 单独处理)
9
+ _VALID_ESCAPES = frozenset('"\\/bfnrt')
10
+
11
+
12
+ def fix_invalid_escapes(json_str: str) -> str:
13
+ """修复 JSON 字符串字面量中非法的反斜杠转义序列。
14
+
15
+ LLM 常把 Windows 路径(如 C:\\Users\\...)或正则表达式(如 \\d+)原样写入
16
+ JSON 字符串,导致 json.loads 抛出 "Invalid \\escape"。本函数只处理字符串
17
+ 字面量内的非法转义,合法转义(\\" \\\\ \\/ \\b \\f \\n \\r \\t \\uXXXX)
18
+ 保持不变。
19
+
20
+ 处理规则:
21
+ - \\x(x 非合法转义字符,如 \\d、\\U、\\q)→ \\\\x,即把反斜杠转义为字面反斜杠
22
+ - \\ 后跟裸换行/回车 → 换成合法的 \\n / \\r 转义
23
+ - 字符串内末尾的裸 \\ → \\\\
24
+ - 非法 \\u(后 4 位非十六进制)→ \\\\u
25
+ """
26
+ out = []
27
+ i, n = 0, len(json_str)
28
+ in_string = False
29
+ while i < n:
30
+ ch = json_str[i]
31
+ if ch == '"':
32
+ in_string = not in_string
33
+ out.append(ch)
34
+ i += 1
35
+ elif ch == '\\' and in_string:
36
+ if i + 1 >= n:
37
+ out.append('\\\\')
38
+ i += 1
39
+ else:
40
+ nxt = json_str[i + 1]
41
+ if nxt == 'u':
42
+ hex_part = json_str[i + 2:i + 6]
43
+ if len(hex_part) == 4 and all(c in '0123456789abcdefABCDEF' for c in hex_part):
44
+ out.append('\\u')
45
+ out.append(hex_part)
46
+ i += 6
47
+ else:
48
+ out.append('\\\\u')
49
+ i += 2
50
+ elif nxt in _VALID_ESCAPES:
51
+ out.append(ch)
52
+ out.append(nxt)
53
+ i += 2
54
+ elif nxt in '\r\n':
55
+ out.append('\\\\')
56
+ out.append('n' if nxt == '\n' else 'r')
57
+ i += 2
58
+ else:
59
+ out.append('\\\\')
60
+ out.append(nxt)
61
+ i += 2
62
+ else:
63
+ out.append(ch)
64
+ i += 1
65
+ return ''.join(out)
66
+
67
+
68
+ def remove_trailing_commas(json_str: str) -> str:
69
+ """修复 LLM 生成 JSON 中的常见格式问题,使其兼容 Python json.loads()。
70
+
71
+ 处理:
72
+ 1. 移除字符串外的尾随逗号(如 {"a":1,}),不影响字符串内的逗号
73
+ 2. 修复字符串内非法的反斜杠转义(如 Windows 路径 C:\\Users\\...、正则 \\d+)
74
+ """
75
+ return re.sub(r',\s*([}\]])', r'\1', fix_invalid_escapes(json_str))
76
+
77
+
78
+ def parse_llm_json(content: str) -> dict:
79
+ """解析 LLM 返回的 JSON 内容,自动处理常见格式问题。
80
+
81
+ 处理步骤:
82
+ 1. 移除 markdown 代码块包裹
83
+ 2. 移除思考过程标签
84
+ 3. 移除尾随逗号
85
+ 4. 解析 JSON
86
+
87
+ Args:
88
+ content: LLM 返回的原始文本
89
+
90
+ Returns:
91
+ 解析后的字典
92
+
93
+ Raises:
94
+ json.JSONDecodeError: JSON 格式无法修复时抛出
95
+ """
96
+ import json
97
+
98
+ text = content.strip()
99
+
100
+ # 移除思考过程
101
+ thinking_patterns = [
102
+ r'Thinking Process:[\s\S]*?(?=\{)',
103
+ r'<think>[\s\S]*?</think>',
104
+ r'\[THOUGHT\][\s\S]*?\[/THOUGHT\]',
105
+ ]
106
+ for pattern in thinking_patterns:
107
+ match = re.search(pattern, text)
108
+ if match:
109
+ text = text[match.end():].strip()
110
+ break
111
+
112
+ # 提取 JSON
113
+ if "```json" in text:
114
+ text = text.split("```json")[1].split("```")[0].strip()
115
+ elif "```" in text:
116
+ parts = text.split("```")
117
+ if len(parts) >= 2:
118
+ text = parts[1].strip()
119
+ else:
120
+ json_match = re.search(r'\{[\s\S]*\}', text)
121
+ if json_match:
122
+ text = json_match.group(0)
123
+
124
+ # 移除尾随逗号后解析
125
+ return json.loads(remove_trailing_commas(text))
@@ -60,15 +60,16 @@ class PromptManager:
60
60
  def _resolve_builtin_dir(self) -> Optional[Path]:
61
61
  """定位内置 prompts 目录。
62
62
 
63
- 优先用 importlib.resources 读取已安装的 ``prompts`` 包(随 whl 打包),
64
- 失败则回退到源码仓库布局 core/../prompts(开发模式)。
63
+ 优先用 importlib.resources 读取已安装的 ``core.prompts`` 子包
64
+ (随 whl 打包,作为 core 包数据),失败则回退到开发模式布局
65
+ core/prompts(__file__ 同级子目录)。
65
66
  """
66
- # 已安装:prompts 作为顶层包随 whl 打包
67
+ # 已安装 / 开发模式:prompts 作为 core 的子包
67
68
  try:
68
69
  from importlib import resources
69
70
 
70
71
  try:
71
- files = resources.files("prompts")
72
+ files = resources.files("core.prompts")
72
73
  with resources.as_file(files) as f:
73
74
  if f.exists():
74
75
  return f
@@ -78,7 +79,7 @@ class PromptManager:
78
79
  pass
79
80
 
80
81
  # 回退:开发模式或源码仓库布局
81
- repo_path = Path(__file__).resolve().parent.parent / "prompts"
82
+ repo_path = Path(__file__).resolve().parent / "prompts"
82
83
  if repo_path.exists():
83
84
  return repo_path
84
85
  return None
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "vcode-analysis"
7
- version = "0.9.0"
7
+ version = "0.10.1"
8
8
  description = "基于大模型的智能代码分析工具,支持代码审查、文档生成、架构分析和安全扫描"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -70,11 +70,11 @@ py-modules = ["cli"]
70
70
 
71
71
  [tool.setuptools.packages.find]
72
72
  where = ["."]
73
- include = ["core*", "analyzers*", "parsers*", "vcode_mcp*", "prompts*"]
73
+ include = ["core*", "analyzers*", "parsers*", "vcode_mcp*"]
74
74
 
75
- # 将 prompts 包内的 Markdown 提示词打包进 whl(默认内置,可被用户目录覆盖)
75
+ # 将 core/prompts 子包内的 Markdown 提示词打包进 whl(默认内置,可被用户目录覆盖)
76
76
  [tool.setuptools.package-data]
77
- prompts = ["**/*.md"]
77
+ core = ["prompts/**/*.md"]
78
78
 
79
79
  [tool.black]
80
80
  line-length = 100
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vcode-analysis
3
- Version: 0.9.0
3
+ Version: 0.10.1
4
4
  Summary: 基于大模型的智能代码分析工具,支持代码审查、文档生成、架构分析和安全扫描
5
5
  Author-email: Wellchang <2483808264@qq.com>
6
6
  License: MIT
@@ -115,14 +115,13 @@ vcode-analysis review ./src
115
115
  # 审查单个文件
116
116
  vcode-analysis review ./src/main.py
117
117
 
118
- # 指定输出格式
119
- vcode-analysis review ./src -o report.md -f markdown
120
- vcode-analysis review ./src -o report.html -f html
118
+ # 指定输出路径(默认生成 Markdown 报告,并自动生成同目录 .html 交互报告)
119
+ vcode-analysis review ./src -o report.md
121
120
 
122
121
  # 启用上下文增强(提升分析质量)
123
122
  vcode-analysis review ./src --context
124
123
 
125
- # 审查 Git 提交
124
+ # 审查 Git 提交(结果默认保存到 result/ 目录,-o 可指定路径)
126
125
  vcode-analysis review-commit abc1234
127
126
  ```
128
127
 
@@ -209,9 +208,12 @@ MCP Server 提供 8 个 Tool、3 个 Resource、3 个 Prompt:
209
208
  ### 6. Git 操作
210
209
 
211
210
  ```bash
212
- # 克隆并分析
211
+ # 克隆并分析(结果默认保存到 result/ 目录,-o 可指定路径)
213
212
  vcode-analysis clone https://github.com/user/repo.git
214
213
 
214
+ # 克隆后自动执行代码审查并保存报告
215
+ vcode-analysis clone https://github.com/user/repo.git --analyze
216
+
215
217
  # 批量克隆(从文件读取 URL 列表)
216
218
  vcode-analysis batch-clone repos.txt ./workspace
217
219
 
@@ -29,6 +29,19 @@ core/metrics_store.py
29
29
  core/prompt_manager.py
30
30
  core/report_generator.py
31
31
  core/token_estimator.py
32
+ core/prompts/__init__.py
33
+ core/prompts/architecture.md
34
+ core/prompts/batch_review.md
35
+ core/prompts/code_review.md
36
+ core/prompts/code_review_v2.md
37
+ core/prompts/commit_review.md
38
+ core/prompts/security_analysis.md
39
+ core/prompts/documentation/api.md
40
+ core/prompts/documentation/module.md
41
+ core/prompts/documentation/readme.md
42
+ core/prompts/mcp/code_review_checklist.md
43
+ core/prompts/mcp/mr_review_template.md
44
+ core/prompts/mcp/vuln_tuning_advisor.md
32
45
  docs/2026-stage-highlights.md
33
46
  docs/PPT大纲-VCode_Analysis_智能代码分析工具分享.md
34
47
  docs/PPT生成提示词-VCode_Analysis分享.md
@@ -65,19 +78,6 @@ parsers/kotlin/ast_parser.py
65
78
  parsers/kotlin/models.py
66
79
  parsers/kotlin/patterns.py
67
80
  parsers/kotlin/regex_parser.py
68
- prompts/__init__.py
69
- prompts/architecture.md
70
- prompts/batch_review.md
71
- prompts/code_review.md
72
- prompts/code_review_v2.md
73
- prompts/commit_review.md
74
- prompts/security_analysis.md
75
- prompts/documentation/api.md
76
- prompts/documentation/module.md
77
- prompts/documentation/readme.md
78
- prompts/mcp/code_review_checklist.md
79
- prompts/mcp/mr_review_template.md
80
- prompts/mcp/vuln_tuning_advisor.md
81
81
  tests/test_batch_operations.py
82
82
  tests/test_c_parser.py
83
83
  tests/test_context_builder_sql.py
@@ -2,5 +2,4 @@ analyzers
2
2
  cli
3
3
  core
4
4
  parsers
5
- prompts
6
5
  vcode_mcp
@@ -8,7 +8,7 @@ from vcode_mcp.prompt_handler import PROMPTS
8
8
  from vcode_mcp.resource_handler import read_metrics_summary, read_report, read_rule
9
9
  from vcode_mcp.tool_handler import handle_tool
10
10
 
11
- mcp = MCPServer("vcode-analysis", version="0.9.0")
11
+ mcp = MCPServer("vcode-analysis", version="0.10.1")
12
12
 
13
13
 
14
14
  # ── Tools ────────────────────────────────────────────────────────
@@ -61,7 +61,7 @@ def _run_review(target: str, config, args: dict) -> list[dict]:
61
61
  reviewer.metrics_store = ms
62
62
  reviewer._current_run_id = ms.record_scan_run(ScanRun(
63
63
  repo_path=str(Path(target).resolve()), analyzer="code_review",
64
- tool_version="0.9.0",
64
+ tool_version="0.10.1",
65
65
  ))
66
66
 
67
67
  path = Path(target)
@@ -99,7 +99,7 @@ def _run_security(target: str, config, args: dict) -> list[dict]:
99
99
  scanner.metrics_store = ms
100
100
  scanner._current_run_id = ms.record_scan_run(ScanRun(
101
101
  repo_path=str(Path(target).resolve()), analyzer="security",
102
- tool_version="0.9.0",
102
+ tool_version="0.10.1",
103
103
  ))
104
104
 
105
105
  path = Path(target)
@@ -1,65 +0,0 @@
1
- """JSON 解析工具函数
2
-
3
- 处理 LLM 生成的 JSON 中常见的格式问题。
4
- """
5
-
6
- import re
7
-
8
-
9
- def remove_trailing_commas(json_str: str) -> str:
10
- """移除 JSON 字符串中的尾随逗号,使其兼容 Python json.loads()。
11
-
12
- LLM 生成的 JSON 常包含尾随逗号(如 {"a":1,}),Python 标准库不支持。
13
- 仅移除 ,} 和 ,] 模式中的多余逗号,不影响字符串内的逗号。
14
- """
15
- return re.sub(r',\s*([}\]])', r'\1', json_str)
16
-
17
-
18
- def parse_llm_json(content: str) -> dict:
19
- """解析 LLM 返回的 JSON 内容,自动处理常见格式问题。
20
-
21
- 处理步骤:
22
- 1. 移除 markdown 代码块包裹
23
- 2. 移除思考过程标签
24
- 3. 移除尾随逗号
25
- 4. 解析 JSON
26
-
27
- Args:
28
- content: LLM 返回的原始文本
29
-
30
- Returns:
31
- 解析后的字典
32
-
33
- Raises:
34
- json.JSONDecodeError: JSON 格式无法修复时抛出
35
- """
36
- import json
37
-
38
- text = content.strip()
39
-
40
- # 移除思考过程
41
- thinking_patterns = [
42
- r'Thinking Process:[\s\S]*?(?=\{)',
43
- r'<think>[\s\S]*?</think>',
44
- r'\[THOUGHT\][\s\S]*?\[/THOUGHT\]',
45
- ]
46
- for pattern in thinking_patterns:
47
- match = re.search(pattern, text)
48
- if match:
49
- text = text[match.end():].strip()
50
- break
51
-
52
- # 提取 JSON
53
- if "```json" in text:
54
- text = text.split("```json")[1].split("```")[0].strip()
55
- elif "```" in text:
56
- parts = text.split("```")
57
- if len(parts) >= 2:
58
- text = parts[1].strip()
59
- else:
60
- json_match = re.search(r'\{[\s\S]*\}', text)
61
- if json_match:
62
- text = json_match.group(0)
63
-
64
- # 移除尾随逗号后解析
65
- return json.loads(remove_trailing_commas(text))
File without changes