hunkdiff 0.9.4 → 0.9.5
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 +74 -16
- package/bin/hunk.cjs +3 -19
- package/package.json +5 -6
- package/skills/hunk-review/SKILL.md +0 -154
package/README.md
CHANGED
|
@@ -67,20 +67,9 @@ git diff --no-color | hunk patch - # review a patch from stdin
|
|
|
67
67
|
|
|
68
68
|
### Working with agents
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
2. Load the Hunk review skill: [`skills/hunk-review/SKILL.md`](skills/hunk-review/SKILL.md).
|
|
72
|
-
3. Ask your agent to use the skill against the live Hunk session.
|
|
70
|
+
Load the [`skills/hunk-review/SKILL.md`](skills/hunk-review/SKILL.md) skill in your coding agent (e.g. Claude, Codex, Opencode, Pi).
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```text
|
|
77
|
-
Load the Hunk skill and use it for this review.
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
> [!NOTE]
|
|
81
|
-
> `hunk skill path` lands in Hunk 0.10.0. Until that release is out, load the skill from the repo path above.
|
|
82
|
-
|
|
83
|
-
For the full live-session and `--agent-context` workflow guide, see [docs/agent-workflows.md](docs/agent-workflows.md).
|
|
72
|
+
Open Hunk in another window, then ask your agent to leave comments.
|
|
84
73
|
|
|
85
74
|
## Feature comparison
|
|
86
75
|
|
|
@@ -145,11 +134,80 @@ git config --global alias.hdiff "-c core.pager=\"hunk pager\" diff"
|
|
|
145
134
|
git config --global alias.hshow "-c core.pager=\"hunk pager\" show"
|
|
146
135
|
```
|
|
147
136
|
|
|
148
|
-
###
|
|
137
|
+
### Agent workflows
|
|
138
|
+
|
|
139
|
+
Hunk supports two agent workflows:
|
|
140
|
+
|
|
141
|
+
- steer a live Hunk window from another terminal with `hunk session ...` (recommended)
|
|
142
|
+
- load agent comments from a file with `--agent-context`
|
|
143
|
+
|
|
144
|
+
#### Steer a live Hunk window
|
|
145
|
+
|
|
146
|
+
Use the Hunk review skill: [`skills/hunk-review/SKILL.md`](skills/hunk-review/SKILL.md).
|
|
147
|
+
|
|
148
|
+
A good generic prompt is:
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
> Load the Hunk skill and use it for this review
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
That skill teaches the agent how to inspect a live Hunk session, navigate it, reload it, and leave inline comments.
|
|
155
|
+
|
|
156
|
+
#### How remote control works
|
|
157
|
+
|
|
158
|
+
When a Hunk TUI starts, it registers with a local loopback daemon. `hunk session ...` talks to that daemon to find the right live window and control it.
|
|
159
|
+
|
|
160
|
+
Use it to:
|
|
161
|
+
|
|
162
|
+
- inspect the current review context
|
|
163
|
+
- export the loaded review structure for agent workflows
|
|
164
|
+
- optionally include raw patch text when an agent truly needs it
|
|
165
|
+
- jump to a file, hunk, or line
|
|
166
|
+
- reload the current window with a different `diff` or `show` command
|
|
167
|
+
- add, batch-apply, list, and remove inline comments
|
|
168
|
+
|
|
169
|
+
Most users only need `hunk session ...`. Use `hunk mcp serve` only for manual startup or debugging of the local daemon.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
hunk session list
|
|
173
|
+
hunk session get --repo .
|
|
174
|
+
hunk session context --repo .
|
|
175
|
+
hunk session review --repo . --json
|
|
176
|
+
hunk session review --repo . --include-patch --json
|
|
177
|
+
hunk session navigate --repo . --file README.md --hunk 2
|
|
178
|
+
hunk session reload --repo . -- diff
|
|
179
|
+
hunk session reload --repo /path/to/worktree -- diff
|
|
180
|
+
hunk session reload --session-path /path/to/live-window --source /path/to/other-checkout -- diff
|
|
181
|
+
hunk session reload --repo . -- show HEAD~1 -- README.md
|
|
182
|
+
hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording"
|
|
183
|
+
hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" --focus
|
|
184
|
+
printf '%s\n' '{"comments":[{"filePath":"README.md","newLine":103,"summary":"Tighten this wording"}]}' | hunk session comment apply --repo . --stdin
|
|
185
|
+
printf '%s\n' '{"comments":[{"filePath":"README.md","hunk":2,"summary":"Explain this hunk"}]}' | hunk session comment apply --repo . --stdin --focus
|
|
186
|
+
hunk session comment list --repo .
|
|
187
|
+
hunk session comment rm --repo . <comment-id>
|
|
188
|
+
hunk session comment clear --repo . --file README.md --yes
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`hunk session review --json` returns file and hunk structure by default. Add `--include-patch` only when a caller truly needs raw unified diff text in the response.
|
|
192
|
+
|
|
193
|
+
`hunk session reload ... -- <hunk command>` swaps what a live session is showing without opening a new TUI window.
|
|
194
|
+
Pass `--focus` to jump the live session to the new note, or to the first note in a batch apply.
|
|
195
|
+
|
|
196
|
+
`hunk session comment apply` reads one stdin JSON object with a top-level `comments` array. Each item needs `filePath`, `summary`, and exactly one target such as `hunk`, `hunkNumber`, `oldLine`, or `newLine`.
|
|
149
197
|
|
|
150
|
-
|
|
198
|
+
- `--repo <path>` selects the live session by its current loaded repo root.
|
|
199
|
+
- `--source <path>` is reload-only: it changes where the nested `diff` / `show` command runs, but does not select the session.
|
|
200
|
+
- For normal worktree use, prefer targeting the worktree session directly with `hunk session reload --repo /path/to/worktree -- diff`.
|
|
201
|
+
- Use `--session-path` + `--source` only for advanced cases where you want to repoint an already-open live window to another checkout or path.
|
|
151
202
|
|
|
152
|
-
|
|
203
|
+
#### Load agent comments from a file
|
|
204
|
+
|
|
205
|
+
Use `--agent-context` to attach agent-written comments or rationale from a JSON sidecar file. For a compact real example, see [`examples/3-agent-review-demo/agent-context.json`](examples/3-agent-review-demo/agent-context.json).
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
hunk diff --agent-context notes.json
|
|
209
|
+
hunk patch change.patch --agent-context notes.json
|
|
210
|
+
```
|
|
153
211
|
|
|
154
212
|
## Examples
|
|
155
213
|
|
package/bin/hunk.cjs
CHANGED
|
@@ -5,10 +5,6 @@ const fs = require("node:fs");
|
|
|
5
5
|
const os = require("node:os");
|
|
6
6
|
const path = require("node:path");
|
|
7
7
|
|
|
8
|
-
function bundledSkillPath() {
|
|
9
|
-
return path.join(__dirname, "..", "skills", "hunk-review", "SKILL.md");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
8
|
function ensureExecutable(target) {
|
|
13
9
|
if (process.platform === "win32") {
|
|
14
10
|
return;
|
|
@@ -98,33 +94,21 @@ function bundledBunRuntime() {
|
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
96
|
|
|
101
|
-
const forwardedArgs = process.argv.slice(2);
|
|
102
|
-
if (forwardedArgs.length === 2 && forwardedArgs[0] === "skill" && forwardedArgs[1] === "path") {
|
|
103
|
-
const skillPath = bundledSkillPath();
|
|
104
|
-
if (!fs.existsSync(skillPath)) {
|
|
105
|
-
console.error(`hunk: could not locate the bundled Hunk review skill at ${skillPath}`);
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
process.stdout.write(`${skillPath}\n`);
|
|
110
|
-
process.exit(0);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
97
|
const overrideBinary = process.env.HUNK_BIN_PATH;
|
|
114
98
|
if (overrideBinary) {
|
|
115
|
-
run(overrideBinary,
|
|
99
|
+
run(overrideBinary, process.argv.slice(2));
|
|
116
100
|
}
|
|
117
101
|
|
|
118
102
|
const scriptDir = path.dirname(fs.realpathSync(__filename));
|
|
119
103
|
const prebuiltBinary = findInstalledBinary(scriptDir);
|
|
120
104
|
if (prebuiltBinary) {
|
|
121
|
-
run(prebuiltBinary,
|
|
105
|
+
run(prebuiltBinary, process.argv.slice(2));
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
const bunBinary = bundledBunRuntime();
|
|
125
109
|
if (bunBinary) {
|
|
126
110
|
const entrypoint = path.join(__dirname, "..", "dist", "npm", "main.js");
|
|
127
|
-
run(bunBinary, [entrypoint, ...
|
|
111
|
+
run(bunBinary, [entrypoint, ...process.argv.slice(2)]);
|
|
128
112
|
}
|
|
129
113
|
|
|
130
114
|
const printablePackages = hostCandidates()
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hunkdiff",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Desktop-inspired terminal diff viewer for understanding agent-authored changesets.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hunk": "./bin/hunk.cjs"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"bin",
|
|
10
|
-
"skills",
|
|
11
10
|
"README.md",
|
|
12
11
|
"LICENSE"
|
|
13
12
|
],
|
|
@@ -31,10 +30,10 @@
|
|
|
31
30
|
"node": ">=18"
|
|
32
31
|
},
|
|
33
32
|
"optionalDependencies": {
|
|
34
|
-
"hunkdiff-darwin-arm64": "0.9.
|
|
35
|
-
"hunkdiff-darwin-x64": "0.9.
|
|
36
|
-
"hunkdiff-linux-arm64": "0.9.
|
|
37
|
-
"hunkdiff-linux-x64": "0.9.
|
|
33
|
+
"hunkdiff-darwin-arm64": "0.9.5",
|
|
34
|
+
"hunkdiff-darwin-x64": "0.9.5",
|
|
35
|
+
"hunkdiff-linux-arm64": "0.9.5",
|
|
36
|
+
"hunkdiff-linux-x64": "0.9.5"
|
|
38
37
|
},
|
|
39
38
|
"license": "MIT",
|
|
40
39
|
"publishConfig": {
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: hunk-review
|
|
3
|
-
description: Interacts with live Hunk diff review sessions via CLI. Inspects review focus, navigates files and hunks, reloads session contents, and adds inline review comments. Use when the user has a Hunk session running or wants to review diffs interactively.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Hunk Review
|
|
7
|
-
|
|
8
|
-
Hunk is an interactive terminal diff viewer. The TUI is for the user -- do NOT run `hunk diff`, `hunk show`, or other interactive commands directly. Use `hunk session *` CLI commands to inspect and control live sessions through the local daemon.
|
|
9
|
-
|
|
10
|
-
If no session exists, ask the user to launch Hunk in their terminal first.
|
|
11
|
-
|
|
12
|
-
## Workflow
|
|
13
|
-
|
|
14
|
-
```text
|
|
15
|
-
1. hunk session list # find live sessions
|
|
16
|
-
2. hunk session get --repo . # inspect path / repo / source
|
|
17
|
-
3. hunk session review --repo . --json # inspect file/hunk structure first
|
|
18
|
-
4. hunk session review --repo . --include-patch --json # opt into raw diff text only when needed
|
|
19
|
-
5. hunk session context --repo . # check current focus when needed
|
|
20
|
-
6. hunk session navigate ... # move to the right place
|
|
21
|
-
7. hunk session reload -- <command> # swap contents if needed
|
|
22
|
-
8. hunk session comment add ... # leave one review note
|
|
23
|
-
9. hunk session comment apply ... # apply many agent notes in one stdin batch
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Session selection
|
|
27
|
-
|
|
28
|
-
Most session commands accept:
|
|
29
|
-
|
|
30
|
-
- `--repo <path>` -- match the live session by its current loaded repo root (most common)
|
|
31
|
-
- `<session-id>` -- match by exact ID (use when multiple sessions share a repo)
|
|
32
|
-
- If only one session exists, it auto-resolves
|
|
33
|
-
|
|
34
|
-
`reload` also supports:
|
|
35
|
-
|
|
36
|
-
- `--session-path <path>` -- match the live Hunk window by its current working directory
|
|
37
|
-
- `--source <path>` -- load the replacement `diff` / `show` command from a different directory
|
|
38
|
-
|
|
39
|
-
Use `--source` only for advanced reloads where the live session you want to control is not already associated with the checkout you want to load next. For a normal worktree session, prefer selecting it directly with `--repo /path/to/worktree`.
|
|
40
|
-
|
|
41
|
-
## Commands
|
|
42
|
-
|
|
43
|
-
### Inspect
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
hunk session list [--json]
|
|
47
|
-
hunk session get (--repo . | <id>) [--json]
|
|
48
|
-
hunk session context (--repo . | <id>) [--json]
|
|
49
|
-
hunk session review (--repo . | <id>) [--json] [--include-patch]
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
- `get` shows the session `Path`, `Repo`, and `Source`, which helps when choosing between `--repo` and `--session-path`
|
|
53
|
-
- `Repo` is what `--repo` matches; `Path` is what `--session-path` matches
|
|
54
|
-
- `review --json` returns file and hunk structure by default; add `--include-patch` only when a caller truly needs raw unified diff text
|
|
55
|
-
|
|
56
|
-
### Navigate
|
|
57
|
-
|
|
58
|
-
Absolute navigation requires `--file` and exactly one of `--hunk`, `--new-line`, or `--old-line`:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
hunk session navigate --repo . --file src/App.tsx --hunk 2
|
|
62
|
-
hunk session navigate --repo . --file src/App.tsx --new-line 372
|
|
63
|
-
hunk session navigate --repo . --file src/App.tsx --old-line 355
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Relative comment navigation jumps between annotated hunks and does not require `--file`:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
hunk session navigate --repo . --next-comment
|
|
70
|
-
hunk session navigate --repo . --prev-comment
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
- `--hunk <n>` is 1-based
|
|
74
|
-
- `--new-line` / `--old-line` are 1-based line numbers on that diff side
|
|
75
|
-
- Use either `--next-comment` or `--prev-comment`, not both
|
|
76
|
-
|
|
77
|
-
### Reload
|
|
78
|
-
|
|
79
|
-
Swaps the live session's contents. Pass a Hunk review command after `--`:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
hunk session reload --repo . -- diff
|
|
83
|
-
hunk session reload --repo . -- diff main...feature -- src/ui
|
|
84
|
-
hunk session reload --repo . -- show HEAD~1
|
|
85
|
-
hunk session reload --repo . -- show HEAD~1 -- README.md
|
|
86
|
-
hunk session reload --repo /path/to/worktree -- diff
|
|
87
|
-
hunk session reload --session-path /path/to/live-window --source /path/to/other-checkout -- diff
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- Always include `--` before the nested Hunk command
|
|
91
|
-
- `--repo` or `<session-id>` usually selects the session you want
|
|
92
|
-
- `--source` is advanced: it does not select the session; it only changes where the replacement review command runs
|
|
93
|
-
- If the live session is already showing the target worktree, prefer `hunk session reload --repo /path/to/worktree -- diff`
|
|
94
|
-
- `--session-path` targets the live window when you need to keep session selection separate from reload source
|
|
95
|
-
|
|
96
|
-
### Comments
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
hunk session comment add --repo . --file README.md --new-line 103 --summary "Tighten this wording" [--rationale "..."] [--author "agent"] [--focus]
|
|
100
|
-
printf '%s\n' '{"comments":[{"filePath":"README.md","newLine":103,"summary":"Tighten this wording"}]}' | hunk session comment apply --repo . --stdin [--focus]
|
|
101
|
-
hunk session comment list --repo . [--file README.md]
|
|
102
|
-
hunk session comment rm --repo . <comment-id>
|
|
103
|
-
hunk session comment clear --repo . --yes [--file README.md]
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
- `comment add` is best for one note; `comment apply` is best when an agent already has several notes ready
|
|
107
|
-
- `comment add` requires `--file`, `--summary`, and exactly one of `--old-line` or `--new-line`
|
|
108
|
-
- `comment apply` payload items require `filePath`, `summary`, and exactly one target such as `hunk`, `hunkNumber`, `oldLine`, or `newLine`
|
|
109
|
-
- `comment apply` reads a JSON batch from stdin and validates the full batch before mutating the live session
|
|
110
|
-
- Pass `--focus` when you want to jump to the new note or the first note in a batch
|
|
111
|
-
- `comment list` and `comment clear` accept optional `--file`
|
|
112
|
-
- Quote `--summary` and `--rationale` defensively in the shell
|
|
113
|
-
|
|
114
|
-
## New files in working-tree reviews
|
|
115
|
-
|
|
116
|
-
`hunk diff` includes untracked files by default. If the user wants tracked changes only, reload with `--exclude-untracked`:
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
hunk session reload --repo . -- diff --exclude-untracked
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Guiding a review
|
|
123
|
-
|
|
124
|
-
The user may ask you to walk them through a changeset or review code using Hunk. Start with `hunk session review --json` to understand the file/hunk structure without inflating agent context, then use `--include-patch` only for the files you truly need to read in raw diff form. Use `context` and `navigate` to line up the user's current view before adding comments.
|
|
125
|
-
|
|
126
|
-
Your role is to narrate: steer the user's view to what matters and leave comments that explain what they're looking at.
|
|
127
|
-
|
|
128
|
-
Typical flow:
|
|
129
|
-
|
|
130
|
-
1. Load the right content (`reload` if needed)
|
|
131
|
-
2. Navigate to the first interesting file / hunk
|
|
132
|
-
3. Add a comment explaining what's happening and why
|
|
133
|
-
4. If you already have several notes ready, prefer one `comment apply` batch over many separate shell invocations
|
|
134
|
-
5. Summarize when done
|
|
135
|
-
|
|
136
|
-
Guidelines:
|
|
137
|
-
|
|
138
|
-
- Work in the order that tells the clearest story, not necessarily file order
|
|
139
|
-
- Navigate before commenting so the user sees the code you're discussing
|
|
140
|
-
- Use `comment apply` for agent-generated batches and `comment add` for one-off notes
|
|
141
|
-
- Use `--focus` sparingly when the note itself should actively steer the review
|
|
142
|
-
- Keep comments focused: intent, structure, risks, or follow-ups
|
|
143
|
-
- Don't comment on every hunk -- highlight what the user wouldn't spot themselves
|
|
144
|
-
|
|
145
|
-
## Common errors
|
|
146
|
-
|
|
147
|
-
- **"No visible diff file matches ..."** -- the file is not in the loaded review. Check `context`, then `reload` if needed.
|
|
148
|
-
- **"No active Hunk sessions"** -- ask the user to open Hunk in their terminal.
|
|
149
|
-
- **"Multiple active sessions match"** -- pass `<session-id>` explicitly.
|
|
150
|
-
- **"No active Hunk session matches session path ..."** -- for advanced split-path reloads, verify the live window `Path` via `hunk session get` or `list`, then use `--session-path`.
|
|
151
|
-
- **"Pass the replacement Hunk command after `--`"** -- include `--` before the nested `diff` / `show` command.
|
|
152
|
-
- **"Pass --stdin to read batch comments from stdin JSON."** -- `comment apply` only reads its batch payload from stdin.
|
|
153
|
-
- **"Specify exactly one navigation target"** -- pick one of `--hunk`, `--old-line`, or `--new-line`.
|
|
154
|
-
- **"Specify either --next-comment or --prev-comment, not both."** -- choose one comment-navigation direction.
|