rs-guard 1.0.0

AI-powered code review CLI for GitHub PRs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# Installation Guide

Complete guide for installing and running rs-guard locally or in GitHub Actions.

---

## Table of Contents

- [Quick Start]#quick-start
- [Installation Methods]#installation-methods
  - [Option 1: Pre-built Binary (Recommended)]#option-1-pre-built-binary-recommended
  - [Option 2: Build from Source]#option-2-build-from-source
  - [Option 3: Cargo Install]#option-3-cargo-install
- [Platform-Specific Instructions]#platform-specific-instructions
  - [Linux]#linux
  - [macOS]#macos
  - [Windows]#windows
- [Verification]#verification
- [GitHub Actions Setup]#github-actions-setup
- [Local Testing Setup]#local-testing-setup
- [Troubleshooting Installation]#troubleshooting-installation

---

## Quick Start

**For immediate testing:**

```bash
# Download the latest binary
curl -L -o rs-guard \
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard
chmod +x rs-guard

# Set your API key
export DEEPSEEK_API_KEY="your-api-key"

# Test locally
./rs-guard --help
```

---

## Installation Methods

### Option 1: Pre-built Binary (Recommended)

Fastest method — no compilation required. Downloads a ready-to-run binary.

#### Linux (x86_64)

```bash
curl -L -o rs-guard \
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-x86_64-unknown-linux-gnu
chmod +x rs-guard
sudo mv rs-guard /usr/local/bin/

# Verify
rs-guard --version
```

#### Linux (ARM64)

```bash
curl -L -o rs-guard \
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-aarch64-unknown-linux-gnu
chmod +x rs-guard
sudo mv rs-guard /usr/local/bin/
```

#### macOS (Intel x86_64)

```bash
curl -L -o rs-guard \
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-x86_64-apple-darwin
chmod +x rs-guard
sudo mv rs-guard /usr/local/bin/
```

#### macOS (Apple Silicon M1/M2/M3/M4/M5)

```bash
curl -L -o rs-guard \
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-aarch64-apple-darwin
chmod +x rs-guard
sudo mv rs-guard /usr/local/bin/
```

#### Windows (x86_64)

**PowerShell:**

```powershell
Invoke-WebRequest -Uri "https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-x86_64-pc-windows-msvc.exe" -OutFile "rs-guard.exe"
Move-Item "rs-guard.exe" "C:\Program Files\rs-guard\"

# Add to PATH if needed
$env:Path += ";C:\Program Files\rs-guard"
```

**Command Prompt:**

```cmd
curl -L -o rs-guard.exe ^
  https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-x86_64-pc-windows-msvc.exe
move rs-guard.exe "C:\Program Files\rs-guard\"
```

---

### Option 2: Build from Source

Requires Rust toolchain. Use this if you need a custom build or want to contribute.

#### Prerequisites

Install Rust (requires version 1.82+):

```bash
# Linux/macOS
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

# Verify installation
rustc --version  # Should be 1.82 or higher
cargo --version
```

#### Build Steps

```bash
# Clone the repository
git clone https://github.com/nebulaideas/rs-guard.git
cd rs-guard

# Checkout the desired branch/tag
git checkout main  # or specific version tag

# Build release binary (optimized)
cargo build --release

# Binary location:
# Linux/macOS: ./target/release/rs-guard
# Windows: .\target\release\rs-guard.exe

# Optional: Install to system path
cargo install --path .
```

#### Build Time Expectations

- **First build:** 2-5 minutes (downloads and compiles all dependencies)
- **Subsequent builds:** 30-60 seconds (incremental compilation)
- **Release build:** Additional 1-2 minutes for optimizations

---

### Option 3: Cargo Install

Simplest method if you already have Rust installed. Downloads and builds from crates.io.

```bash
# Install latest published version
cargo install rs-guard

# Binary will be installed to ~/.cargo/bin/rs-guard
# Ensure ~/.cargo/bin is in your PATH
```

**Note:** This requires the crate to be published on crates.io first. Before publication, use "Build from Source" instead.

---

## Platform-Specific Instructions

### Linux

#### Add to PATH (if not using sudo)

```bash
# Add to your shell config (~/.bashrc, ~/.zshrc, etc.)
export PATH="$HOME/.cargo/bin:$PATH"

# Or if you downloaded the binary manually
export PATH="$HOME/bin:$PATH"
```

#### System Dependencies

No additional dependencies required. The binary is statically linked.

### macOS

#### Gatekeeper Warning

If you see "rs-guard cannot be opened because the developer cannot be verified":

```bash
# Option 1: Remove quarantine attribute
xattr -d com.apple.quarantine /usr/local/bin/rs-guard

# Option 2: Use sudo to move to a trusted location
sudo mv ~/Downloads/rs-guard /usr/local/bin/
```

#### Apple Silicon Performance

Native ARM64 binaries run 20-30% faster on M1/M2/M3/M4/M5 chips compared to Rosetta translation.

### Windows

#### Add to PATH

1. Open **System Properties****Environment Variables**
2. Under **User variables**, select `Path`**Edit**
3. Add: `C:\Users\<YourUsername>\.cargo\bin`
4. Click **OK** and restart your terminal

Alternatively, add to PowerShell profile (`$PROFILE`):

```powershell
$env:Path += ";$env:USERPROFILE\.cargo\bin"
```

#### Windows Defender

If flagged as unknown software:

- Right-click → **Properties** → Check **Unblock**
- Or add an exclusion in Windows Security settings

---

## Verification

After installation, verify the binary works:

```bash
# Check version
rs-guard --version

# Display help
rs-guard --help

# Test with a simple command (should show help, not error)
rs-guard
```

Expected output:

```
rs-guard 0.6.0
AI-powered code review CLI for GitHub PRs

Usage: rs-guard [OPTIONS]
...
```

