repotoire 0.5.1

Graph-powered code analysis CLI. 106 detectors for security, architecture, and code quality.
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
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# User Guide

Complete reference for all Repotoire commands, flags, and features.

## Table of Contents

- [Global Options]#global-options
- [Commands]#commands
  - [analyze]#analyze
  - [findings]#findings
  - [fix]#fix
  - [graph]#graph
  - [stats]#stats
  - [serve]#serve
  - [config]#config
  - [doctor]#doctor
  - [clean]#clean
  - [init]#init
  - [feedback]#feedback
  - [train]#train
- [Output Formats]#output-formats
- [Environment Variables]#environment-variables

---

## Global Options

These options apply to all commands:

| Option | Description | Default |
|--------|-------------|---------|
| `--log-level <LEVEL>` | Logging verbosity: `error`, `warn`, `info`, `debug`, `trace` | `info` |
| `--workers <N>` | Parallel workers (1-64) | `8` |
| `-h, --help` | Print help ||
| `-V, --version` | Print version ||

---

## Commands

### analyze

Run code analysis on a repository.

```bash
repotoire analyze [OPTIONS] [PATH]
```

#### Arguments

| Argument | Description | Default |
|----------|-------------|---------|
| `PATH` | Path to repository | `.` (current directory) |

#### Options

| Option | Short | Description |
|--------|-------|-------------|
| `--format <FORMAT>` | `-f` | Output format: `text`, `json`, `sarif`, `html`, `markdown` (or `md`) |
| `--output <FILE>` | `-o` | Write output to file (default: stdout) |
| `--severity <LEVEL>` | | Minimum severity: `critical`, `high`, `medium`, `low` |
| `--top <N>` | | Maximum findings to show |
| `--page <N>` | | Page number for pagination (1-indexed) |
| `--per-page <N>` | | Findings per page (0 = all) |
| `--skip-detector <NAME>` | | Skip specific detectors (repeatable) |
| `--thorough` | | Run external tools (Bandit, ESLint, etc.) |
| `--relaxed` | | Show only high/critical findings |
| `--no-git` | | Skip git history analysis (faster) |
| `--no-emoji` | | Disable emoji in output |
| `--fail-on <LEVEL>` | | Exit with code 1 if findings at this severity |
| `--explain-score` | | Show detailed scoring breakdown |
| `--verify` | | Use LLM to filter false positives (needs API key) |

#### Examples

```bash
# Basic analysis
repotoire analyze .

# Output JSON to file
repotoire analyze . -f json -o report.json

# Show only critical/high findings
repotoire analyze . --relaxed

# Fail CI if critical issues found
repotoire analyze . --fail-on critical

# Skip slow detectors
repotoire analyze . --skip-detector bandit --skip-detector eslint

# Run thorough analysis with external tools
repotoire analyze . --thorough

# Get detailed scoring explanation
repotoire analyze . --explain-score

# Fast mode: skip git history
repotoire analyze . --no-git

# Clean CI output
repotoire analyze . --no-emoji --log-level warn
```

---

### findings

View findings from the last analysis.

```bash
repotoire findings [OPTIONS] [PATH]
```

#### Options

| Option | Description | Default |
|--------|-------------|---------|
| `--severity <LEVEL>` | Filter by minimum severity | All |
| `--detector <NAME>` | Filter by detector name | All |
| `--page <N>` | Page number | 1 |
| `--per-page <N>` | Findings per page | 20 |
| `--format <FORMAT>` | Output format | `text` |

#### Examples

```bash
# View all findings (paginated)
repotoire findings

# Only critical issues
repotoire findings --severity critical

# Page through results
repotoire findings --page 2 --per-page 50

# Filter by detector
repotoire findings --detector sql-injection

# Output as JSON
repotoire findings --format json
```

---

### fix

Generate AI-powered fix for a finding.

```bash
repotoire fix <INDEX> [OPTIONS] [PATH]
```

#### Arguments

| Argument | Description |
|----------|-------------|
| `INDEX` | Finding number to fix (from `repotoire findings`) |

#### Options

| Option | Description |
|--------|-------------|
| `--apply` | Apply the fix automatically |

#### Prerequisites

Requires an AI API key set in your environment:

```bash
# Pick one:
export ANTHROPIC_API_KEY=sk-ant-...    # Claude
export OPENAI_API_KEY=sk-...           # GPT-4
export DEEPINFRA_API_KEY=...           # Llama 3.3
export OPENROUTER_API_KEY=...          # Any model

# Or have Ollama running locally
ollama serve
```

#### Examples

```bash
# Generate fix for finding #1
repotoire fix 1

# Auto-apply the fix
repotoire fix 1 --apply

# Fix in a different project
repotoire fix 3 /path/to/project
```

---

### graph

Query the code knowledge graph directly.

```bash
repotoire graph [OPTIONS] [PATH]
```

#### Options

| Option | Description |
|--------|-------------|
| `--query <CYPHER>` | Run a Cypher query |
| `--type <TYPE>` | Query type: `functions`, `classes`, `files`, `stats` |

#### Examples

```bash
# Show graph statistics
repotoire graph --type stats

# List all functions
repotoire graph --type functions

# Custom Cypher query
repotoire graph --query "MATCH (f:Function) WHERE f.complexity > 20 RETURN f.name, f.complexity"
```

See [SCHEMA.md](SCHEMA.md) for full graph schema and query examples.

---

### stats

Show graph statistics for the analyzed codebase.

