Metadata-Version: 2.4
Name: vcode-analysis
Version: 0.1.0
Summary: 基于大模型的智能代码分析工具，支持代码审查、文档生成、架构分析和安全扫描
Author-email: Wellchang <2483808264@qq.com>
License: MIT
Project-URL: Homepage, https://gitcode.com/wellchang/code-analysis
Project-URL: Repository, https://gitcode.com/wellchang/code-analysis
Project-URL: Documentation, https://gitcode.com/wellchang/code-analysis/blob/master/docs/USER_MANUAL.md
Project-URL: Bug Tracker, https://gitcode.com/wellchang/code-analysis/issues
Keywords: vcode-analysis,llm,code-review,documentation
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Security
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.25.0
Requires-Dist: docopt>=0.6.2
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: rich
Requires-Dist: rich>=13.0.0; extra == "rich"
Provides-Extra: parsers
Requires-Dist: javalang>=0.13.0; extra == "parsers"
Requires-Dist: pycparser>=2.21; extra == "parsers"
Dynamic: license-file

# Code Analysis - 智能代码分析工具

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

基于私有化部署大模型的智能代码分析工具，支持代码审查、文档生成、架构分析和安全扫描。

## ✨ 核心特性

| 特性 | 描述 |
|------|------|
| 🔍 **代码审查** | 自动分析代码质量，识别问题和安全漏洞 |
| 📝 **文档生成** | 自动生成模块文档、API 文档 |
| 🏗️ **架构分析** | 分析项目结构、依赖关系、代码度量 |
| 🔒 **安全扫描** | 检测常见安全漏洞和风险代码 |
| 📦 **批量操作** | 批量克隆、批量 Git 操作、多仓库管理 |
| 📂 **目录分析** | 扫描项目结构、识别技术栈 |
| 🌐 **多语言支持** | Python, Java, Kotlin, C, JavaScript, TypeScript 等 |
| 🤖 **私有化部署** | 兼容 OpenAI API 格式，支持任何私有化 LLM |

## 🚀 快速开始

### 安装

```bash
# 克隆项目
git clone https://gitcode.com/wellchang/code-analysis.git
cd code-analysis

# 安装依赖
pip install httpx docopt pyyaml
```

### 配置

```bash
# 初始化配置文件
python cli.py config --init

# 编辑配置文件
# ~/.code-analysis/config.yaml
```

### 使用

```bash
# 代码审查
python cli.py review ./src

# 架构分析
python cli.py arch ./src

# 安全扫描
python cli.py security ./src --deep

# 目录扫描
python cli.py scan-dir ./project
```

## 📖 命令概览

```bash
Commands:
    review          代码审查
    review-commit   审查指定提交
    doc             生成文档
    arch            架构分析
    security        安全漏洞扫描
    clone           克隆仓库并分析
    batch-clone     批量克隆仓库
    batch-pull      批量拉取更新
    git-status      查看多仓库状态
    scan-dir        扫描目录结构
    config          配置管理
```

## 🌍 支持的语言

| 语言 | 文件扩展名 | 解析模式 |
|------|------------|----------|
| Python | `.py` | AST |
| Java | `.java` | AST |
| Kotlin | `.kt`, `.kts` | 双模式 |
| C | `.c`, `.h` | 双模式 |
| JavaScript | `.js`, `.jsx` | 正则 |
| TypeScript | `.ts`, `.tsx` | 正则 |

## 📚 文档

- [完整使用手册](docs/USER_MANUAL.md)
- [Kotlin 解析器设计](docs/design/kotlin-parser-design.md)
- [C 解析器设计](docs/design/c-parser-design.md)

## 🔧 项目结构

```
code-analysis/
├── cli.py                 # CLI 入口
├── core/
│   ├── analyzer.py        # 分析引擎核心
│   ├── llm_client.py      # LLM 客户端
│   ├── git_handler.py     # Git 操作 + 批量操作
│   └── config.py          # 配置管理
├── analyzers/
│   ├── code_review.py     # 代码审查
│   ├── documentation.py   # 文档生成
│   ├── architecture.py    # 架构分析
│   ├── security.py        # 安全扫描
│   └── directory.py       # 目录分析
└── parsers/
    ├── python_parser.py   # Python AST 解析器
    ├── java_parser.py     # Java AST 解析器
    ├── kotlin_parser.py   # Kotlin 解析器（双模式）
    ├── c_parser.py        # C 语言解析器（双模式）
    └── ...
```

## 💡 使用示例

### 代码审查

```bash
# 审查整个项目
python cli.py review ./src --output report.md

# 审查最新提交
python cli.py review-commit HEAD
```

### 安全扫描

```bash
# 深度安全扫描
python cli.py security ./src --deep --output security.md
```

### 批量操作

```bash
# 批量克隆（从文件读取 URL 列表）
python cli.py batch-clone repos.txt ./projects --parallel

# 查看多仓库状态
python cli.py git-status ~/projects
```

## ⚙️ 配置示例

```yaml
# ~/.code-analysis/config.yaml
llm:
  base_url: http://localhost:8000/v1
  api_key: sk-your-api-key
  model: qwen3.5-35b-a3b
  temperature: 0.7
  max_tokens: 4096

analysis:
  max_file_size: 102400
  ignore_patterns:
    - node_modules
    - .git
    - __pycache__
    - venv
```

## 🤝 扩展开发

### 添加新的分析器

```python
from core import Analyzer

class CustomAnalyzer:
    def __init__(self, analyzer: Analyzer):
        self.analyzer = analyzer

    def analyze(self, file_path: str) -> dict:
        content = self.analyzer.read_file(file_path)
        prompt = f"分析以下代码：\n{content}"
        result = self.analyzer.llm_client.chat(prompt)
        return {"result": result}
```

### 使用解析器 API

```python
from parsers import KotlinASTParser, CASTParser

# Kotlin 解析
parser = KotlinASTParser()
result = parser.parse_file('Example.kt', mode='auto')

# C 解析
parser = CASTParser()
result = parser.parse_file('main.c', mode='fast')
```

## 📄 许可证

[MIT License](LICENSE)

## 🔗 链接

- [项目主页](https://gitcode.com/wellchang/code-analysis)
- [问题反馈](https://gitcode.com/wellchang/code-analysis/issues)