---

## GitHub Actions Setup

### Minimal Workflow

Create `.github/workflows/ai-review.yml`:

```yaml
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

permissions:
  pull-requests: write
  contents: read

jobs:
  review:
    runs-on: ubuntu-latest
    if: ${{ !github.event.pull_request.head.repo.fork }}

    steps:
      - uses: actions/checkout@v4

      - name: Download rs-guard
        run: |
          curl -L -o rs-guard \
            https://github.com/nebulaideas/rs-guard/releases/latest/download/rs-guard-x86_64-unknown-linux-gnu
          chmod +x rs-guard

      - name: AI Code Review
        run: ./rs-guard
        env:
          DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          REPO_FULL_NAME: ${{ github.repository }}
```

### With Configuration File

If using `.reviewer.toml`:

```yaml
- name: AI Code Review
  run: ./rs-guard --config .reviewer.toml
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    PR_NUMBER: ${{ github.event.pull_request.number }}
    REPO_FULL_NAME: ${{ github.repository }}
```

### Upload Review Artifacts

```yaml
- name: Upload review result
  uses: actions/upload-artifact@v4
  if: always()
  with:
    name: review-result
    path: |
      review-result.txt
      rs-guard-metrics.json
```

### Required Secrets

Configure these in your repository settings (**Settings** → **Secrets and variables** → **Actions**):

| Secret             | Description                                       |
| ------------------ | ------------------------------------------------- |
| `DEEPSEEK_API_KEY` | Your DeepSeek API key (or other provider)         |
| `GITHUB_TOKEN`     | Auto-provided by GitHub Actions (no setup needed) |

---

## Local Testing Setup

### Step 1: Install the Binary

Choose one of the installation methods above. For development, "Build from Source" is recommended.

### Step 2: Configure API Keys

```bash
# Linux/macOS
export DEEPSEEK_API_KEY="your-api-key"

# Windows (PowerShell)
$env:DEEPSEEK_API_KEY="your-api-key"

# Windows (Command Prompt)
set DEEPSEEK_API_KEY=your-api-key
```

**Optional:** Add to your shell profile for persistence:

```bash
# ~/.bashrc or ~/.zshrc
export DEEPSEEK_API_KEY="your-api-key"
```

### Step 3: Test in a Repository

```bash
# Navigate to a git repository
cd /path/to/your/project

# Stage some changes
git add .

# Run rs-guard
rs-guard

# Or with explicit provider
rs-guard --provider deepseek --model deepseek-v4-flash
```

### Step 4: Set Up Pre-commit Hook (Optional)

```bash
# Copy the example hook
cp examples/local-review/pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

# Now commits will be reviewed automatically
git commit -m "feat: add new feature"
```

To bypass the hook when needed:

```bash
git commit --no-verify -m "quick fix"
```

### Step 5: Review a Diff File

```bash
# Generate a diff
git diff > my-changes.diff

# Review the diff file
rs-guard --diff-file my-changes.diff
```

---

## Troubleshooting Installation

### "Command not found: rs-guard"

**Cause:** Binary not in PATH.

**Solution:**

```bash
# Find where rs-guard was installed
which rs-guard  # Linux/macOS
where rs-guard  # Windows

# If not found, check default locations:
ls ~/.cargo/bin/rs-guard
ls /usr/local/bin/rs-guard

# Add to PATH
export PATH="$HOME/.cargo/bin:$PATH"
```

### "Permission denied"

**Cause:** Binary lacks execute permission.

**Solution:**

```bash
chmod +x rs-guard
```

### "Binary incompatible" or wrong architecture

**Cause:** Downloaded binary doesn't match your system architecture.

**Solution:** Check your architecture:

```bash
# Linux/macOS
uname -m

# Expected outputs:
# x86_64 = Intel/AMD 64-bit
# aarch64 = ARM 64-bit (M1/M2/M3/M4/M5, Raspberry Pi, etc.)
```

Download the matching binary variant.

### Build fails with "Rust version too old"

**Cause:** Rust version < 1.82.

**Solution:**

```bash
rustup update stable
rustc --version  # Verify >= 1.82
```

### "SSL certificate error" during download

**Cause:** Outdated CA certificates or network issue.

**Solution:**

```bash
# Update CA certificates
sudo apt-get update && sudo apt-get install --reinstall ca-certificates  # Debian/Ubuntu
sudo yum reinstall ca-certificates  # RHEL/CentOS

# Or use --insecure flag (not recommended for production)
curl -k -L -o rs-guard <URL>
```

### Windows: "The system cannot find the file specified"

**Cause:** PATH not updated or terminal needs restart.

**Solution:**

1. Close and reopen your terminal/PowerShell
2. Verify PATH: `$env:Path -split ';' | Select-String rs-guard`
3. Re-add to PATH if needed (see Windows section above)

### macOS: "Cannot be opened because the developer cannot be verified"

**Solution:**

```bash
xattr -d com.apple.quarantine $(which rs-guard)
```

Or go to **System Preferences** → **Security & Privacy** → Click **Open Anyway**.

---

## Next Steps

- **[docs/USAGE.md]USAGE.md** — Complete CLI reference
- **[docs/CONFIGURATION.md]CONFIGURATION.md**`.reviewer.toml` setup
- **[docs/PROVIDERS.md]PROVIDERS.md** — API key acquisition for all providers
- **[docs/LOCAL_MODE.md]LOCAL_MODE.md** — Pre-commit hook configuration
- **[examples/]../examples/** — Example workflows and configurations

---

## Getting Help

- **Documentation:** See [docs/]docs/ directory
- **Issues:** <https://github.com/nebulaideas/rs-guard/issues>
- **Discussions:** <https://github.com/nebulaideas/rs-guard/discussions>