Skip to content

Commit e56390f

Browse files
authored
Merge pull request #9 from modem-dev/oss/oss-docs-and-cli-cleanup
Tighten OSS onboarding docs and remove the old git alias
2 parents 0203393 + bf70483 commit e56390f

7 files changed

Lines changed: 126 additions & 212 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ CLI input
4646
- `[` and `]` navigate hunks across the full review stream. Do not reintroduce `j`/`k` hunk navigation unless the user asks.
4747
- Agent context belongs beside the code, not hidden in a separate mode or workflow.
4848
- Agent notes are hunk-specific: show notes for the selected hunk, render them in the diff flow near the annotated row, and keep a clear spatial relationship to the code they explain.
49-
- When making code changes in this repo, also refresh `.hunk/latest.json` so the next review can load agent rationale with `hunk git --agent-context .hunk/latest.json`.
49+
- When making code changes in this repo, also refresh `.hunk/latest.json` so the next review can load agent rationale with `hunk diff --agent-context .hunk/latest.json`.
5050
- Keep `.hunk/latest.json` concise and review-oriented: one changeset summary, file summaries in narrative order, and a few hunk-level annotations with real rationale.
5151
- File order in `.hunk/latest.json` is intentional, but the visible note UI should stay hunk-note driven rather than showing generic file or changeset explainer cards.
52-
- If newly created files should appear in `hunk git` before commit, use `git add -N <paths>` so they show up in the review stream without staging content.
52+
- If newly created files should appear in `hunk diff` before commit, use `git add -N <paths>` so they show up in the review stream without staging content.
5353

5454
## commands
5555

README.md

Lines changed: 120 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,100 @@
11
# hunk
22

3-
Hunk is a desktop-inspired terminal diff viewer for understanding AI-authored changesets in Bun + TypeScript with OpenTUI.
3+
Hunk is a terminal diff viewer for reviewing agent-authored changesets with a desktop-style UI.
44

5-
## Requirements
6-
7-
- Bun
8-
- Zig
5+
- full-screen multi-file review stream
6+
- split, stacked, and responsive auto layouts
7+
- keyboard and mouse navigation
8+
- optional agent rationale beside annotated hunks
9+
- Git pager and difftool integration
910

1011
## Install
1112

