# Spekter

[![pipeline status](https://gitlab.com/hallyhaa/spekter/badges/main/pipeline.svg)](https://gitlab.com/hallyhaa/spekter/-/pipelines)
[![crates.io](https://img.shields.io/crates/v/spekter.svg)](https://crates.io/crates/spekter)
[![license](https://img.shields.io/crates/l/spekter.svg)](https://gitlab.com/hallyhaa/spekter/-/blob/main/LICENSE)

Instant recursive directory and file diff tool, not unlike [Meld](https://meldmerge.org/).

## Features

- **Instant file preview** -- files appear immediately, diff colors update progressively in the background
- **Side-by-side and unified diff views** with synchronized scrolling
- **Syntax highlighting**
- **Recursive directory comparison** with two-column tree view
- **Inline character-level highlighting for diffs**
- **Tabbed interface** -- open multiple diffs, drag to reorder, Ctrl+Tab to switch
- **JSON order detection** -- detects when array/object contents only differ in ordering
- **CRLF normalization** -- line ending differences don't cause false positives
- **Smart ignore** -- skips .git, .idea, swap files, backups, and other noise

## Install

Requires [Rust](https://rustup.rs/) (1.70+).

```bash
# GUI application (includes --nw terminal mode)
cargo install spekter

# CLI only (no GUI dependencies, lighter build)
cargo install spekter-cli
```

## Usage

### GUI (`spkt`)

```bash
# Compare two directories
spkt /path/to/old /path/to/new

# Compare two files
spkt file1.rs file2.rs

# Open without arguments -- use the file picker
spkt

# Run in terminal mode (no window)
spkt --nw /path/to/old /path/to/new
```

### CLI (`spkt-nw`)

Lightweight alternative with no GUI dependencies.

```bash
# Compare two directories
spkt-nw /path/to/old /path/to/new

# Compare two files (colored diff output)
spkt-nw file1.rs file2.rs

# Limit output depth
spkt-nw --depth 0 /dir1 /dir2    # just: "Directories differ" or "identical"
spkt-nw --depth 1 /dir1 /dir2    # top-level files and directory names only
spkt-nw --depth 2 /dir1 /dir2    # one level into subdirectories
```

Exit codes: 0 = identical, 1 = differences found, 2 = error.

## Keyboard shortcuts

| Shortcut | Action                 |
|----------|------------------------|
| Ctrl+O | Open file picker       |
| Ctrl+Tab / Ctrl+Shift+Tab | Switch tabs            |
| Ctrl+W | Close tab              |
| Ctrl+1 | Side-by-side mode      |
| Ctrl+2 | Unified mode           |
| Escape | Close current diff tab |
| F5 / Ctrl+R | Refresh                |

## Architecture

Spekter is a Rust workspace with three crates:

- **spekter-core** -- library for directory walking, file hashing (XXH3), diffing (imara-diff histogram algorithm), and ignore patterns
- **spekter** -- egui/eframe GUI (`spkt`) with syntax highlighting, Meld-style Bezier gutter connectors, system font loading, filesystem watching, and instant file preview
- **spekter-cli** -- lightweight terminal-only build (`spkt-nw`) with colored diff output and depth-limited directory listings

## Building from source

```bash
git clone https://gitlab.com/hallyhaa/spekter
cd spekter
cargo build --release
# Binary at target/release/spkt
```

## License

MIT