```bash
repotoire stats [PATH]
```

#### Example Output

```
📊 Graph Statistics

Files:        145
Classes:      67
Functions:    423
Modules:      89

Languages:
  Python:     78 files
  TypeScript: 45 files
  JavaScript: 22 files

Edges:
  CALLS:         1,234
  IMPORTS:       567
  INHERITS:      45
  CONTAINS:      890
```

---

### serve

Start MCP server for AI assistant integration.

```bash
repotoire serve [OPTIONS]
```

#### Options

| Option | Description |
|--------|-------------|
| `--local` | Force local-only mode (no cloud API calls) |

The server enables AI assistants (Claude Desktop, Cursor) to interact with your codebase. See [MCP.md](MCP.md) for setup instructions.

---

### config

Manage configuration files.

```bash
repotoire config <COMMAND> [PATH]
```

#### Subcommands

| Command | Description |
|---------|-------------|
| `init` | Create a `repotoire.toml` with example settings |
| `show` | Display current config and paths |
| `set <KEY> <VALUE>` | Set a configuration value |

#### Examples

```bash
# Initialize config file
repotoire config init

# View current config
repotoire config show

# Set a value
repotoire config set defaults.severity high
```

---

### doctor

Check your environment setup.

```bash
repotoire doctor
```

#### Example Output

```
Repotoire Doctor

✓ Python version: 3.12.0
✓ Rust extension: Loaded
⚠ API keys: Present: OPENAI | Missing: ANTHROPIC, DEEPINFRA
✓ Kuzu database: Importable v0.11.3
✓ Disk space (home): 150.2GB free (35% used)
```

---

### clean

Remove cached analysis data.

```bash
repotoire clean [PATH]
```

Deletes the `.repotoire` directory in the specified path.

```bash
# Clean current project
repotoire clean

# Clean specific project
repotoire clean /path/to/project
```

---

### init

Initialize a repository for analysis.

```bash
repotoire init [PATH]
```

Creates necessary directories and optionally generates a config file.

---

### feedback

Label findings as true/false positives for training.

```bash
repotoire feedback <INDEX> <LABEL> [PATH]
```

#### Arguments

| Argument | Description |
|----------|-------------|
| `INDEX` | Finding number |
| `LABEL` | `true-positive` or `false-positive` |

This helps improve detector accuracy over time.

---

### train

Train the classifier on labeled data.

```bash
repotoire train [PATH]
```

Uses feedback data to improve detection accuracy.

---

## Output Formats

### text (default)

Human-readable output with colors and emoji.

```bash
repotoire analyze . -f text
```

### json

Machine-readable JSON output.

```bash
repotoire analyze . -f json -o report.json
```

```json
{
  "grade": "B",
  "score": 82.5,
  "findings": [
    {
      "detector": "sql-injection",
      "severity": "critical",
      "file": "src/db.py",
      "line": 45,
      "message": "SQL query with string interpolation"
    }
  ]
}
```

### sarif

SARIF format for IDE and CI integration.

```bash
repotoire analyze . -f sarif -o report.sarif
```

Supported by:
- GitHub Code Scanning
- VS Code SARIF Viewer
- Azure DevOps

### html

Interactive HTML report.

```bash
repotoire analyze . -f html -o report.html
```

Opens in any browser with sortable tables and severity filters.

### markdown (md)

Markdown format for documentation or pull requests.

```bash
repotoire analyze . -f markdown -o report.md
# or
repotoire analyze . -f md -o report.md
```

---

## Environment Variables

### AI API Keys

For `repotoire fix` and LLM-powered features:

| Variable | Provider | Notes |
|----------|----------|-------|
| `ANTHROPIC_API_KEY` | Claude | Best quality |
| `OPENAI_API_KEY` | GPT-4 | |
| `DEEPINFRA_API_KEY` | Llama 3.3 | Cheapest cloud option |
| `OPENROUTER_API_KEY` | Any model | Router to multiple providers |

**Local AI:** Run `ollama serve` with `llama3.3` model for free, local AI.

### Cloud Features

| Variable | Description |
|----------|-------------|
| `REPOTOIRE_API_KEY` | Enable PRO cloud features (semantic search, RAG) |
| `REPOTOIRE_API_URL` | Custom API endpoint |

### Analysis Behavior

| Variable | Description |
|----------|-------------|
| `REPOTOIRE_WORKERS` | Default parallel workers |
| `REPOTOIRE_LOG_LEVEL` | Default log level |

---

## Performance Tips

### For Large Repositories

```bash
# Skip git history (biggest speed gain)
repotoire analyze . --no-git

# Show only important findings
repotoire analyze . --relaxed

# Use more workers
repotoire analyze . --workers 16
```

### Caching

Repotoire caches analysis in `.repotoire/`. Subsequent runs on unchanged files are faster.

Clear cache if you encounter issues:

```bash
repotoire clean
```

### External Tools

External tools (Bandit, ESLint, Semgrep) are **not** run by default. They're slower but more thorough:

```bash
# Default: fast, graph-based analysis only
repotoire analyze .

# Thorough: includes external tools
repotoire analyze . --thorough
```

---

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success (or no findings above `--fail-on` threshold) |
| 1 | Findings at/above `--fail-on` severity found |
| 2 | Error during analysis |

Use `--fail-on` in CI pipelines:

```bash
repotoire analyze . --fail-on critical
echo $?  # 0 = no critical issues, 1 = critical issues found
```