@acemarke/diffloupe 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +202 -135
  2. package/dist/index.js +599 -535
  3. package/dist/review-core/opencode/governor.ts +709 -0
  4. package/dist/review-core/opencode/tools.md +104 -0
  5. package/dist/review-core/system.md +52 -0
  6. package/dist/wasm/tree-sitter-cpp.wasm +0 -0
  7. package/dist/wasm/tree-sitter-tsx.wasm +0 -0
  8. package/dist/wasm/tree-sitter-typescript.wasm +0 -0
  9. package/dist/wasm/web-tree-sitter.wasm +0 -0
  10. package/dist/web/assets/arktype-bg7F_Ihs.js +34 -0
  11. package/dist/web/assets/diffs-D52k9AsX.js +157 -0
  12. package/dist/web/assets/index-BjtH6rIF.js +12 -0
  13. package/dist/web/assets/index-FlD9qnmN.css +1 -0
  14. package/dist/web/assets/langs/c-B7uRR5me.js +1 -0
  15. package/dist/web/assets/langs/cmake-Bj61d0ZC.js +1 -0
  16. package/dist/web/assets/langs/cpp-CsVjRphN.js +1 -0
  17. package/dist/web/assets/langs/css-C8fQr_0Q.js +1 -0
  18. package/dist/web/assets/langs/diff-woXpYk--.js +1 -0
  19. package/dist/web/assets/langs/docker-IyjqRm3v.js +1 -0
  20. package/dist/web/assets/langs/glsl-D4jN2Gfq.js +1 -0
  21. package/dist/web/assets/langs/go-rLFTqkRN.js +1 -0
  22. package/dist/web/assets/langs/graphql-CraUZO0h.js +1 -0
  23. package/dist/web/assets/langs/html-DA4kSGiR.js +1 -0
  24. package/dist/web/assets/langs/ini-B5eOa1yu.js +1 -0
  25. package/dist/web/assets/langs/java-BXcb2rRD.js +1 -0
  26. package/dist/web/assets/langs/javascript-BgS3c2Ky.js +1 -0
  27. package/dist/web/assets/langs/json-qhed-kSA.js +1 -0
  28. package/dist/web/assets/langs/json5-BR5RXkoi.js +1 -0
  29. package/dist/web/assets/langs/jsonc-CYpm1nAK.js +1 -0
  30. package/dist/web/assets/langs/jsx-Bz0zcwM4.js +1 -0
  31. package/dist/web/assets/langs/make-Dixweg8N.js +1 -0
  32. package/dist/web/assets/langs/markdown-BYOwaDjH.js +1 -0
  33. package/dist/web/assets/langs/objective-cpp-BsSzOQcm.js +1 -0
  34. package/dist/web/assets/langs/plain-text-BONI54VU.js +1 -0
  35. package/dist/web/assets/langs/postcss-BXeXVLqQ.js +1 -0
  36. package/dist/web/assets/langs/powershell-QtSnmXcu.js +1 -0
  37. package/dist/web/assets/langs/python-gzcpVVnB.js +1 -0
  38. package/dist/web/assets/langs/regexp-Cw_s_VJJ.js +1 -0
  39. package/dist/web/assets/langs/rust-DpiIf5JO.js +1 -0
  40. package/dist/web/assets/langs/scss-CHVQqdPx.js +1 -0
  41. package/dist/web/assets/langs/shellscript-CLZ0U2zV.js +1 -0
  42. package/dist/web/assets/langs/sql-CEbI0hMM.js +1 -0
  43. package/dist/web/assets/langs/svelte-CfPQtCMR.js +1 -0
  44. package/dist/web/assets/langs/toml-CcmNWLt0.js +1 -0
  45. package/dist/web/assets/langs/tsx-udAQXfEw.js +1 -0
  46. package/dist/web/assets/langs/typescript-bsJCZSQ-.js +1 -0
  47. package/dist/web/assets/langs/vue-DEcQttJD.js +1 -0
  48. package/dist/web/assets/langs/xml-D5JPTzE5.js +1 -0
  49. package/dist/web/assets/langs/yaml-rwi0_p6S.js +1 -0
  50. package/dist/web/assets/react-jlQz0HNM.js +9 -0
  51. package/dist/web/assets/rolldown-runtime-hePW80VL.js +1 -0
  52. package/dist/web/assets/router-DvNvfdSS.js +2 -0
  53. package/dist/web/assets/shiki-CbbI7yl6.js +153 -0
  54. package/dist/web/assets/state-a-GRkbSP.js +1 -0
  55. package/dist/web/assets/themes/pierre-dark-CpLgRqie.js +1 -0
  56. package/dist/web/assets/themes/pierre-light-CoaEpmwp.js +1 -0
  57. package/dist/web/assets/unused-C8e4aDKx.js +1 -0
  58. package/dist/web/assets/worker-uPqQ0MJ1.js +164 -0
  59. package/dist/web/index.html +26 -0
  60. package/package.json +34 -15
