New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@diff-review-system/drs

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diff-review-system/drs

AI-powered code review bot for GitLab MRs and GitHub PRs using OpenCode SDK

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
304
-18.28%
Maintainers
1
Weekly downloads
 
Created
Source

DRS - AI Code Review Bot

An automated code review bot for GitLab Merge Requests and GitHub Pull Requests powered by OpenCode SDK and Claude AI.

Features

  • AI-Powered Reviews: Comprehensive code analysis using Claude's latest models
  • Specialized Agents: Security, quality, style, and performance review experts
  • Multi-Platform Support: Works with both GitLab MRs and GitHub PRs
  • Multiple Deployment Modes: CI/CD pipelines, webhook server, or local CLI
  • Customizable: Override agents with project-specific rules
  • Native Integration: Full API integration for both GitLab and GitHub

Quick Start

1. Install

npm install -g @diff-review-system/drs

2. Initialize Project

cd your-project
drs init

3. Configure Environment

# Copy example env file
cp .env.example .env

# Edit .env and set:
# - GITLAB_TOKEN: Your GitLab access token (for GitLab MRs)
# - GITHUB_TOKEN: Your GitHub access token (for GitHub PRs)
# - OPENCODE_SERVER: URL of your OpenCode instance (optional - will start in-process if not set)
# - ANTHROPIC_API_KEY: Your Anthropic API key for Claude

Note: OPENCODE_SERVER is optional. If not provided, DRS will automatically start an OpenCode server in-process. For production deployments or when sharing across multiple tools, you can run a dedicated OpenCode server and set the URL.

4. Review Local Changes

# Review unstaged changes
drs review-local

# Review staged changes
drs review-local --staged

# Use specific agents
drs review-local --agents security,quality

Deployment Modes

Mode 1: Local CLI

Review code locally before pushing:

# Review local changes
drs review-local

# Review specific GitLab MR
drs review-mr --project my-org/my-repo --mr 123 --post-comments

# Review specific GitHub PR
drs review-pr --owner octocat --repo hello-world --pr 456 --post-comments

Mode 2: GitLab CI/CD

Add to your .gitlab-ci.yml:

include:
  - remote: 'https://raw.githubusercontent.com/your-org/drs/main/templates/gitlab-ci.yml'

ai_review:
  extends: .drs_review
  variables:
    OPENCODE_SERVER: "http://opencode.internal:3000"

Mode 3: GitHub Actions

Note: GitHub Actions requires an OpenCode server to be accessible. You must either:

  • Set up a remote OpenCode server and configure OPENCODE_SERVER secret
  • Or install OpenCode CLI in the workflow (see below)

Add to .github/workflows/pr-review.yml:

name: DRS PR Review

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Build from source
        run: |
          npm ci
          npm run build

      - name: Review Pull Request
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          OPENCODE_SERVER: ${{ secrets.OPENCODE_SERVER }}  # Required: Set this in repository secrets
        run: |
          node dist/cli/index.js review-pr \
            --owner ${{ github.event.repository.owner.login }} \
            --repo ${{ github.event.repository.name }} \
            --pr ${{ github.event.pull_request.number }} \
            --post-comments

