Skip to main content

Multi-agent code review system using LangGraph

Project description

SCX Code Agent

多智能体代码审查系统,基于 LangGraph 构建。

安装

poetry install

配置

方式一:配置文件(推荐)

在项目根目录创建 .scx-code-agent.yaml

provider:
  name: deepseek
  model: deepseek-v4-flash
  api_key: ${LLM_API_KEY}
  base_url: https://api.deepseek.com

review:
  max_workers: 5
  skip_dirs:
    - node_modules
    - .venv
  custom_rules:
    general:
      - "本项目禁止使用 unittest,必须用 pytest"
    security:
      - "禁止在日志中打印用户手机号"

示例配置文件:

cp .scx-code-agent.yaml.example .scx-code-agent.yaml

方式二:环境变量

复制 .env.example.env 并配置:

cp .env.example .env

配置优先级

命令行参数 > 配置文件 > 环境变量 > 默认值

使用

全量审查

# 扫描当前目录
poetry run scx-code-agent --all

# 扫描指定路径
poetry run scx-code-agent --path src/

增量审查(PR)

poetry run scx-code-agent --diff origin/main

输出选项

# 输出到文件
poetry run scx-code-agent --path src/ --output dist/report.md

# JSON 格式输出
poetry run scx-code-agent --path src/ --format json --output dist/report.json

PR 评论(CI/CD)

在 GitHub Actions 等环境中,可将审查结果发表为 PR 评论:

# 设置 GitHub Token
export GITHUB_TOKEN=ghp_xxx

# 发表 PR 评论
poetry run scx-code-agent --diff origin/main --pr-comment

环境变量:

  • GITHUB_TOKEN: GitHub Personal Access Token(需要 repo:status 权限)
  • GITHUB_REPOSITORY: 仓库路径(可选,通常自动检测)

自定义审查规则

在配置文件的 review.custom_rules 中定义项目特定的审查规则,规则会被注入到对应专家的 prompt 中:

review:
  custom_rules:
    general:                        # 所有专家通用
      - "所有函数必须有类型注解"
    security:                       # 仅安全专家
      - "禁止在日志中打印用户手机号"
    architecture:                   # 仅架构专家
      - "Service 层禁止直接 import Controller"
    performance:                    # 仅性能专家
      - "数据库查询结果集超过 100 条必须分页"

general 中的规则对所有专家生效,其余仅对对应专家生效。规则支持 ${VAR} 环境变量替换。

架构

  • Coordinator: 文件收集与分发
  • Security Expert: 安全审查
  • Architecture Expert: 架构审查
  • Performance Expert: 性能审查
  • Reporter: 报告生成与格式化

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scx_code_agent-0.1.2.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scx_code_agent-0.1.2-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file scx_code_agent-0.1.2.tar.gz.

File metadata

  • Download URL: scx_code_agent-0.1.2.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/25.5.0

File hashes

Hashes for scx_code_agent-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4869c8a12a9df4addad52b72fab12a27176aad4cb913b1562686cacbf7be5c6b
MD5 8b6a5a556173822fd6cffc88ecdf9326
BLAKE2b-256 a4c4c2267f5c0a9b485125a365db174b40df881ddd69b1de674854f2f55cf1fa

See more details on using hashes here.

File details

Details for the file scx_code_agent-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scx_code_agent-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/25.5.0

File hashes

Hashes for scx_code_agent-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e30520921f545f65215bb726e1f245d1215e389583a1099ad6641cafa5a53e32
MD5 acf585765c0fbecc4d6d823d1bb0e004
BLAKE2b-256 672819bef359a6f25ab899eebda3c824bf59ab37765a126e85e2d61876f63458

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page