package/README.md CHANGED
@@ -2,207 +2,274 @@
2
2
 
3
3
  Understand your diffs before you merge them.
4
4
 
5
- ## The Problem
5
+ DiffLoupe runs a multi-agent AI code review over a local change or a GitHub pull request. You read the result in a local web UI: the changed files are grouped by what they do, the findings sit next to the lines they are about, and a walkthrough tells you where to start reading.
6
6
 
7
- Reading diffs is hard. You're staring at fragments of code without the full picture, trying to reconstruct what the change *actually does* and whether it's correct.
7
+ It is also a plain diff viewer. `diffloupe diff` shows the same grouped diff in about a second, with no agents and no credentials, and can add a walkthrough from a single model call.
8
8
 
9
- Good code review requires a mental model of the existing system - understanding where features live, how components interact, what a change will impact. But diffs show you disconnected hunks across files, and you're left mentally stitching them together.
9
+ ![The run page: merge and prod risk, findings by file, intent check, and where to start](docs/images/run-summary.png)
10
10
 
11
- This problem gets worse with AI-generated code. When an AI assistant produces 50 files of changes, you can't just skim and approve. You need to understand what was built, verify it matches your intent, and catch the subtle issues that LLMs introduce.
11
+ ![A finding and a walkthrough stop shown under the lines they refer to, and listed under their files in the group's file tree](docs/images/run-finding.png)
12
12
 
13
- ## The Solution
13
+ <sub>Screenshots use a synthetic test fixture, not a real repository.</sub>
14
14
 
15
- DiffLoupe uses AI to analyze diffs and tell you what they *mean*:
15
+ ## How a review works
16
16
 
17
- - **"What does this change do?"** - Get a clear summary of purpose, scope, and affected areas
18
- - **"What could go wrong?"** - Surface risks with concrete evidence, not vague warnings
19
- - **"Does it match my intent?"** - Compare what you asked for against what was actually built
17
+ 1. **Group.** The changed files are grouped into review units from links in the code: a name defined in one file and used in another, a test and its source, an import, a shared directory. Generated and lock files are skipped. Docs are listed but not reviewed in depth.
18
+ 2. **Review.** Each unit gets its own reviewer agent, which reads the surrounding code with [tilth](https://github.com/jahala/tilth) and reports findings with evidence. Up to six run at once.
19
+ 3. **Coordinate.** A coordinator merges and deduplicates the findings, drops the ones it cannot verify, and checks the change against its stated intent: the PR description, `--intent`, or the commit messages.
20
+ 4. **Walk through.** A walkthrough pass orders the change into chapters and stops, with a "start here" list.
20
21
 
21
- The key differentiator is **intent alignment**: provide your stated intent (commit message, PR description, or explicit description), and DiffLoupe compares it against what the code actually does. This surfaces scope creep, incomplete implementations, and mislabeled changes before they cause problems.
22
+ Each review is saved as a run that you can list and reopen. Reviewing the same target again links the new run to the previous one: findings that were fixed are listed as fixed, and ones still open are carried forward instead of being reported again.
22
23
 
23
- ## Features
24
+ ## The web UI
24
25
 
25
- - **Intent Derivation** - Analyzes diffs to determine purpose, scope, and affected areas
26
- - **Risk Assessment** - Identifies potential issues with severity levels and concrete evidence
27
- - **Intent Alignment** - Compares stated intent vs derived intent to catch mismatches
28
- - **Smart Context Loading** - Includes sibling files and new file source to reduce false positives
29
- - **Large Diff Handling** - Automatic decomposition strategies (two-pass, flow-based) for big changes
30
- - **GitHub PR Support** - Analyze PRs directly using PR metadata as stated intent
26
+ - **Summary** at the top, laid out like a GitHub review comment: merge risk and production risk, finding counts, findings grouped by file with links to their lines, whether the change matches its stated intent, what to focus on, and where to start.
27
+ - **Groups** in the sidebar and down the page. Each group has a short summary and its own file tree. Files can be collapsed one by one or from the collapse menu.
28
+ - **File tree notes:** under each file in a group's tree, one row per finding (severity dot, title, line) and per walkthrough stop (signpost icon, title, stop number, line). Clicking a row scrolls to its line. Groups with a blocker or should-fix finding, or a critical walkthrough stop, get an orange mark; its tooltip says which.
29
+ - **Finding cards** under the lines they refer to, coloured by severity, with explanation, evidence and a suggested fix. Focusing a finding highlights its line range.
30
+ - **Walkthrough stops** as separate cards, with a Guide mode in the sidebar for stepping through them in order.
31
+ - **Copy** on each finding and **Copy all** put the findings on the clipboard as markdown, ready to paste into a coding agent.
32
+ - **Keyboard:** `j`/`k` next/previous file, `n`/`p` next/previous finding, `]`/`[` next/previous stop, `x` collapse the current file, `t` back to the summary, `?` for the list. Browser Back and Forward move between the findings you jumped to.
33
+ - Split or unified diffs, line wrapping, light and dark themes.
34
+ - While a review is running, the page shows its progress and fills in the file groups as soon as grouping finishes.
35
+ - The run list at `/` shows every saved run, with a filter for reviews or diffs.
31
36
 
32
- ## Installation
37
+ ## Requirements
38
+
39
+ | Tool | Notes |
40
+ |------|-------|
41
+ | [Bun](https://bun.sh) 1.3 or later | Runs the CLI and the server. |
42
+ | `git` | |
43
+ | [OpenCode](https://opencode.ai) 2.x | Runs every agent (`npm i -g opencode-ai`). Tested with 2.0.26. DiffLoupe writes its own OpenCode config for each run, so your agents, plugins and MCP servers are not used. Your default model and your `providers` block are. |
44
+ | [tilth](https://github.com/jahala/tilth) | Code reading tools for the reviewers (`cargo install tilth`). Tested with 0.9.0. |
45
+ | [`gh`](https://cli.github.com) | Only for pull requests. Run `gh auth login` first. |
46
+ | A model provider credential | See [Credentials](#credentials). |
47
+
48
+ `diffloupe diff` needs only Bun, `git`, and `gh` for pull requests. With `--walkthrough` it also needs OpenCode and a credential for the walkthrough model, but not tilth.
49
+
50
+ Run `diffloupe doctor` to check all of this, along with which models a review will use and where each credential comes from.
51
+
52
+ **Cost.** With the built-in defaults (Claude Opus 5.5 for the reviewers and the coordinator, Claude Sonnet 5.5 for the walkthrough and group naming), real runs so far cost about $0.10 for a one-file commit, about $1 for a small PR, and $4–5 for a large one. If your OpenCode config sets a default model, DiffLoupe uses it for every stage instead, which changes the cost. Use `--max-cost` or `maxCostUsd` to set a limit. The run page and `diffloupe runs` show what each run cost. Models whose provider reports no price show "cost not reported", and `--max-cost` cannot be enforced for them.
53
+
54
+ **Platforms.** Developed and tested on Linux and WSL2. On WSL the server binds `127.0.0.1` and the Windows browser reaches it through `localhost`. macOS should work but has not been tried. Native Windows is not supported; use WSL.
55
+
56
+ ## Install
33
57
 
34
58
  ```bash
35
- npm install -g @acemarke/diffloupe
59
+ bun add -g @acemarke/diffloupe
36
60
  ```
37
61
 
38
- Requires Node.js 18+.
62
+ `npm i -g @acemarke/diffloupe` works too, but the `diffloupe` command runs under Bun either way, so Bun must be on your `PATH`. The package is a self-contained bundle with no runtime dependencies.
39
63
 
40
- ## Configuration
41
-
42
- Set your Anthropic API key as an environment variable:
64
+ To run from source instead:
43
65
 
44
66
  ```bash
45
- export ANTHROPIC_API_KEY=sk-ant-api03-...
67
+ git clone https://github.com/markerikson/diffloupe.git
68
+ cd diffloupe
69
+ bun install
70
+ bun run build
46
71
  ```
47
72
 
48
- Add to your shell profile (`~/.bashrc`, `~/.zshrc`) for persistence.
73
+ Then run `bun /path/to/diffloupe/dist/index.js`, or put a `diffloupe` alias or wrapper script on your `PATH` that runs it.
49
74
 
50
- ## Quick Start
75
+ ## Quick start
51
76
 
52
77
  ```bash
53
- # Analyze staged changes
54
- diffloupe analyze
78
+ # Review uncommitted changes in the current repo and open the result in a browser
79
+ diffloupe review --open
80
+
81
+ # Review a GitHub PR; its title and description are the stated intent
82
+ diffloupe review '#123' --open
83
+ diffloupe review https://github.com/owner/repo/pull/123 --open
84
+
85
+ # Review a branch against its merge base, with a stated intent and a cost limit
86
+ diffloupe review branch:my-feature --intent "Add rate limiting to API endpoints" --max-cost 3
87
+
88
+ # Run in the terminal only and print the review as markdown
89
+ diffloupe review --headless --markdown
55
90
 
56
- # Analyze with your stated intent
57
- diffloupe analyze --intent "Add rate limiting to API endpoints"
91
+ # View uncommitted changes grouped by code links, with no model calls
92
+ diffloupe diff --open
58
93
 
59
- # Analyze a commit (uses commit message as intent)
60
- diffloupe analyze commit:HEAD
94
+ # View a PR with a walkthrough guide (one model call)
95
+ diffloupe diff '#123' --walkthrough --open
61
96
 
62
- # Analyze a GitHub PR (uses title + description as intent)
63
- diffloupe pr 123
97
+ # View a PR from any directory, without a clone
98
+ diffloupe diff owner/repo#123 --open
64
99
 
65
- # Preview what will be sent to the LLM (no API call)
66
- diffloupe summarize --stats
100
+ # Reopen saved runs
101
+ diffloupe open --last --open
102
+ diffloupe runs
67
103
  ```
68
104
 
69
- ## Commands
105
+ `review` and `diff` start a local server, print the run URL, and stream progress to the terminal. The page can be opened right away. Ctrl+C stops the server, and cancels the run if it is still going. If a `diffloupe serve` is already running, `review`, `diff` and `open` use it instead of starting another server.
70
106
 
71
- ### `diffloupe analyze [target]`
107
+ ## Commands
72
108
 
73
- Analyze code changes with AI assistance.
109
+ ### `diffloupe review [target]`
74
110
 
75
111
  **Targets:**
76
112
 
77
113
  | Target | Description |
78
114
  |--------|-------------|
79
- | `staged` | Staged changes (default) |
80
- | `unstaged` | Unstaged working tree changes |
81
- | `HEAD` | All uncommitted changes |
82
- | `branch:name` | Compare current HEAD to branch |
83
- | `commit:hash` | Analyze a specific commit |
84
- | `range:a..b` | Analyze a commit range |
115
+ | `worktree` | Staged, unstaged and untracked changes against HEAD (default) |
116
+ | `staged` | Staged changes against HEAD |
117
+ | `<sha>`, `HEAD`, `HEAD~2`, `main^`, a tag, `commit:<rev>` | A single commit against its parent. Use `commit:<branch>` for just the tip commit of a branch |
118
+ | `<a>..<b>`, `range:<a>..<b>` | The diff between two commits. An empty side means `HEAD`, as in `HEAD~3..` |
119
+ | `<a>...<b>`, `range:<a>...<b>` | `<b>` against `merge-base(<a>, <b>)` |
120
+ | `<branch>`, `branch:<name>` | A branch against its merge base with the default branch. A bare name of the default branch means its tip commit |
121
+ | `#<n>`, `pr:<n>`, PR URL | A GitHub pull request, reviewed in a temporary worktree at the PR head |
85
122
 
86
123
  **Options:**
87
124
 
88
125
  | Option | Description |
89
126
  |--------|-------------|
127
+ | `-C, --repo <path>` | Repository to review (default: current directory) |
128
+ | `--base <ref>` | For `staged`/`worktree`: diff against `merge-base(<ref>, HEAD)` instead of HEAD |
90
129
  | `-i, --intent <text>` | Describe the intent of the changes |
91
- | `--intent-file <path>` | Read intent from a file |
92
- | `-v, --verbose` | Show detailed output |
93
- | `--json` | Output results as JSON |
94
- | `-C, --cwd <path>` | Run in a different directory |
95
- | `--strategy <name>` | Force decomposition strategy (direct, two-pass, flow-based) |
96
- | `--demo` | Show example output without API call |
130
+ | `--intent-file <path>` | Read the intent from a file |
131
+ | `--model <stage=id>` | Model for a stage: `review`, `coordinator`, `walkthrough` (repeatable) |
132
+ | `--effort <level>` | Reasoning effort: `low`, `medium`, `high` |
133
+ | `--config <file>` | Per-repo review settings (see below) |
134
+ | `--max-cost <usd>` | Stop starting new review slices once spending reaches this amount. Slices already running finish, so the total can go over: by up to six slices at $3 each, plus the coordinator and walkthrough. |
135
+ | `--host <host>`, `--port <port>` | Server address (default `127.0.0.1:4517`, or the next free port) |
136
+ | `--open` | Open the run in a browser. On WSL this opens the Windows browser. |
137
+ | `--headless` | Run without a server and print a summary to stdout |
138
+ | `--markdown` | With `--headless`, print the full review markdown instead of the summary |
139
+
140
+ Untracked files over 1 MB are skipped and listed in the run.
97
141
 
98
- **Intent sources** (in priority order):
99
- 1. `--intent` flag
100
- 2. `--intent-file` contents
101
- 3. Commit message (for `commit:` targets)
102
- 4. Piped stdin
142
+ ### `diffloupe diff [target]`
103
143
 
104
- ### `diffloupe pr <identifier>`
144
+ Shows a target's diff in the web UI, grouped the same way as a review, with no review agents. It takes the same targets as `review`. Grouping reads files from git objects, so no worktree is created and your checkout is not touched. Group titles come from the files' directories and names instead of a model call. Docs and generated files go in the trailing "Other changes" section.
105
145
 
106
- Analyze a GitHub PR. Requires `gh` CLI to be installed and authenticated.
146
+ | Option | Description |
147
+ |--------|-------------|
148
+ | `-C, --repo <path>` | Repository (default: current directory) |
149
+ | `--base <ref>` | For `staged`/`worktree`: diff against `merge-base(<ref>, HEAD)` instead of HEAD |
150
+ | `--walkthrough` | Add the walkthrough guide: one call to the walkthrough model, which works from the diff alone and gets no tools for reading the repo |
151
+ | `-i, --intent <text>`, `--intent-file <path>` | Stated intent, used by the walkthrough |
152
+ | `--model walkthrough=<id>`, `--effort <level>` | Walkthrough model and effort |
153
+ | `--config <file>` | Per-repo settings, for the walkthrough model |
154
+ | `--host`, `--port`, `--open` | As for `review` |
155
+ | `--headless` | Print the groups and their files to stdout, no server |
107
156
 
108
- **Identifier formats:**
157
+ `owner/repo#<n>` and PR URLs also work outside a clone of that repository. DiffLoupe then keeps its own copy of the repository under `~/.local/share/diffloupe/repos/` with no history and no file contents: each run fetches only the PR head and its merge base, and file contents are fetched as the diff and grouping need them. git authenticates through `gh`, so private repositories work too. Such runs cannot be turned into reviews, since a review needs a clone.
109
158
 
110
- ```bash
111
- diffloupe pr 123 # PR in current repo
112
- diffloupe pr owner/repo#123 # Cross-repo PR
113
- diffloupe pr https://github.com/owner/repo/pull/123 # Full URL
159
+ A diff run page has a **Review these changes** button. It starts a full review of the same base and head commits. For `worktree` and `staged` targets that is the snapshot you were looking at, not what is on disk now.
160
+
161
+ ### `diffloupe open [runId]`
162
+
163
+ Prints the URL of a saved run, starting a server if none is running. `--last` opens the most recent run; with no run id it opens the run list. `--open` opens the browser. `--port` is where it looks for a running server (default 4517), and `--host` is the address a new server listens on.
164
+
165
+ ### `diffloupe serve`
166
+
167
+ Runs the server until you stop it. `-C` sets the repository that runs use by default. `--host`, `--port` and `--open` work as for `review`.
168
+
169
+ ### `diffloupe runs`
170
+
171
+ | Command | Description |
172
+ |---------|-------------|
173
+ | `diffloupe runs [--kind review\|diff] [--json]` | List saved runs, newest first |
174
+ | `diffloupe runs show <id> [--json]` | Show a run: groups with their files and findings, walkthrough stops, totals |
175
+ | `diffloupe runs show <id> --markdown [--over-cap]` | Print the findings as markdown, the same text as Copy all in the UI |
176
+ | `diffloupe runs rm <id>` | Delete a run, its artifacts, its scratch files and the git refs that pin its commits |
177
+ | `diffloupe runs prune [--older-than 30d] [--keep 20] [--kind review\|diff] [--yes]` | Delete runs older than the cutoff, except the newest `--keep`, plus scratch files no run owns. Lists what it would delete unless `--yes` is given |
178
+
179
+ Runs are stored under `$XDG_DATA_HOME/diffloupe/runs/<id>/` (`~/.local/share/diffloupe/runs/` by default). Each holds `run.json`, the reviewed `diff.patch`, the progress log, and the raw review output. Deleting a run removes the refs that pin its commits; the repository copies under `repos/` are not deleted, and their objects stay until you remove the directory.
180
+
181
+ ### `diffloupe doctor`
182
+
183
+ Checks Bun, git, OpenCode, tilth and `gh`; prints the model for each stage and where it came from, and the source of each provider credential; and shows how much disk the data directory uses. Exits non-zero if a review could not run. `--config <file>` includes a per-repo settings file in the model lookup.
184
+
185
+ ## Configuration
186
+
187
+ **User config:** `~/.config/diffloupe/config.json`
188
+
189
+ ```json
190
+ {
191
+ "provider": "anthropic",
192
+ "models": { "review": "claude-opus-5-5", "coordinator": "claude-opus-5-5", "walkthrough": "claude-sonnet-5-5" },
193
+ "effort": "medium",
194
+ "apiKeys": { "anthropic": "sk-ant-..." },
195
+ "opencode": { "useDefaultModel": true },
196
+ "maxCostUsd": 5,
197
+ "port": 4517,
198
+ "host": "127.0.0.1"
199
+ }
114
200
  ```
115
201
 
116
- **Options:**
202
+ **Per-repo settings** (`--config <file>`):
117
203
 
118
- | Option | Description |
119
- |--------|-------------|
120
- | `-R, --repo <owner/repo>` | Specify repository |
121
- | `-v, --verbose` | Show detailed output |
122
- | `--json` | Output results as JSON |
204
+ ```json
205
+ {
206
+ "provider": "anthropic",
207
+ "models": { "review": "...", "coordinator": "...", "walkthrough": "..." },
208
+ "effort": "medium",
209
+ "surfaces": { "deploy": ["^infra/"], "tooling": ["^docs/"] },
210
+ "extraExcludes": ["vendor/openssl/"]
211
+ }
212
+ ```
123
213
 
124
- The PR's title and description are automatically used as stated intent.
214
+ Every field is optional.
125
215
 
126
- ### `diffloupe summarize [target]`
216
+ | Setting | User config | Per-repo settings | CLI | Environment | Default |
217
+ |---------|-------------|-------------------|-----|-------------|---------|
218
+ | Reviewer model | `models.review` | `models.review` | `--model review=<id>` | `REVIEW_MODEL` | OpenCode default model, else `anthropic/claude-opus-5-5` |
219
+ | Coordinator model | `models.coordinator` | `models.coordinator` | `--model coordinator=<id>` | `REVIEW_MODEL_MERGE` | OpenCode default model, else `anthropic/claude-opus-5-5` |
220
+ | Walkthrough model | `models.walkthrough` | `models.walkthrough` | `--model walkthrough=<id>` | `REVIEW_MODEL_WALK` | OpenCode default model, else `anthropic/claude-sonnet-5-5` |
221
+ | Provider for bare model ids | `provider` | `provider` | | `REVIEW_PROVIDER` | `anthropic` |
222
+ | Effort | `effort` | `effort` | `--effort` | `REVIEW_EFFORT`, `REVIEW_EFFORT_AUX` | `medium` for built-in default models only |
223
+ | Use the OpenCode default model | `opencode.useDefaultModel` | | | | `true` |
224
+ | API keys by provider id | `apiKeys.<provider>` | | | | |
225
+ | Cost limit (USD) | `maxCostUsd` | | `--max-cost` | | none |
226
+ | Server address | `host`, `port` | | `--host`, `--port` | | `127.0.0.1:4517` |
127
227
 
128
- Preview diff formatting without running LLM analysis. Useful for debugging and understanding token usage.
228
+ **Model lookup.** Each stage is looked up on its own. `REVIEW_*` environment variables win, then command-line options, then the per-repo settings file, then the user config, then the `model` in your global OpenCode config (`~/.config/opencode/opencode.json(c)`), then the built-in defaults. A model id without a `/` gets the provider prefix, so `claude-opus-5-5` means `anthropic/claude-opus-5-5`.
129
229
 
130
- **Options:**
230
+ **Effort** is passed to OpenCode as the model variant (`provider/model#high`), so it must be a variant the model offers. It is only added when you set it, or when the model is a built-in default. A model from your OpenCode config runs without a variant unless you set an effort. A `#variant` written in the model id always wins.
131
231
 
132
- | Option | Description |
133
- |--------|-------------|
134
- | `--stats` | Show only file list and token estimates |
135
- | `--files-only` | Show only file list |
136
- | `--json` | Output as JSON |
137
- | `--no-tokens` | Skip token estimates |
138
-
139
- ## Output
140
-
141
- DiffLoupe provides three types of analysis:
142
-
143
- **Derived Intent** - What the change actually does:
144
- - Summary and purpose
145
- - Scope (feature, bugfix, refactor, etc.)
146
- - Affected areas
147
- - Suggested review order
148
-
149
- **Risk Assessment** - Potential issues:
150
- - Severity (low, medium, high, critical)
151
- - Category (security, performance, error-handling, etc.)
152
- - Evidence from the actual code
153
- - Suggested mitigations
154
-
155
- **Intent Alignment** (when stated intent provided):
156
- - Alignment level (aligned, partial, misaligned)
157
- - What matches between stated and actual
158
- - Mismatches, missing implementations, and unstated changes (scope creep)
159
-
160
- ## How It Works
161
-
162
- 1. **Parse** - Load and parse the git diff
163
- 2. **Classify** - Tier files by importance (skip lock files, generated code)
164
- 3. **Gather Context** - Load sibling files in touched directories
165
- 4. **Select Strategy** - Choose decomposition approach based on diff size
166
- 5. **Analyze** - Run intent derivation and risk assessment
167
- 6. **Align** - Compare stated intent vs derived intent (if provided)
168
-
169
- For large diffs, DiffLoupe automatically selects a decomposition strategy:
170
- - **Direct** - Small diffs analyzed in one pass
171
- - **Two-pass** - Medium diffs: quick overview, then deep-dive on flagged files
172
- - **Flow-based** - Large diffs: group files by logical flow, analyze each flow
232
+ `surfaces` are regex sources matched against repo-relative paths. They decide which findings count toward "prod risk": anything not matched as deploy or tooling counts as product code. `extraExcludes` are path substrings left out of the code map.
173
233
 
174
- ## Inspirations
234
+ ### Credentials
175
235
 
176
- DiffLoupe builds on ideas from several excellent tools:
236
+ Each review agent runs OpenCode with its own data directory, so DiffLoupe has to hand it a credential for every provider the chosen models use. For each provider, the first of these that exists is used:
177
237
 
178
- - [LaReview](https://github.com/puemos/lareview) - Flow-based grouping concept
179
- - [GitHuman](https://github.com/mcollina/githuman) - Pre-commit review philosophy
180
- - [Diffray](https://github.com/diffray/diffray) - Validation patterns, confidence scoring
181
- - [Critique](https://github.com/remorses/critique) - Prompt engineering principles
182
- - [CodeRabbit](https://coderabbit.ai) - Incremental review patterns
238
+ 1. The provider's environment variable, such as `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`. A `providers.<id>.env` list in your OpenCode config is honored.
239
+ 2. `apiKeys.<provider>` in `~/.config/diffloupe/config.json`. It is passed to the OpenCode processes only, not to DiffLoupe's own environment.
240
+ 3. An API key you saved with `opencode auth login`. DiffLoupe reads it with `opencode auth export` and imports it into each agent's data directory, which is deleted when the agent exits.
183
241
 
184
- ## Development
242
+ OAuth logins (such as a Claude or ChatGPT subscription) are not shared with the agents; use an API key for those providers. Providers that authenticate from the machine, such as Amazon Bedrock, Google Vertex, Ollama and LM Studio, are not checked. If a provider has no credential, the review stops before it starts and names the provider, the stage, and the ways to add one.
185
243
 
186
- DiffLoupe is built with Bun and TypeScript, published as a Node.js-compatible package.
244
+ The `diffloupe` command does not load `.env` files, so a `.env` in the repo you review cannot supply or override a key. `diffloupe doctor` shows which source each provider's credential comes from.
187
245
 
188
- ```bash
189
- # Install dependencies
190
- bun install
246
+ ## Inspirations
191
247
 
192
- # Run in dev mode
193
- bun run dev
248
+ - [pulls.review](https://pulls.review) - the page layout: grouped files, sticky group panels, per-group file trees
249
+ - [Codiff](https://github.com/nkzw-tech/codiff): a diff viewer with walkthroughs
250
+ - [`@pierre/diffs`](https://diffs.com) - the diff renderer
251
+ - [Plannotator](https://github.com/backnotprop/plannotator) - local review server, browser opening and request guards
252
+ - [LaReview](https://github.com/puemos/lareview) - flow-based grouping
253
+ - [GitHuman](https://github.com/mcollina/githuman) - pre-commit review
254
+ - [Diffray](https://github.com/diffray/diffray) - validation patterns, confidence scoring
255
+ - [Critique](https://github.com/remorses/critique) - prompt engineering principles
256
+ - [CodeRabbit](https://coderabbit.ai) - incremental review
194
257
 
195
- # Run tests
196
- bun test
258
+ ## Development
197
259
 
198
- # Type check
260
+ ```bash
261
+ bun install
262
+ bun run dev # CLI from source, in watch mode
263
+ bun run dev:web # Vite dev server for the web UI on :5173, proxying /api to a server on :4517
264
+ bun test src # unit tests
199
265
  bun run typecheck
200
-
201
- # Build for distribution
202
- bun run build
266
+ bun run lint
267
+ bun run build # CLI bundle plus the web UI in dist/web
203
268
  ```
204
269
 
205
- **Tech stack:** Bun, TypeScript, TanStack AI, ArkType, Commander
270
+ The server serves the web UI from `dist/web`, so after changing web code, `bun run build:web` and a page reload are enough.
271
+
272
+ **Tech stack:** Bun, TypeScript, Commander, ArkType, Hono, React, Redux Toolkit, TanStack Router, `@pierre/diffs`
206
273
 
207
274
  ## License
208
275