hunkdiff 0.4.0 → 0.5.0
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.
- package/README.md +95 -218
- package/bin/hunk.cjs +3 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
<img width="384" height="384" alt="image" src="https://github.com/user-attachments/assets/85c5ba93-9de1-4757-87ae-4520b8fd659f" />
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://github.com/modem-dev/hunk/actions/workflows/ci.yml?branch=main"><img src="https://img.shields.io/github/actions/workflow/status/modem-dev/hunk/ci.yml?branch=main&style=for-the-badge&label=CI" alt="CI status"></a>
|
|
5
|
-
<a href="https://github.com/modem-dev/hunk/releases"><img src="https://img.shields.io/github/v/release/modem-dev/hunk?style=for-the-badge" alt="Latest release"></a>
|
|
6
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
|
|
7
|
-
</p>
|
|
3
|
+
# hunk - TUI diff tool that's AI-friendly
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
[](https://github.com/modem-dev/hunk/actions/workflows/ci.yml?branch=main)
|
|
6
|
+
[](https://github.com/modem-dev/hunk/releases)
|
|
7
|
+
[](LICENSE)
|
|
10
8
|
|
|
9
|
+
Hunk is a desktop-inspired terminal diff viewer for reviewing agent-authored changesets.
|
|
10
|
+
|
|
11
|
+
- AI annotations
|
|
11
12
|
- full-screen multi-file review stream
|
|
13
|
+
- keyboard & mouse support
|
|
12
14
|
- split, stacked, and responsive auto layouts
|
|
13
|
-
- keyboard and mouse navigation
|
|
14
|
-
- optional agent rationale beside annotated hunks
|
|
15
15
|
- Git pager and difftool integration
|
|
16
16
|
|
|
17
17
|
## Install
|
|
@@ -20,276 +20,153 @@ Hunk is a terminal diff viewer for reviewing agent-authored changesets with a de
|
|
|
20
20
|
npm i -g hunkdiff
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Requirements:
|
|
24
24
|
|
|
25
25
|
- Node.js 18+
|
|
26
|
-
-
|
|
26
|
+
- Currently supported on macOS and Linux
|
|
27
|
+
- Git is recommended for most workflows
|
|
27
28
|
|
|
28
|
-
##
|
|
29
|
+
## Usage
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
### Basics
|
|
31
32
|
|
|
32
33
|
```bash
|
|
33
|
-
hunk
|
|
34
|
+
hunk # show help
|
|
35
|
+
hunk --version # get version
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
### Working with Git
|
|
37
39
|
|
|
38
40
|
```bash
|
|
41
|
+
hunk diff # review current repo changes
|
|
39
42
|
hunk diff --staged
|
|
43
|
+
hunk show # review the latest commit
|
|
44
|
+
hunk show HEAD~1 # review an earlier commit
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
### Working with raw files/patches
|
|
43
48
|
|
|
44
49
|
```bash
|
|
45
|
-
hunk
|
|
50
|
+
hunk diff before.ts after.ts # compare two files directly
|
|
51
|
+
git diff --no-color | hunk patch - # review a patch from stdin
|
|
46
52
|
```
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
hunk diff before.ts after.ts
|
|
52
|
-
```
|
|
54
|
+
## Feature comparison
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
| Capability | hunk | difftastic | delta | diff |
|
|
57
|
+
| ----------------------------------------------------------- | ---- | ---------- | ----- | ---- |
|
|
58
|
+
| Dedicated interactive review UI | ✅ | ❌ | ❌ | ❌ |
|
|
59
|
+
| Multi-file review stream with navigation sidebar | ✅ | ❌ | ❌ | ❌ |
|
|
60
|
+
| Agent / AI rationale sidecar | ✅ | ❌ | ❌ | ❌ |
|
|
61
|
+
| Split diffs | ✅ | ✅ | ✅ | ✅ |
|
|
62
|
+
| Stacked diffs | ✅ | ✅ | ✅ | ✅ |
|
|
63
|
+
| Auto responsive layouts | ✅ | ❌ | ❌ | ❌ |
|
|
64
|
+
| Themes | ✅ | ❌ | ✅ | ❌ |
|
|
65
|
+
| Syntax highlighting | ✅ | ✅ | ✅ | ❌ |
|
|
66
|
+
| Syntax-aware / structural diffing | ❌ | ✅ | ❌ | ❌ |
|
|
67
|
+
| Mouse support inside the diff viewer | ✅ | ❌ | ❌ | ❌ |
|
|
68
|
+
| Runtime toggles for wrapping / line numbers / hunk metadata | ✅ | ❌ | ❌ | ❌ |
|
|
69
|
+
| Pager-compatible mode | ✅ | ✅ | ✅ | ✅ |
|
|
55
70
|
|
|
56
|
-
|
|
57
|
-
git diff --no-color | hunk patch -
|
|
58
|
-
```
|
|
71
|
+
## Git integration
|
|
59
72
|
|
|
60
|
-
|
|
73
|
+
You can set Hunk as your Git pager so `git diff` and `git show` open in Hunk automatically.
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
| --- | --- | --- | --- | --- |
|
|
64
|
-
| Dedicated interactive review UI | ✅ | ❌ | ❌ | ❌ |
|
|
65
|
-
| Multi-file review stream with navigation sidebar | ✅ | ❌ | ❌ | ❌ |
|
|
66
|
-
| Agent / AI rationale sidecar | ✅ | ❌ | ❌ | ❌ |
|
|
67
|
-
| Split diffs | ✅ | ✅ | ✅ | ✅ |
|
|
68
|
-
| Stacked diffs | ✅ | ✅ | ✅ | ✅ |
|
|
69
|
-
| Auto responsive layouts | ✅ | ❌ | ❌ | ❌ |
|
|
70
|
-
| Themes | ✅ | ❌ | ✅ | ❌ |
|
|
71
|
-
| Syntax highlighting | ✅ | ✅ | ✅ | ❌ |
|
|
72
|
-
| Syntax-aware / structural diffing | ❌ | ✅ | ❌ | ❌ |
|
|
73
|
-
| Mouse support inside the diff viewer | ✅ | ❌ | ❌ | ❌ |
|
|
74
|
-
| Runtime toggles for wrapping / line numbers / hunk metadata | ✅ | ❌ | ❌ | ❌ |
|
|
75
|
-
| Pager-compatible mode | ✅ | ✅ | ✅ | ✅ |
|
|
76
|
-
|
|
77
|
-
## Benchmarks
|
|
78
|
-
|
|
79
|
-
Quick local timing snapshot from one Linux machine on the same 120-line TypeScript file pair. Metric: time until a changed marker first became visible.
|
|
80
|
-
|
|
81
|
-
| Tool | Avg first-visible changed output |
|
|
82
|
-
| --- | ---: |
|
|
83
|
-
| `diff` | ~37 ms |
|
|
84
|
-
| `delta --paging=never` | ~35 ms |
|
|
85
|
-
| `hunk diff` | ~219 ms |
|
|
86
|
-
| `difft --display side-by-side` | ~266 ms |
|
|
87
|
-
|
|
88
|
-
Takeaway:
|
|
89
|
-
|
|
90
|
-
- `diff` and `delta` are fastest here because they print plain diff text and exit.
|
|
91
|
-
- `hunk` spends more startup time on an interactive UI, syntax highlighting, navigation state, and optional agent context.
|
|
92
|
-
- `difftastic` spends more startup time on structural diffing.
|
|
93
|
-
|
|
94
|
-
## Common workflows
|
|
95
|
-
|
|
96
|
-
- `hunk` — print CLI help
|
|
97
|
-
- `hunk diff` — review working tree changes
|
|
98
|
-
- `hunk diff --staged` / `hunk diff --cached` — review staged changes
|
|
99
|
-
- `hunk diff <ref>` — review changes versus a branch, tag, or commit-ish
|
|
100
|
-
- `hunk diff <ref1>..<ref2>` / `hunk diff <ref1>...<ref2>` — review Git ranges
|
|
101
|
-
- `hunk diff -- <pathspec...>` — limit review to selected paths
|
|
102
|
-
- `hunk show [ref]` — review the last commit or a specific ref
|
|
103
|
-
- `hunk stash show [ref]` — review a stash entry
|
|
104
|
-
- `hunk patch [file|-]` — review a patch file or stdin
|
|
105
|
-
- `hunk pager` — act as a Git pager wrapper, opening Hunk for diff-like stdin and falling back to plain text paging otherwise
|
|
106
|
-
- `hunk difftool <left> <right> [path]` — integrate with Git difftool
|
|
107
|
-
- `hunk mcp serve` — run the local MCP daemon for agent-to-diff communication
|
|
108
|
-
|
|
109
|
-
## MCP daemon (experimental)
|
|
110
|
-
|
|
111
|
-
Hunk can run a local MCP daemon that brokers commands to live Hunk TUI sessions.
|
|
112
|
-
|
|
113
|
-
Opening a normal Hunk review session now tries to register with the daemon automatically and will auto-start it on loopback when needed. You can still run the daemon explicitly:
|
|
75
|
+
From the terminal:
|
|
114
76
|
|
|
115
77
|
```bash
|
|
116
|
-
hunk
|
|
78
|
+
git config --global core.pager "hunk pager"
|
|
117
79
|
```
|
|
118
80
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
- local loopback daemon only
|
|
122
|
-
- live session discovery via `list_sessions` / `get_session`
|
|
123
|
-
- inline diff comments via `comment`
|
|
124
|
-
- Linux-first implementation, designed to stay portable to macOS later
|
|
125
|
-
|
|
126
|
-
Environment variables:
|
|
81
|
+
Or in your Git config:
|
|
127
82
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## Interaction
|
|
133
|
-
|
|
134
|
-
- `1` split view
|
|
135
|
-
- `2` stacked view
|
|
136
|
-
- `0` auto layout
|
|
137
|
-
- `t` cycle themes
|
|
138
|
-
- `a` toggle the agent panel
|
|
139
|
-
- `l` toggle line numbers
|
|
140
|
-
- `w` toggle line wrapping
|
|
141
|
-
- `m` toggle hunk metadata
|
|
142
|
-
- `[` / `]` move between hunks
|
|
143
|
-
- `space` / `b` page forward and backward
|
|
144
|
-
- `/` focus the file filter
|
|
145
|
-
- `tab` cycle focus regions
|
|
146
|
-
- `q` or `Esc` quit
|
|
147
|
-
|
|
148
|
-
## Git integration
|
|
83
|
+
```ini
|
|
84
|
+
[core]
|
|
85
|
+
pager = hunk pager
|
|
86
|
+
```
|
|
149
87
|
|
|
150
|
-
|
|
88
|
+
If you’d rather keep Git’s default `diff` and `show` behavior, you can add optional aliases instead:
|
|
151
89
|
|
|
152
90
|
```bash
|
|
153
|
-
hunk diff
|
|
154
|
-
hunk
|
|
155
|
-
hunk diff main...feature
|
|
156
|
-
hunk show
|
|
157
|
-
hunk stash show
|
|
91
|
+
git config --global alias.hdiff "-c core.pager=\"hunk pager\" diff"
|
|
92
|
+
git config --global alias.hshow "-c core.pager=\"hunk pager\" show"
|
|
158
93
|
```
|
|
159
94
|
|
|
160
|
-
|
|
95
|
+
## Examples
|
|
161
96
|
|
|
162
|
-
|
|
163
|
-
git config --global core.pager 'hunk patch -'
|
|
164
|
-
```
|
|
97
|
+
Ready-to-run demo diffs live in [`examples/`](examples/README.md).
|
|
165
98
|
|
|
166
|
-
|
|
99
|
+
Each example includes the exact command to run from the repository root.
|
|
167
100
|
|
|
168
|
-
|
|
169
|
-
git config --global pager.diff 'hunk patch -'
|
|
170
|
-
git config --global pager.show 'hunk patch -'
|
|
171
|
-
```
|
|
101
|
+
## Agent skill
|
|
172
102
|
|
|
173
|
-
|
|
103
|
+
Hunk ships a bundled agent skill named `hunk-review` in `skills/hunk-review/SKILL.md`.
|
|
174
104
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
105
|
+
It is written as a self-contained skill for skill-aware coding agents. The skill teaches an agent to:
|
|
106
|
+
|
|
107
|
+
- briefly explain what Hunk is
|
|
108
|
+
- prefer `hunk session ...` when a live Hunk review window already exists
|
|
109
|
+
- inspect current review focus before navigating blindly
|
|
110
|
+
- use `hunk session reload` to swap what an existing live session is showing
|
|
111
|
+
- leave concise inline review comments tied to real diff lines
|
|
179
112
|
|
|
180
|
-
|
|
113
|
+
If your coding agent supports packaged or repo-local skills, point it at this repository or copy the `skills/hunk-review/` directory into that agent's skill search path.
|
|
181
114
|
|
|
182
|
-
|
|
115
|
+
## Config
|
|
183
116
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
5. `[pager]` when Hunk is running in pager mode
|
|
189
|
-
6. explicit CLI flags
|
|
117
|
+
Hunk reads config from:
|
|
118
|
+
|
|
119
|
+
- `~/.config/hunk/config.toml`
|
|
120
|
+
- `.hunk/config.toml`
|
|
190
121
|
|
|
191
122
|
Example:
|
|
192
123
|
|
|
193
124
|
```toml
|
|
194
|
-
theme = "midnight
|
|
195
|
-
mode = "auto"
|
|
125
|
+
theme = "graphite" # graphite, midnight, paper, ember
|
|
126
|
+
mode = "auto" # auto, split, stack
|
|
196
127
|
line_numbers = true
|
|
197
128
|
wrap_lines = false
|
|
198
|
-
hunk_headers = true
|
|
199
129
|
agent_notes = false
|
|
200
|
-
|
|
201
|
-
[pager]
|
|
202
|
-
mode = "stack"
|
|
203
|
-
line_numbers = false
|
|
204
|
-
|
|
205
|
-
[diff]
|
|
206
|
-
mode = "split"
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
Supported one-off CLI overrides:
|
|
210
|
-
|
|
211
|
-
- `--mode <auto|split|stack>`
|
|
212
|
-
- `--theme <theme>`
|
|
213
|
-
- `--line-numbers` / `--no-line-numbers`
|
|
214
|
-
- `--wrap` / `--no-wrap`
|
|
215
|
-
- `--hunk-headers` / `--no-hunk-headers`
|
|
216
|
-
- `--agent-notes` / `--no-agent-notes`
|
|
217
|
-
|
|
218
|
-
## Agent context sidecar
|
|
219
|
-
|
|
220
|
-
Use `--agent-context <file>` to load a JSON sidecar and show agent rationale next to the diff.
|
|
221
|
-
|
|
222
|
-
The order of `files` in the sidecar is significant. Hunk uses that order for the sidebar and the main review stream so an agent can present a review narrative instead of raw patch order.
|
|
223
|
-
|
|
224
|
-
```json
|
|
225
|
-
{
|
|
226
|
-
"version": 1,
|
|
227
|
-
"summary": "High-level change summary from the agent.",
|
|
228
|
-
"files": [
|
|
229
|
-
{
|
|
230
|
-
"path": "src/core/loaders.ts",
|
|
231
|
-
"summary": "Normalizes git and patch inputs into one changeset model.",
|
|
232
|
-
"annotations": [
|
|
233
|
-
{
|
|
234
|
-
"newRange": [120, 156],
|
|
235
|
-
"summary": "Adds the patch loader entrypoint.",
|
|
236
|
-
"rationale": "Keeps all diff sources flowing through one normalized shape.",
|
|
237
|
-
"tags": ["parser", "architecture"],
|
|
238
|
-
"confidence": "high"
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
130
|
```
|
|
245
131
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
```bash
|
|
249
|
-
hunk diff --agent-context .hunk/latest.json
|
|
250
|
-
```
|
|
132
|
+
## Advanced workflows
|
|
251
133
|
|
|
252
|
-
|
|
134
|
+
- `hunk diff --agent-context <file>` loads inline agent rationale from a JSON sidecar
|
|
135
|
+
- `hunk mcp serve` runs the local Hunk session daemon and websocket broker for manual startup or debugging
|
|
136
|
+
- normal Hunk sessions auto-start/register with it by default
|
|
137
|
+
- coding agents should usually interact through `hunk session ...`, not by managing the daemon directly
|
|
138
|
+
- Hunk keeps the daemon loopback-only by default
|
|
139
|
+
- if you intentionally need remote access, set `HUNK_MCP_UNSAFE_ALLOW_REMOTE=1` and choose a non-loopback `HUNK_MCP_HOST`
|
|
253
140
|
|
|
254
|
-
|
|
141
|
+
### Live session control CLI
|
|
255
142
|
|
|
256
|
-
|
|
257
|
-
bun install
|
|
258
|
-
```
|
|
143
|
+
`hunk session ...` is the user-facing and agent-facing interface to Hunk's local live review session daemon.
|
|
259
144
|
|
|
260
|
-
|
|
145
|
+
Use explicit session targeting with either a live `<session-id>` or `--repo <path>` when exactly one live session matches that repo root.
|
|
261
146
|
|
|
262
147
|
```bash
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
148
|
+
hunk session list
|
|
149
|
+
hunk session context --repo .
|
|
150
|
+
hunk session navigate --repo . --file README.md --hunk 2
|
|
151
|
+
hunk session reload --repo . -- diff
|
|
152
|
+
hunk session reload --repo . -- show HEAD~1 -- README.md
|
|
153
|
+
hunk session comment add --repo . --file README.md --new-line 103 --summary "Frame this as MCP-first"
|
|
154
|
+
hunk session comment list --repo .
|
|
155
|
+
hunk session comment rm --repo . <comment-id>
|
|
156
|
+
hunk session comment clear --repo . --file README.md --yes
|
|
266
157
|
```
|
|
267
158
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
```bash
|
|
271
|
-
bun run build:npm
|
|
272
|
-
bun run check:pack
|
|
273
|
-
```
|
|
159
|
+
`hunk session reload ... -- <hunk command>` swaps the live session to a new `diff`, `show`, or other reviewable Hunk input without opening a new TUI window.
|
|
274
160
|
|
|
275
|
-
|
|
161
|
+
The session CLI can inspect, navigate, annotate, and reload a live session, but it does not edit `.hunk/latest.json`.
|
|
276
162
|
|
|
277
|
-
|
|
278
|
-
bun run build:prebuilt:npm
|
|
279
|
-
bun run check:prebuilt-pack
|
|
280
|
-
bun run smoke:prebuilt-install
|
|
281
|
-
```
|
|
163
|
+
## Performance notes
|
|
282
164
|
|
|
283
|
-
|
|
165
|
+
Hunk spends more startup time than plain diff output tools because it launches an interactive UI with syntax highlighting, navigation state, and optional agent context. In exchange, it is optimized for reviewing a full changeset instead of printing static diff text and exiting.
|
|
284
166
|
|
|
285
|
-
|
|
286
|
-
bun run build:prebuilt:artifact
|
|
287
|
-
bun run stage:prebuilt:release
|
|
288
|
-
bun run check:prebuilt-pack
|
|
289
|
-
bun run publish:prebuilt:npm -- --dry-run
|
|
290
|
-
```
|
|
167
|
+
## Contributing
|
|
291
168
|
|
|
292
|
-
|
|
169
|
+
For source setup, tests, packaging checks, and repo architecture, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
293
170
|
|
|
294
171
|
## License
|
|
295
172
|
|
package/bin/hunk.cjs
CHANGED
|
@@ -111,7 +111,9 @@ if (bunBinary) {
|
|
|
111
111
|
run(bunBinary, [entrypoint, ...process.argv.slice(2)]);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const printablePackages = hostCandidates()
|
|
114
|
+
const printablePackages = hostCandidates()
|
|
115
|
+
.map((candidate) => `"${candidate.packageName}"`)
|
|
116
|
+
.join(" or ");
|
|
115
117
|
console.error(
|
|
116
118
|
printablePackages.length > 0
|
|
117
119
|
? `Failed to locate a matching prebuilt Hunk binary. Try reinstalling hunkdiff or manually installing ${printablePackages}.`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hunkdiff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Desktop-inspired terminal diff viewer for understanding agent-authored changesets.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hunk": "./bin/hunk.cjs"
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"LICENSE"
|
|
12
12
|
],
|
|
13
13
|
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"code-review",
|
|
14
16
|
"diff",
|
|
15
17
|
"git",
|
|
16
|
-
"tui",
|
|
17
18
|
"terminal",
|
|
18
|
-
"
|
|
19
|
-
"ai"
|
|
19
|
+
"tui"
|
|
20
20
|
],
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"hunkdiff-darwin-arm64": "0.
|
|
34
|
-
"hunkdiff-darwin-x64": "0.
|
|
35
|
-
"hunkdiff-linux-x64": "0.
|
|
33
|
+
"hunkdiff-darwin-arm64": "0.5.0",
|
|
34
|
+
"hunkdiff-darwin-x64": "0.5.0",
|
|
35
|
+
"hunkdiff-linux-x64": "0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"publishConfig": {
|