← 返回
未分类 Key 中文

GitLab MR Code Review

Automated AI code review for GitLab Merge Requests via polling. Periodically checks for open MRs, reviews code diffs for security vulnerabilities, bugs, and...
通过轮询对 GitLab 合并请求进行自动化 AI 代码审查。定期检查开放的合并请求,审查代码差异中的安全漏洞、错误等。
gotoloops gotoloops 来源
未分类 clawhub v1.0.3 1 版本 100000 Key: 需要
★ 1
Stars
📥 383
下载
💾 1
安装
1
版本
#latest

概述

GitLab MR Code Review

Polling-based automated code review for GitLab MRs.

Architecture

Cron (*/2 * * * *) → gitlab-api.js list-mrs → skip reviewed → fetch diff → AI review → post comments/note
  • No webhook server — pure polling
  • Reviewed MRs tracked in {baseDir}/mr-reviewed.json

Setup

  1. Create {baseDir}/.env with your GitLab credentials:

```

GITLAB_URL=https://gitlab.example.com

GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx

```

The script auto-loads this file. Environment variables take precedence (won't be overwritten if already set).

  1. Test: node {baseDir}/scripts/gitlab-api.js get-version
  2. Install cron worker — see references/cron-setup.md for the full command

API Script Reference

node {baseDir}/scripts/gitlab-api.js get-version                              # Test connection
node {baseDir}/scripts/gitlab-api.js list-mrs                                 # List open MRs
node {baseDir}/scripts/gitlab-api.js list-mrs --project <project_path>        # Filter by project
node {baseDir}/scripts/gitlab-api.js get-changes <project_id> <mr_iid>        # Fetch MR diff
node {baseDir}/scripts/gitlab-api.js get-file <project_id> <branch> <path>    # Fetch file content
node {baseDir}/scripts/gitlab-api.js post-comment --file <json> <pid> <iid>   # Inline comment (use --file!)
node {baseDir}/scripts/gitlab-api.js post-note <project_id> <mr_iid> '<text>' # Summary note

post-comment JSON format

{
  "body": "**[Critical]** sql_injection\n\nRaw query with user input.",
  "position": {
    "base_sha": "abc123",
    "start_sha": "def456",
    "head_sha": "ghi789",
    "new_path": "src/db.js",
    "new_line": 42
  }
}

base_sha/start_sha/head_sha come from get-changes output's diff_refs.

Review Rules

  • Default: references/review-guidelines.md — severity levels, output format, what to skip
  • Per-project: Place .gitlab-review-prompt.md in the repo root; the worker auto-fetches it via get-file

Troubleshooting

ProblemFix
--------------
MRs not reviewedopenclaw cron list — is worker enabled?
API errorsnode {baseDir}/scripts/gitlab-api.js get-version
Duplicate reviewsCheck {baseDir}/mr-reviewed.json exists and is writable; ensure cron prompt has explicit "never re-review" rule at highest priority
Garbled commentsUse --file mode for post-comment (Windows PowerShell encoding)
Wrong line numbersnew_line must be the line number in the NEW version of the file

版本历史

共 1 个版本

  • v1.0.3 当前
    2026-05-03 09:18 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 77 📥 182,539
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 681 📥 329,691
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 197 📥 67,995