1213
```bash
13-
bun install
14+
npm i -g hunkdiff
15+
```
16+
17+
For now, the published `hunk` executable still expects [Bun](https://bun.sh) 1.3.10+ to be available on your `PATH` at runtime.
18+
19+
## Quick start
20+
21+
Review your current working tree:
22+
23+
```bash
24+
hunk diff
1425
```
1526

16-
## Run
27+
Review staged changes:
1728

1829
```bash
19-
bun run src/main.tsx -- diff
30+
hunk diff --staged
2031
```
2132

22-
## Standalone binary
33+
Review a commit:
34+
35+
```bash
36+
hunk show HEAD~1
37+
```
2338

24-
Build a local executable:
39+
Compare two files directly:
2540

2641
```bash
27-
bun run build:bin
28-
./dist/hunk diff
42+
hunk diff before.ts after.ts
2943
```
3044

31-
Install it into `~/.local/bin`:
45+
Open a patch from stdin:
3246

3347
```bash
34-
bun run install:bin
35-
hunk
36-
hunk diff
48+
git diff --no-color | hunk patch -
3749
```
3850

39-
If you want a different install location, set `HUNK_INSTALL_DIR` before running the install script.
51+
## Feature comparison
52+
53+
| Capability | hunk | difftastic | delta | diff |
54+
| --- | --- | --- | --- | --- |
55+
| Dedicated interactive review UI |||||
56+
| Multi-file review stream with navigation sidebar |||||
57+
| Agent / AI rationale sidecar |||||
58+
| Split diffs |||||
59+
| Stacked diffs |||||
60+
| Auto responsive layouts |||||
61+
| Themes |||||
62+
| Syntax highlighting |||||
63+
| Syntax-aware / structural diffing |||||
64+
| Mouse support inside the diff viewer |||||
65+
| Runtime toggles for wrapping / line numbers / hunk metadata |||||
66+
| Pager-compatible mode |||||
67+
68+
## Benchmarks
69+
70+
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.
71+
72+
| Tool | Avg first-visible changed output |
73+
| --- | ---: |
74+
| `diff` | ~37 ms |
75+
| `delta --paging=never` | ~35 ms |
76+
| `hunk diff` | ~219 ms |
77+
| `difft --display side-by-side` | ~266 ms |
78+
79+
Takeaway:
4080

41-
## Workflows
81+
- `diff` and `delta` are fastest here because they print plain diff text and exit.
82+
- `hunk` spends more startup time on an interactive UI, syntax highlighting, navigation state, and optional agent context.
83+
- `difftastic` spends more startup time on structural diffing.
4284

43-
- `hunk` — print standard CLI help with the most common commands
44-
- `hunk diff` — review local working tree changes in the full Hunk UI
45-
- `hunk diff --staged` / `hunk diff --cached` — review staged changes in the full Hunk UI
85+
## Common workflows
86+
87+
- `hunk` — print CLI help
88+
- `hunk diff` — review working tree changes
89+
- `hunk diff --staged` / `hunk diff --cached` — review staged changes
4690
- `hunk diff <ref>` — review changes versus a branch, tag, or commit-ish
47-
- `hunk diff <ref1>..<ref2>` / `hunk diff <ref1>...<ref2>` — review common Git ranges
48-
- `hunk diff -- <pathspec...>` — review only selected paths
49-
- `hunk show [ref]` — review the last commit or a given ref in the full Hunk UI
50-
- `hunk stash show [ref]` — review a stash entry in the full Hunk UI
51-
- `hunk diff <left> <right>` — compare two concrete files directly
52-
- `hunk patch [file|-]` — review a patch file or stdin, including pager mode
53-
- `hunk pager` — act as a general Git pager wrapper, opening Hunk for diff-like stdin and falling back to normal text paging otherwise
91+
- `hunk diff <ref1>..<ref2>` / `hunk diff <ref1>...<ref2>` — review Git ranges
92+
- `hunk diff -- <pathspec...>` — limit review to selected paths
93+
- `hunk show [ref]` — review the last commit or a specific ref
94+
- `hunk stash show [ref]` — review a stash entry
95+
- `hunk patch [file|-]` — review a patch file or stdin
96+
- `hunk pager` — act as a Git pager wrapper, opening Hunk for diff-like stdin and falling back to plain text paging otherwise
5497
- `hunk difftool <left> <right> [path]` — integrate with Git difftool
55-
- `hunk git [range]` — legacy alias for the original Git-style diff entrypoint
5698

5799
## Interaction
58100

@@ -70,19 +112,49 @@ If you want a different install location, set `HUNK_INSTALL_DIR` before running
70112
- `tab` cycle focus regions
71113
- `q` or `Esc` quit
72114

115+
## Git integration
116+
117+
Use Hunk directly for full-screen review:
118+
119+
```bash
120+
hunk diff
121+
hunk diff --staged
122+
hunk diff main...feature
123+
hunk show
124+
hunk stash show
125+
```
126+
127+
Use Hunk as a pager for `git diff` and `git show`:
128+
129+
```bash
130+
git config --global core.pager 'hunk patch -'
131+
```
132+
133+
Or scope it just to diff/show:
134+
135+
```bash
136+
git config --global pager.diff 'hunk patch -'
137+
git config --global pager.show 'hunk patch -'
138+
```
139+
140+
Use Hunk as a Git difftool:
141+
142+
```bash
143+
git config --global diff.tool hunk
144+
git config --global difftool.hunk.cmd 'hunk difftool "$LOCAL" "$REMOTE" "$MERGED"'
145+
```
146+
73147
## Configuration
74148

75149
Hunk reads layered TOML config with this precedence:
76150

77151
1. built-in defaults
78152
2. global config: `$XDG_CONFIG_HOME/hunk/config.toml` or `~/.config/hunk/config.toml`
79153
3. repo-local config: `.hunk/config.toml`
80-
4. command-specific sections like `[git]`, `[diff]`, `[show]`, `[stash-show]`, `[patch]`, `[difftool]`
154+
4. command-specific sections like `[diff]`, `[show]`, `[stash-show]`, `[patch]`, `[difftool]`
81155
5. `[pager]` when Hunk is running in pager mode
82156
6. explicit CLI flags
83157

84-
When you change persistent view settings inside Hunk, it writes them back to `.hunk/config.toml` in the current repo when possible, or to the global config file outside a repo.
85-
86158
Example:
87159

88160
```toml
@@ -101,16 +173,7 @@ line_numbers = false
101173
mode = "split"
102174
```
103175

104-
CLI overrides are available when you want one-off or pager-specific behavior:
105-
106-
```bash
107-
hunk diff --mode split --line-numbers
108-
hunk show HEAD~1 --theme paper
109-
hunk patch - --mode stack --no-line-numbers
110-
hunk diff before.ts after.ts --theme paper --wrap
111-
```
112-
113-
Supported persistent CLI overrides:
176+
Supported one-off CLI overrides:
114177

115178
- `--mode <auto|split|stack>`
116179
- `--theme <theme>`
@@ -119,11 +182,11 @@ Supported persistent CLI overrides:
119182
- `--hunk-headers` / `--no-hunk-headers`
120183
- `--agent-notes` / `--no-agent-notes`
121184

122-
## Agent sidecar format
185+
## Agent context sidecar
123186

124187
Use `--agent-context <file>` to load a JSON sidecar and show agent rationale next to the diff.
125188

126-
The order of `files` in the sidecar is significant. Hunk uses that order for the sidebar and main review stream so an agent can tell a story instead of relying on raw patch order.
189+
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.
127190

128191
```json
129192
{
@@ -142,130 +205,40 @@ The order of `files` in the sidecar is significant. Hunk uses that order for the
142205
"confidence": "high"
143206
}
144207
]
145-
},
146-
{
147-
"path": "src/ui/App.tsx",
148-
"summary": "Presents the new workflow after the loader changes.",
149-
"annotations": [
150-
{
151-
"newRange": [90, 136],
152-
"summary": "Uses the normalized model in the review shell.",
153-
"rationale": "The reader should inspect this after understanding the loader changes.",
154-
"tags": ["ui"],
155-
"confidence": "medium"
156-
}
157-
]
158208
}
159209
]
160210
}
161211
```
162212

163-
Files omitted from the sidecar keep their original diff order and appear after the explicitly ordered files.
164-
165-
## Codex workflow
166-
167-
For Codex-driven changes, keep a transient sidecar at `.hunk/latest.json` and load it during review:
213+
For local agent-driven review, keep a transient sidecar at `.hunk/latest.json` and load it with:
168214

169215
```bash
170216
hunk diff --agent-context .hunk/latest.json
171217
```
172218

173-
Suggested pattern:
174-
175-
- Codex makes code changes.
176-
- Codex refreshes `.hunk/latest.json` with a concise changeset summary, file summaries, and hunk-level rationale.
177-
- You open `hunk diff`, `hunk diff --staged`, or `hunk show <ref>` with that sidecar.
178-
179-
Keep the sidecar concise. It should explain why a hunk exists, what risk to review, and how the files fit together. It should not narrate obvious syntax edits line by line.
180-
181-
## Comparison
219+
## Development
182220

183-
### Feature comparison
184-
185-
| Capability | hunk | difftastic | delta | diff |
186-
| --- | --- | --- | --- | --- |
187-
| Dedicated interactive review UI |||||
188-
| Multi-file review stream with navigation sidebar |||||
189-
| Agent / AI rationale sidecar |||||
190-
| Split diffs |||||
191-
| Stacked diffs |||||
192-
| Auto responsive layouts |||||
193-
| Themes |||||
194-
| Syntax highlighting |||||
195-
| Syntax-aware / structural diffing |||||
196-
| Mouse support inside the diff viewer |||||
197-
| Runtime toggles for wrapping / line numbers / hunk metadata |||||
198-
| Pager-compatible mode |||||
199-
200-
### Local timing snapshot
201-
202-
These numbers are **not a universal benchmark**. They are a quick local comparison from one Linux machine using tmux panes, measuring **time until a changed marker first became visible** on the same 120-line TypeScript file pair.
203-
204-
Commands used:
205-
206-
- `hunk diff before.ts after.ts`
207-
- `difft --display side-by-side before.ts after.ts`
208-
- `delta --paging=never before.ts after.ts`
209-
- `diff -u before.ts after.ts`
210-
211-
| Tool | Avg first-visible changed output |
212-
| --- | ---: |
213-
| `diff` | ~37 ms |
214-
| `delta --paging=never` | ~35 ms |
215-
| `hunk diff` | ~219 ms |
216-
| `difft --display side-by-side` | ~266 ms |
217-
218-
Interpretation:
219-
220-
- `diff` and `delta` are fastest here because they emit plain diff text and exit.
221-
- `hunk` pays extra startup cost for an interactive terminal UI, syntax highlighting, navigation state, and optional agent context.
222-
- `difftastic` pays extra cost for syntax-aware / structural diffing.
223-
- For larger review sessions, Hunk is optimized for **navigating and understanding** a changeset, not just dumping the quickest possible patch text.
224-
225-
## Git integration
226-
227-
For full-screen review, you can invoke Hunk directly with Git-shaped commands:
228-
229-
```bash
230-
hunk diff
231-
hunk diff --staged
232-
hunk diff main...feature
233-
hunk show
234-
hunk show HEAD~1
235-
hunk stash show
236-
```
237-
238-
Use Hunk as the default Git pager when you want it to behave like a normal pager under `git diff` / `git show`:
221+
Install dependencies:
239222

240223
```bash
241-
git config --global core.pager 'hunk patch -'
224+
bun install
242225
```
243226

244-
Or scope it just to `git diff` and `git show`:
227+
Validate a change:
245228

246229
```bash
247-
git config --global pager.diff 'hunk patch -'
248-
git config --global pager.show 'hunk patch -'
230+
bun run typecheck
231+
bun test
232+
bun run test:tty-smoke
249233
```
250234

251-
When Hunk reads a patch from stdin, it automatically switches to pager-style chrome, strips Git's color escape sequences before parsing, and binds keyboard input to the controlling terminal so it works correctly as a Git pager.
252-
253-
Then:
235+
Build the npm runtime bundle used for publishing:
254236

255237
```bash
256-
git diff
257-
git show HEAD
238+
bun run build:npm
239+
bun run check:pack
258240
```
259241

260-
If you want Git to launch Hunk as a difftool for file-to-file comparisons:
242+
## License
261243

262-
```bash
263-
git config --global diff.tool hunk
264-
git config --global difftool.hunk.cmd 'hunk difftool "$LOCAL" "$REMOTE" "$MERGED"'
265-
```
266-
e comparisons:
267-
268-
```bash
269-
git config --global diff.tool hunk
270-
git config --global difftool.hunk.cmd 'hunk difftool "$LOCAL" "$REMOTE" "$MERGED"'
271-
```
244+
[MIT](LICENSE)

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"files": [
1111
"dist/npm",
1212
"README.md",
13-
"LICENSE",
14-
"CONTRIBUTING.md",
15-
"SECURITY.md"
13+
"LICENSE"
1614
],
1715
"scripts": {
1816
"start": "bun run src/main.tsx",

0 commit comments

Comments
 (0)