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.3.tar.gz (26.5 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.3-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scx_code_agent-0.1.3.tar.gz
  • Upload date:
  • Size: 26.5 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.3.tar.gz
Algorithm Hash digest
SHA256 be24509b5091fb3ad0be71630a27c39813d4da7555bf1dfadff694beb573a795
MD5 becf134ff82707359d376607a1f973b1
BLAKE2b-256 b658ab41eb9a7000358d34a6b44987e3926a5b3a1f49c88007dde1cc419e0b0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scx_code_agent-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 34.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 be496a2b13068860e1c2d167dac01c61b861470417b9d9e7dc235e4dfbae1d75
MD5 741c0748e69ac6b98de8148fecd3f324
BLAKE2b-256 78841a086ece01d869621e83c68217734be14d5e588c8521921f5a8cce721a37

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