Required Secrets:

  • ANTHROPIC_API_KEY: Your Anthropic API key
  • OPENCODE_SERVER: URL of your OpenCode server (e.g., http://opencode.yourcompany.com:3000)

Mode 4: Webhook Server

Deploy as a standalone service:

# Using Docker Compose
cd examples
docker-compose up -d

# Configure webhooks:
# GitLab: http://your-server:8080/webhook/gitlab (Merge request events, Comments)
# GitHub: http://your-server:8080/webhook/github (Pull request events)

OpenCode Server Configuration

DRS supports two modes of OpenCode server operation:

In-Process Server (Default)

If OPENCODE_SERVER is not set, DRS will automatically start an OpenCode server within the same process:

# No server configuration needed
drs review-local

Pros:

  • Zero configuration required
  • Automatic startup/shutdown
  • Simpler deployment
  • Lower latency

Cons:

  • Server lifetime tied to CLI process
  • Cannot share across multiple tools
  • Uses process resources

Remote Server (Optional)

For production deployments or when sharing across multiple tools, run a dedicated OpenCode server:

# Set the server URL
export OPENCODE_SERVER=http://opencode.internal:3000
drs review-local

Pros:

  • Persistent server
  • Shared across multiple tools
  • Better for CI/CD pipelines
  • Can be scaled separately

Cons:

  • Requires separate service setup
  • Additional infrastructure

Architecture

DRS uses OpenCode SDK with markdown-based agent definitions:

.opencode/
├── agent/
│   ├── gitlab-reviewer.md       # GitLab MR orchestrator
│   ├── github-reviewer.md       # GitHub PR orchestrator
│   ├── local-reviewer.md        # Local diff reviewer
│   └── review/
│       ├── security.md          # Security specialist
│       ├── quality.md           # Code quality expert
│       ├── style.md             # Style checker
│       └── performance.md       # Performance analyzer
└── opencode.jsonc               # Configuration

Customization

Override Default Agents

Create custom agents in your project:

# Create custom security agent
mkdir -p .drs/agents
cat > .drs/agents/security.md << 'EOF'
---
description: Custom security reviewer
model: opencode/claude-sonnet-4-5
---

You are a security expert for this specific application.

## Project-Specific Rules
[Add your custom rules here]
EOF

Configure Review Behavior

Edit .drs/drs.config.yaml:

review:
  agents:
    - security
    - quality
  ignorePatterns:
    - "*.test.ts"
    - "*.md"

Review Agents

Security Agent

Focuses on:

  • OWASP Top 10 vulnerabilities
  • Injection attacks (SQL, XSS, Command)
  • Authentication/authorization issues
  • Sensitive data exposure
  • Security misconfigurations

Quality Agent

Reviews:

  • Design patterns and anti-patterns
  • Code complexity
  • DRY violations
  • Error handling
  • Code smells

Style Agent

Checks:

  • Naming conventions
  • Code formatting
  • Documentation quality
  • Type safety (TypeScript)
  • Unused code

Performance Agent

Analyzes:

  • Algorithmic complexity
  • Database query efficiency
  • Memory management
  • Caching opportunities
  • Concurrency issues

Configuration

Environment Variables

# Required (depending on platform)
GITLAB_TOKEN=glpat-xxx              # For GitLab MR reviews
GITHUB_TOKEN=ghp-xxx                # For GitHub PR reviews
ANTHROPIC_API_KEY=sk-ant-xxx        # For Claude AI

# Optional
OPENCODE_SERVER=http://localhost:3000  # Leave empty to start in-process server
GITLAB_URL=https://gitlab.com
REVIEW_AGENTS=security,quality,style,performance

Configuration Files

  • .drs/drs.config.yaml - DRS-specific configuration
  • .gitlab-review.yml - Alternative location
  • .opencode/opencode.jsonc - OpenCode configuration

Examples

See the examples/ directory for:

  • GitLab CI configuration
  • Docker Compose setup
  • Custom agent definitions
  • Configuration templates

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Development mode
npm run dev

Requirements

  • Node.js 20+
  • Anthropic API key (for Claude AI)
  • GitLab access token (for GitLab MR reviews)
  • GitHub access token (for GitHub PR reviews)
  • Git 2.30+ (for local mode)
  • OpenCode server instance (optional - will start in-process if not provided)

License

Apache-2.0

Documentation

  • Design Document - Original design using Claude Agent SDK
  • Architecture Document - OpenCode SDK architecture
  • OpenCode Documentation
  • GitLab API

Contributing

Contributions welcome! Please read the contributing guidelines first.

Support

Keywords

gitlab

FAQs

Package last updated on 09 Jan 2026

Related posts