|
1 | 1 | # diffs |
2 | 2 |
|
3 | | -`diffs` is a small Go CLI that serves an embedded React diff review UI. |
| 3 | +Fast, beautiful diffs on the Go. |
4 | 4 |
|
5 | | -It has two main modes: |
| 5 | +<!-- screenshot goes here --> |
6 | 6 |
|
7 | | -- Local working tree: `diffs local` opens `http://127.0.0.1:3433/local` and refreshes staged, unstaged, and untracked changes from filesystem events. |
8 | | -- Pull request review: `diffs pr https://github.com/org/repo/pull/123` opens the same UI backed by `gh api`. |
| 7 | +## Motivation |
9 | 8 |
|
10 | | -## Build |
| 9 | +`diffs` is a local-first CLI in a single binary. Inspired by [DiffsHub](https://diffshub.com) from [pierre.computer](https://pierre.computer/), it brings a calmer review experience to your working tree and GitHub pull request. |
11 | 10 |
|
12 | | -```sh |
13 | | -pnpm install |
14 | | -pnpm build |
15 | | -``` |
| 11 | +## Install |
16 | 12 |
|
17 | | -The build compiles the web UI into `internal/webassets/dist`, embeds that generated bundle into the Go binary, and writes the final CLI binary. |
| 13 | +Download a pre-built binary from the [releases page](https://github.com/imfing/diffs-cli/releases), or build from source (see below). |
18 | 14 |
|
19 | 15 | ## Usage |
20 | 16 |
|
| 17 | +Run from any git repository: |
| 18 | + |
21 | 19 | ```sh |
22 | 20 | diffs |
23 | | -diffs local |
24 | | -diffs local --host localhost --port 4321 --dir /path/to/repo |
25 | | -diffs pr /org/repo/pull/123 |
| 21 | +``` |
| 22 | + |
| 23 | +This opens `http://127.0.0.1:3433/local` and reloads when files change. |
| 24 | + |
| 25 | +Review a GitHub pull request (requires the [GitHub CLI](https://cli.github.com)): |
| 26 | + |
| 27 | +```sh |
26 | 28 | diffs pr https://github.com/org/repo/pull/123 |
| 29 | +``` |
| 30 | + |
| 31 | +Common flags: |
| 32 | + |
| 33 | +```sh |
| 34 | +diffs local --port 4321 --dir /path/to/repo |
27 | 35 | diffs pr --github-host github.example.com /org/repo/pull/123 |
28 | 36 | ``` |
29 | 37 |
|
30 | | -The GitHub PR path relies on the GitHub CLI being authenticated for the target host. |
| 38 | +### Large pull requests |
| 39 | + |
| 40 | +The `pr` command fetches the diff via `gh api`, which GitHub caps at 300 changed files. For larger PRs, clone the repo and review with `diffs local` after checking out the PR branch: |
| 41 | + |
| 42 | +```sh |
| 43 | +gh pr checkout 123 |
| 44 | +diffs local |
| 45 | +``` |
31 | 46 |
|
32 | 47 | ## Configuration |
33 | 48 |
|
34 | | -On startup, `diffs` attempts to read `~/.config/diffs/config.toml`. Missing config is ignored. |
| 49 | +Optional. `diffs` reads `~/.config/diffs/config.toml` on startup: |
35 | 50 |
|
36 | 51 | ```toml |
37 | 52 | [ui] |
38 | 53 | color_scheme = "system" # system, light, dark |
39 | | -diff_theme = "github" # pierre, github, dark-plus, light-plus, one-dark-pro, one-light, monokai, night-owl, tokyo-night |
| 54 | +diff_theme = "github" # github, dark-plus, light-plus, one-dark-pro, ... |
40 | 55 | diff_style = "split" # split, unified |
41 | 56 | word_wrap = false |
42 | 57 | line_numbers = true |
43 | 58 | line_backgrounds = true |
44 | 59 | ``` |
45 | 60 |
|
46 | | -## Local comments |
| 61 | +The file sets initial defaults only. Once you change a setting in the UI it is saved to the browser's `localStorage` and takes precedence over `config.toml` on subsequent loads. |
| 62 | + |
| 63 | +## Comments |
| 64 | + |
| 65 | +Review comments are stored in `.diffs/comments.json` at the repo root. The folder is git-ignored by default. |
| 66 | + |
| 67 | +```sh |
| 68 | +diffs comments add --file web/src/App.tsx --line 42 --body "Check this" |
| 69 | +diffs comments list |
| 70 | +diffs comments reply <thread-id> --body "Updated" |
| 71 | +diffs comments resolve <thread-id> |
| 72 | +diffs comments reopen <thread-id> |
| 73 | +``` |
| 74 | + |
| 75 | +Pass `--dir /path/to/repo` to target a different repository. |
47 | 76 |
|
48 | | -Local review comments are stored in `.diffs/comments.json` at the git repository root. The `.diffs/` directory is ignored by default, so comments stay local unless you intentionally share that file. |
| 77 | +## Build from source |
| 78 | + |
| 79 | +Requires Go 1.26+ and pnpm. |
49 | 80 |
|
50 | 81 | ```sh |
51 | | -diffs comments list --dir . |
52 | | -diffs comments list --json --dir . |
53 | | -diffs comments add --dir . --file web/src/App.tsx --line 42 --body "Check this" |
54 | | -diffs comments reply THREAD_ID --dir . --body "Updated note" |
55 | | -diffs comments resolve THREAD_ID --dir . |
56 | | -diffs comments reopen THREAD_ID --dir . |
| 82 | +pnpm install |
| 83 | +pnpm build |
57 | 84 | ``` |
58 | 85 |
|
59 | | -Use `--dir /path/to/repo` with any `comments` command to target another repository. |
| 86 | +The binary is written to `bin/diffs`. |
0 commit comments