proxy-pilot 0.7.1

Core-agnostic proxy health monitor, automatic failover daemon, and multi-channel alerting tool for Linux servers.
Documentation
# CLI Reference

`proxy-pilot` exposes a single binary installed at `/usr/local/bin/proxy-pilot` (or `~/.cargo/bin/proxy-pilot` if installed via Cargo). Run `proxy-pilot --help` or `proxy-pilot <command> --help` anytime.

## Commands Overview

| Command | Description |
| --- | --- |
| `proxy-pilot setup` | Interactive setup wizard (planned). |
| `proxy-pilot run` | Runs the monitoring, automatic failover, periodic benchmarking, auto-prune, and alerting daemon. |
| `proxy-pilot status` | Shows active core, install status, active profile, and profile/target counts. |
| `proxy-pilot list` | Lists all saved profiles sorted by priority. |
| `proxy-pilot add` | Appends a single profile to `config.yaml` without deleting existing ones. |
| `proxy-pilot import` | Imports one or more profiles (`vless://...` or `name,tag`) from interactive paste, a file, or inline arguments, and benchmarks them automatically. |
| `proxy-pilot remove` | Removes a single profile by name (`--name <n>`) or all profiles (`--all`) from `config.yaml`. |
| `proxy-pilot benchmark` | Tests all profiles in parallel, ranks healthy ones by lowest latency (ms), updates `priority`, and activates the fastest. |
| `proxy-pilot prune` | Tests all profiles in parallel, removes **all dead/unhealthy** profiles from `config.yaml`, and saves the sorted healthy list. |

---

## Command Details & Examples

### `run`
Runs the watchdog daemon in the foreground (used by `systemd` or manual execution).
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).

```bash
proxy-pilot run --config /etc/proxy-pilot/config.yaml
```

### `status`
Displays the configured core (`xray`), whether the binary is installed, the currently active profile, and the number of saved profiles and probe targets.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).

```bash
proxy-pilot status
```

### `list`
Lists all saved proxy profiles sorted by `priority` (lowest number = highest priority).
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).

```bash
proxy-pilot list
```

### `add`
Appends a single profile to `config.yaml` without modifying existing profiles.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).
- `--name <NAME>`: Unique profile name (required).
- `--tag <TAG>`: Outbound tag in the proxy core config (required).
- `--priority <U32>`: Optional priority (lower = preferred; defaults to appending at the end).

```bash
proxy-pilot add --name germany-1 --tag vless-de-1 --priority 1
```

### `import`
Batch-imports profiles (`vless://...` links or `name,tag` pairs) into `config.yaml` and automatically runs a parallel benchmark to rank them by latency.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).
- `-f, --file <PATH>`: Read profiles from a text file (one per line; blank lines and `#` comments are ignored).
- `--no-benchmark`: Skip the automatic parallel benchmark after importing.
- `[LINKS]...`: Optional inline `vless://...` links or `name,tag` entries.

```bash
# 1. Interactive paste mode (paste links, then press Ctrl+D on Linux/macOS or Ctrl+Z + Enter on Windows)
proxy-pilot import

# 2. Import from a text file
proxy-pilot import --file proxies.txt

# 3. Import inline links without running benchmark
proxy-pilot import --no-benchmark "vless://uuid@host:443#de-1" "vless://uuid@host2:443#nl-1"
```

### `remove`
Removes a single proxy profile by name, or clears all saved profiles from `config.yaml`.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).
- `--name <NAME>`: Exact profile name to remove (mutually exclusive with `--all`).
- `--all`: Remove **all** saved profiles from `config.yaml` (mutually exclusive with `--name`).

```bash
# Remove a single profile
proxy-pilot remove --name germany-1

# Remove all saved profiles
proxy-pilot remove --all
```

### `benchmark`
Tests all saved profiles in parallel (using an isolated temporary core session when available, so live traffic is not interrupted), ranks healthy profiles by lowest latency, updates `priority` in `config.yaml`, and activates the fastest healthy profile.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).

```bash
proxy-pilot benchmark
```

### `prune`
Tests all saved profiles in parallel, **removes every dead/unhealthy profile** from `config.yaml`, and saves the remaining healthy profiles sorted by latency.
- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).

```bash
proxy-pilot prune
```

### `setup`
Interactive setup wizard (planned for a future release).

```bash
proxy-pilot setup
```

---

## Global Flags

- `-c, --config <PATH>`: Path to `config.yaml` (default: `/etc/proxy-pilot/config.yaml`).
- `-h, --help`: Print help information.
- `-V, --version`: Print installed version.

## Exit Codes

- `0`: Success.
- `1`: Runtime, configuration, or network error.
- `2`: Invalid CLI arguments or flags (`clap`).