@eliya-oss/agent-diff 0.1.0-alpha.2 → 0.1.0-alpha.200
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/.agents/adr/README.md +3 -0
- package/.agents/prd/README.md +2 -2
- package/.claude/skills/create-pr/SKILL.md +164 -0
- package/.claude/skills/release-notes/SKILL.md +318 -0
- package/CHANGELOG.md +2108 -0
- package/README.md +27 -89
- package/bin/adiff.js +80 -2
- package/dist/grammars/css/LICENSE +21 -0
- package/dist/grammars/css/highlights.scm +76 -0
- package/dist/grammars/css/tree-sitter-css.wasm +0 -0
- package/dist/main.js +25548 -13125
- package/package.json +15 -8
- package/skills/adiff/SKILL.md +335 -33
package/package.json
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
"name": "@eliya-oss/agent-diff",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"devDependencies": {
|
|
5
|
-
"@effect/
|
|
5
|
+
"@effect/tsgo": "^0.31.0",
|
|
6
|
+
"@effect/vitest": "^4.0.0-rc.110",
|
|
6
7
|
"@types/node": "^26.1.2",
|
|
7
|
-
"effect": "^4.0.0-
|
|
8
|
-
"oxlint": "
|
|
8
|
+
"effect": "^4.0.0-rc.110",
|
|
9
|
+
"oxlint": "1.77.0",
|
|
10
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
9
11
|
"rolldown": "^1.2.1",
|
|
10
12
|
"vitest": "^4.1.10"
|
|
11
13
|
},
|
|
@@ -16,13 +18,13 @@
|
|
|
16
18
|
"@opentui/core": "^0.4.5"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
21
|
+
"node": ">=22"
|
|
20
22
|
},
|
|
21
23
|
"bin": {
|
|
22
24
|
"adiff": "./bin/adiff.js"
|
|
23
25
|
},
|
|
24
|
-
"version": "0.1.0-alpha.
|
|
25
|
-
"description": "Review
|
|
26
|
+
"version": "0.1.0-alpha.200",
|
|
27
|
+
"description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
|
|
26
28
|
"license": "MIT",
|
|
27
29
|
"repository": {
|
|
28
30
|
"type": "git",
|
|
@@ -41,7 +43,8 @@
|
|
|
41
43
|
"check": "pnpm run typecheck && pnpm run lint && pnpm run build && pnpm test",
|
|
42
44
|
"build": "rolldown -c rolldown.config.ts",
|
|
43
45
|
"typecheck": "tsc --noEmit",
|
|
44
|
-
"lint": "oxlint && node scripts/check-
|
|
46
|
+
"lint": "oxlint && node scripts/check-rules.ts && node scripts/check-film.ts && node scripts/check-public.ts",
|
|
47
|
+
"check-body": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/check-public.ts",
|
|
45
48
|
"test": "NODE_OPTIONS=--experimental-ffi vitest run",
|
|
46
49
|
"test:watch": "NODE_OPTIONS=--experimental-ffi vitest",
|
|
47
50
|
"dev": "node --experimental-ffi --disable-warning=ExperimentalWarning src/main.ts",
|
|
@@ -51,6 +54,10 @@
|
|
|
51
54
|
"sketch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/sketch.ts",
|
|
52
55
|
"watch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/watch.ts",
|
|
53
56
|
"serve": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/serve.ts",
|
|
54
|
-
"play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts"
|
|
57
|
+
"play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts",
|
|
58
|
+
"shot": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/shot.ts",
|
|
59
|
+
"pr-summary": "node scripts/pr-summary.ts",
|
|
60
|
+
"scenario": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/scenario.ts",
|
|
61
|
+
"record": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/record.ts"
|
|
55
62
|
}
|
|
56
63
|
}
|
package/skills/adiff/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: adiff
|
|
3
|
-
description: Pick up review comments left on this worktree's diff in the adiff terminal, act on them, and
|
|
3
|
+
description: Pick up review comments left on this worktree's diff in the adiff terminal, act on them, and answer them by id. Use when the user says they left comments, asks you to check adiff, asks you to watch for review feedback, or asks you to hand work over for review.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# adiff
|
|
@@ -24,16 +24,135 @@ Each comment carries the code it is about. `snippet` is the exact text the revie
|
|
|
24
24
|
`side` says whether the line numbers are in the new file (`new`) or the version being replaced
|
|
25
25
|
(`old`), and `head` is the commit the diff was read at.
|
|
26
26
|
|
|
27
|
-
A comment
|
|
27
|
+
A comment on code one of your layers explains carries `layer`, that layer's title as your latest
|
|
28
|
+
revision has it. The code the layer describes is about to change under your hands, so the layers go
|
|
29
|
+
stale the moment you act on the comment: write a new revision with `adiff layers set` before you
|
|
30
|
+
answer, and say in the answer that you did.
|
|
31
|
+
|
|
32
|
+
A comment keeps coming back until it is answered. A second plain `take` returns it again, so answer
|
|
33
|
+
what you take. Settling or removing it also retires it: those are the reviewer saying they no longer
|
|
34
|
+
need one.
|
|
35
|
+
|
|
36
|
+
## A remark is context, a comment is work
|
|
37
|
+
|
|
38
|
+
`adiff remark list --repo . --branch <branch>` reads the remarks left on the branch's pull request.
|
|
39
|
+
They are not yours to act on. A remark is somebody's point about the code, and the reviewer decides
|
|
40
|
+
what happens to it: accepting one writes a comment, and that comment is what reaches you through
|
|
41
|
+
`comment take`. Read remarks when the reviewer asks you to, or to understand a comment that answers
|
|
42
|
+
one. Never act on a remark that has not been accepted, and never accept one yourself.
|
|
28
43
|
|
|
29
44
|
## Wait for the next one
|
|
30
45
|
|
|
46
|
+
Start a session with a plain take, which collects everything still owed an answer:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
adiff comment take --worktree .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then listen for what comes next:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
adiff comment take --worktree . --new --wait 6900
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`--new` hands back only comments this review has not handed you before: a new comment, a reply to
|
|
59
|
+
one of your answers, or a comment the reviewer reopened or restored. Comments you already took
|
|
60
|
+
and are still working on never end the wait, so it wakes you only for something new. It blocks until
|
|
61
|
+
such a comment arrives or the timeout in seconds elapses, then returns the same envelope.
|
|
62
|
+
|
|
63
|
+
An empty `comments` array means only that the wait ran out. It is not an error and not news: run the
|
|
64
|
+
same wait again and say nothing to the user about it.
|
|
65
|
+
|
|
66
|
+
Run it in the background, never in the foreground. In Claude Code that is the Bash tool with
|
|
67
|
+
`run_in_background` and a `timeout` of 7200000. 6900 seconds keeps the wait under the harness's
|
|
68
|
+
two-hour limit on a background command, so it ends with an empty answer rather than being killed. A
|
|
69
|
+
foreground wait holds the turn, so you cannot do anything else and the person you are working with
|
|
70
|
+
cannot talk to you. Backgrounded, the harness brings you back the moment a comment lands.
|
|
71
|
+
|
|
72
|
+
Do not run it under a Monitor, do not re-arm a short wait on a timer, and do not schedule wakeups to
|
|
73
|
+
check on it. Each of those wakes you for nothing; the background wait already brings you back when a
|
|
74
|
+
comment arrives.
|
|
75
|
+
|
|
76
|
+
`--wait` takes a whole number of seconds from 1 to 86400. A value outside that is refused on
|
|
77
|
+
stderr with exit 2, because an instant empty answer would read exactly like a wait that expired:
|
|
78
|
+
if a wait comes back at once, you are not waiting.
|
|
79
|
+
|
|
80
|
+
Arm the wait as the first thing you do in a turn, before the work. A turn that is interrupted
|
|
81
|
+
half-way then still leaves a listener running, and a wait armed at the end of a turn is a wait that
|
|
82
|
+
often never gets armed.
|
|
83
|
+
|
|
84
|
+
Keep one wait per worktree. Two waits running at once hand the same comment to both, which is two of
|
|
85
|
+
you answering one comment. Before starting one, check whether one is already running.
|
|
86
|
+
|
|
87
|
+
Re-arm it as soon as it returns, before you handle what it returned, and keep it running while you
|
|
88
|
+
work. A reviewer reads at their own pace, so comments arrive minutes apart, and the whole point is
|
|
89
|
+
that they reach you as events rather than by you asking. When you finish a piece of work, say you are
|
|
90
|
+
still listening.
|
|
91
|
+
|
|
92
|
+
A backgrounded wait that is killed rather than expiring is not the reviewer going quiet, and not a
|
|
93
|
+
reason to stop listening. A kill loses nothing: taking is what records a comment as handed over, so a
|
|
94
|
+
comment that arrived after the kill is still new to the next `--new` wait. Arm a new one.
|
|
95
|
+
|
|
96
|
+
## Answering a comment
|
|
97
|
+
|
|
98
|
+
Say what you did, against the comment you were handed:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
adiff comment answer --worktree . --id <id> --body "Dropped it, and the import with it."
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The id comes from `comment take`. The reviewer sees the answer under their own words the next time
|
|
105
|
+
they read the branch, so this is how they learn a point was addressed rather than ignored.
|
|
106
|
+
|
|
107
|
+
Answer when the change alone does not carry the reasoning: what you did instead of what was asked,
|
|
108
|
+
what you found while doing it, or why the comment does not apply. A comment that asked a question
|
|
109
|
+
deserves an answer even when nothing changed.
|
|
110
|
+
|
|
111
|
+
Add `--question` when you need the reviewer to decide before you continue:
|
|
112
|
+
|
|
31
113
|
```bash
|
|
32
|
-
adiff comment
|
|
114
|
+
adiff comment answer --worktree . --id <id> --question --body "Drop it, or keep it and map the error?"
|
|
33
115
|
```
|
|
34
116
|
|
|
35
|
-
|
|
36
|
-
|
|
117
|
+
That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
|
|
118
|
+
the work genuinely stops without an answer.
|
|
119
|
+
|
|
120
|
+
When the answers you expect are few and short, offer them with `--choice`, two to four times. The
|
|
121
|
+
reviewer can pick one instead of typing it, and it reaches you as an ordinary reply carrying those
|
|
122
|
+
words. `--choice` marks the answer a question on its own:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
adiff comment answer --worktree . --id <id> --body "Drop it, or keep it and map the error?" --choice "Drop it" --choice "Keep it and map the error"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Say what you are doing on a comment
|
|
129
|
+
|
|
130
|
+
A comment that takes more than a minute looks to the reviewer exactly like one you dropped. After
|
|
131
|
+
you take it, say in one short line what you are doing on it, and say it again when that changes:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
adiff comment doing --worktree . --id <id> --body "Editing driver.ts"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The reviewer sees the latest line on the comment. Your answer clears it, so there is nothing to
|
|
138
|
+
take back when you finish. Keep it to what you are doing now, not a plan.
|
|
139
|
+
|
|
140
|
+
## When the reviewer writes back
|
|
141
|
+
|
|
142
|
+
A reviewer can reply to an answer, and the reply arrives through `comment take` like any other
|
|
143
|
+
comment — with an `id` of its own that you answer against, and a `thread` carrying what was said
|
|
144
|
+
before it, oldest first:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{"body":"the imports","replyTo":"c1","thread":[{"voice":"reviewer","body":"why two of these"},{"voice":"agent","body":"which two did you mean"}]}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Read the thread before answering. A reply is usually short because it is the rest of a sentence you
|
|
151
|
+
already have: "the imports" only means something next to the question it answers. Answer it against
|
|
152
|
+
its own id, not the id of the comment that started the thread.
|
|
153
|
+
|
|
154
|
+
Settling a thread is the reviewer's to do, not yours. They raised the point, so they decide it is
|
|
155
|
+
closed.
|
|
37
156
|
|
|
38
157
|
## Acting on a comment
|
|
39
158
|
|
|
@@ -41,11 +160,16 @@ Read `snippet` before opening the file: the reviewer commented on the diff, and
|
|
|
41
160
|
moved on since. If `head` no longer matches `git rev-parse --short HEAD`, the change you are being
|
|
42
161
|
asked about may already be gone — say so rather than guessing at what they meant.
|
|
43
162
|
|
|
44
|
-
Answer the comment by doing the work,
|
|
45
|
-
|
|
46
|
-
|
|
163
|
+
Answer the comment by doing the work, then say what you did with `adiff comment answer`, by id.
|
|
164
|
+
The reviewer is watching the diff, and the diff is read from the working tree, so an edit shows the
|
|
165
|
+
moment they read the branch again: no commit is needed for them to see it. Do not commit once per
|
|
166
|
+
comment. Commit when the work forms a change you would want as a commit anyway, and let one commit
|
|
167
|
+
answer as many comments as it addresses. When a comment is a question rather than a request, answer
|
|
168
|
+
it with `adiff comment answer` too; an answer written into a commit message never reaches the
|
|
169
|
+
reviewer's screen.
|
|
47
170
|
|
|
48
|
-
Handle every comment in the batch
|
|
171
|
+
Handle every comment in the batch. The `--new` wait you re-armed does not hand them back, so a
|
|
172
|
+
comment you skip waits for your next plain take.
|
|
49
173
|
|
|
50
174
|
## Failure
|
|
51
175
|
|
|
@@ -54,25 +178,89 @@ Failures go to **stderr**, never stdout, so stdout is always safe to parse. The
|
|
|
54
178
|
what kind of problem it is: `2` the request was malformed, `3` the branch or file does not exist,
|
|
55
179
|
`1` something unexpected.
|
|
56
180
|
|
|
181
|
+
Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
|
|
182
|
+
`--branch <name>`. Standing in the worktree, `--worktree .` is always enough.
|
|
183
|
+
|
|
57
184
|
Read `suggestion` before doing anything else — it names the command that resolves the failure.
|
|
58
185
|
Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
|
|
59
186
|
about, because the reviewer has not opened it; report that rather than looping.
|
|
60
187
|
|
|
61
|
-
## Handing work over
|
|
188
|
+
## Handing work over
|
|
189
|
+
|
|
190
|
+
Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
|
|
191
|
+
them if they asked for one, and say how to read it. That is the whole handover. A first reading order
|
|
192
|
+
is extra work you do on request, and it has its own section further down. A reading order that
|
|
193
|
+
already exists is different: keep it current before you say the work is ready, without being asked.
|
|
194
|
+
|
|
195
|
+
## Put the review in front of them
|
|
196
|
+
|
|
197
|
+
When someone asks you for a review, open it rather than describing how:
|
|
62
198
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
199
|
+
```bash
|
|
200
|
+
adiff review pane --repo <repo> --branch <branch>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
It splits the pane they are already looking at, so their next move is to look right rather than to
|
|
204
|
+
type. The answer says what happened:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api --branch add-invitations"}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
In Harbor the review opens as a child terminal under yours instead of a split. `opened:false` means
|
|
211
|
+
nothing could be split, which is ordinary: a terminal without tmux, Zellij, WezTerm, kitty or Harbor
|
|
212
|
+
has nowhere to put a pane. The answer carries `command` either way, so quote that
|
|
213
|
+
line and let them run it.
|
|
214
|
+
|
|
215
|
+
Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
|
|
216
|
+
someone's screen uninvited is worse than a line they have to copy.
|
|
217
|
+
|
|
218
|
+
## Tell the reviewer how to read it
|
|
219
|
+
|
|
220
|
+
Whether or not a pane opened, say what to do with it. Name the repository they should point at,
|
|
221
|
+
which is the repository the worktree belongs to:
|
|
222
|
+
|
|
223
|
+
> Open it with `adiff review open --repo <repo> --branch <branch>`, which lands on this branch's
|
|
224
|
+
> diff. The sidebar lists the files; `j` and `k` move down the diff, `]` and `[` walk between
|
|
225
|
+
> files, `}` and `{` jump to the next and previous change, `G` goes to the end. Select lines with
|
|
226
|
+
> `v`, write a comment with `c`, and send it with `ctrl+s`. Press `?` for the rest.
|
|
227
|
+
|
|
228
|
+
Fill the repository path and the branch in yourself, so nobody has to compose the command or find
|
|
229
|
+
the branch in a list. `--branch` takes the name `branch list` reports; without it the review opens
|
|
230
|
+
on the worktree list.
|
|
231
|
+
|
|
232
|
+
Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
|
|
233
|
+
doubt spends their attention there. When the branch has no reading order, offer one rather than
|
|
234
|
+
writing one: if the change is long enough that the order matters, say you can publish one and let
|
|
235
|
+
them decide.
|
|
236
|
+
|
|
237
|
+
## Publishing a reading order, when you are asked for one
|
|
238
|
+
|
|
239
|
+
Write a first reading order only when the reviewer asks. A reading order is a real piece of work, it
|
|
240
|
+
can be wrong, and one nobody wanted spends their attention on your summary rather than on the code.
|
|
241
|
+
Once one exists, keeping it current is not a new ask: see the next section.
|
|
242
|
+
|
|
243
|
+
The ask often arrives as a comment. Pressing `L` in the review sends you one of these:
|
|
244
|
+
|
|
245
|
+
- "Please write a reading order for this branch with `adiff layers set` …" — there is none yet.
|
|
246
|
+
- "The reading order on this branch describes an older commit …" — read the diff again from
|
|
247
|
+
scratch. Do not patch the old layers; line numbers have moved.
|
|
248
|
+
- "Please revise the reading order …" — there is one and the reviewer wants it different. Ask what
|
|
249
|
+
is wrong with it if the comment does not say.
|
|
250
|
+
|
|
251
|
+
Answer it like any other comment when you are done.
|
|
252
|
+
|
|
253
|
+
When they do ask, write **layers**: an ordered set over the diff, each one a claim about a span of
|
|
66
254
|
code. The reviewer then walks the argument instead of the filesystem.
|
|
67
255
|
|
|
68
256
|
```bash
|
|
69
|
-
adiff
|
|
257
|
+
adiff layers set --worktree . --json - <<'JSON'
|
|
70
258
|
{
|
|
71
259
|
"summary": "Team invitations, end to end",
|
|
72
|
-
"
|
|
260
|
+
"layers": [
|
|
73
261
|
{
|
|
74
262
|
"title": "Add the invitation data model",
|
|
75
|
-
"note": "The record every later
|
|
263
|
+
"note": "The record every later layer leans on.\n- `expiresAt` is required; nothing reads a missing one\n- One open invitation per email, enforced by an index",
|
|
76
264
|
"spans": [{ "path": "src/db/invites.ts", "start": 1, "end": 48 }]
|
|
77
265
|
},
|
|
78
266
|
{
|
|
@@ -91,35 +279,148 @@ adiff story set --worktree . --json - <<'JSON'
|
|
|
91
279
|
JSON
|
|
92
280
|
```
|
|
93
281
|
|
|
94
|
-
Rules that make a
|
|
282
|
+
Rules that make a layers worth reading:
|
|
95
283
|
|
|
96
|
-
- **Order is the point.**
|
|
284
|
+
- **Order is the point.** Layer 1 is what the reader must understand before layer 2 makes sense.
|
|
97
285
|
Data model, then the code that uses it, then the surface, then the mechanical bits last.
|
|
98
286
|
- **A title is a claim, not a file name.** "Add the invitation API", never "changes to
|
|
99
287
|
src/api/invites.ts".
|
|
100
288
|
- **Line numbers are the new side of the diff**, the same numbers `adiff comment take` reports.
|
|
101
|
-
- **
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
289
|
+
- **A note is a lead and a few points, not a paragraph.** The first line says how to read the
|
|
290
|
+
layer or what it claims, in one clause. Then up to four lines, each starting `- `, each one
|
|
291
|
+
decision or surprise the reviewer would otherwise miss. About 220 characters in all. Put names
|
|
292
|
+
from code in backticks, and a newline between points, not semicolons. Leave out the file list
|
|
293
|
+
(the review shows it), asides in parentheses (make one its own point if it matters) and anything
|
|
294
|
+
the title already says.
|
|
295
|
+
- **Cover everything.** adiff computes coverage itself and answers with the changed lines no layer
|
|
296
|
+
claims; those show up for the reviewer under "not in any layer" whatever you do. A layer set that
|
|
297
|
+
quietly skips a third of the diff is worse than none, so put the leftovers in a final layer and
|
|
298
|
+
say they are mechanical. Claim the lines you actually read: a span reaching past them counts only
|
|
299
|
+
the changed lines inside it, so padding the range buys nothing.
|
|
300
|
+
|
|
301
|
+
The answer to `layers set` is the honest report — check it before you claim to be done:
|
|
302
|
+
|
|
303
|
+
```json
|
|
304
|
+
{"ok":true,"layers":{"version":1,"stale":false,"covered":7,"partial":1,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"layers":[{"title":"Add the invitation data model","files":["src/db/invites.ts"],"covered":1,"partial":0,"added":42,"removed":3,"vanished":[]}]}}
|
|
305
|
+
|
|
306
|
+
`covered`, `partial` and `vanished` appear per layer as well as for the document, so you can tell
|
|
307
|
+
which of your own layers is the thin one. `vanished` on a layer names paths it claims that are not
|
|
308
|
+
in the diff — usually a typo or a file that moved.
|
|
309
|
+
|
|
310
|
+
`added` and `removed` on a layer count the changed lines inside its own spans, a removed line by its
|
|
311
|
+
old line number. A line two layers both claim counts in each.
|
|
312
|
+
|
|
313
|
+
`layers set` refuses a document it cannot use and says which layer is wrong and why: a span that
|
|
314
|
+
ends before it starts, a span starting below line 1, a start or end that is not a whole number, a
|
|
315
|
+
block with no `kind`, a layer with no title. It no longer drops a bad span quietly, so a layer that
|
|
316
|
+
used to cover less than you thought now fails loudly instead.
|
|
317
|
+
```
|
|
105
318
|
|
|
106
|
-
|
|
319
|
+
`total` counts hunks. `covered` counts the ones where every changed line sits inside a layer, and
|
|
320
|
+
`partial` the ones a layer explains only some of. `uncovered` names the runs of changed lines no
|
|
321
|
+
layer claims, so it reads as line numbers a reviewer would otherwise have to find alone: claim them
|
|
322
|
+
and set the layers again. Done means `uncovered` is empty and `shared` is zero. `vanished` names
|
|
323
|
+
paths a layer points at that this branch does not change, which usually means a typo in a path. Read
|
|
324
|
+
it back at any time with:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
adiff layers show --worktree . --fields covered,partial,total,uncovered
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
`uncovered` does not always empty out by claiming lines you can see. A deleted line is counted at
|
|
331
|
+
the number it had in the old file, so a branch that cuts a file from 409 lines to 394 reports an
|
|
332
|
+
uncovered run at 395-409 — line numbers past the end of the file as it now stands. A span over the
|
|
333
|
+
new file cannot reach them; only a span whose `end` runs past the end of the file can. Write one, or
|
|
334
|
+
say the run is unreachable, rather than reading the leftover as a layer you forgot.
|
|
335
|
+
|
|
336
|
+
That case aside, claim the runs you explain and nothing more. A span from line 1 to past the end of
|
|
337
|
+
the file covers whatever happens to it, and it is the wrong trade: the terminal scopes a layer to the
|
|
338
|
+
lines it claims, so a layer claiming the whole file draws the whole diff, and eleven layers over one
|
|
339
|
+
file draw it eleven times. Staleness is cheap by comparison — adiff says when a set is stale and the
|
|
340
|
+
reviewer asks for another.
|
|
341
|
+
|
|
342
|
+
`shared` in the answer counts the hunks more than one layer claims. Coverage cannot see this: a
|
|
343
|
+
reading order whose layers each claim the whole diff reports the same `covered` as one whose layers
|
|
344
|
+
each claim their own run. Done means `uncovered` is empty **and** `shared` is zero.
|
|
345
|
+
|
|
346
|
+
Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
|
|
347
|
+
was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
|
|
348
|
+
reviewer has a reading order, keep it true, as the next section says.
|
|
349
|
+
|
|
350
|
+
When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
|
|
351
|
+
the files, each layer shows the files it covers with the ones already reviewed ticked off, and `]`
|
|
352
|
+
and `[` walk those files in the order you put them in — from the last file of one layer into the
|
|
353
|
+
first of the next.
|
|
354
|
+
|
|
355
|
+
## Keep an existing reading order current, unasked
|
|
356
|
+
|
|
357
|
+
Once a branch has layers, check them after each change you make (a commit, an answered comment, a
|
|
358
|
+
rebase) and before you say the work is ready:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
adiff layers show --worktree . --fields stale,uncovered,shared,vanished
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
If `uncovered` is not empty, `stale` is true or `vanished` names a path, write a new revision with
|
|
365
|
+
`adiff layers set` right away. Put new runs into the layer whose claim they serve, and add a final
|
|
366
|
+
layer only for lines that serve none. When the base moved, read the diff again rather than patching
|
|
367
|
+
line numbers. Done means `uncovered` is empty and `shared` is zero.
|
|
368
|
+
|
|
369
|
+
Do it silently: it is upkeep, not news, so do not ask first and do not report it unless the reviewer
|
|
370
|
+
asks. `NoLayers` (exit 3) means the branch has no reading order, and then you write one only when
|
|
371
|
+
asked.
|
|
372
|
+
|
|
373
|
+
## Helping draft a review of somebody else's pull request
|
|
374
|
+
|
|
375
|
+
Sometimes the reviewer is not reading your work — they are reading a stranger's pull request,
|
|
376
|
+
checked out into this worktree, and want you to think it through with them before they say anything
|
|
377
|
+
on it. You learn that from the comment itself: a comment written on somebody else's pull request
|
|
378
|
+
carries `"theirs": true`. Read it before anything else you do with the comment.
|
|
107
379
|
|
|
108
380
|
```json
|
|
109
|
-
{"
|
|
381
|
+
{"id":"c7","file":"src/retry.ts","start":40,"end":52,"snippet":"…","body":"is this retry loop safe?","theirs":true}
|
|
110
382
|
```
|
|
111
383
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
384
|
+
On such a branch the code is not yours to change. **Never edit, commit or push.** A comment that
|
|
385
|
+
reads like a fix request is a point the reviewer wants made to the author: answer it with
|
|
386
|
+
`comment answer`, in prose, and put the wording the author should read in a draft. A comment with
|
|
387
|
+
no `theirs` is your own work, and the rest of this skill applies.
|
|
388
|
+
|
|
389
|
+
A note to the author is **held** as a draft. Nothing reaches the forge until the reviewer sends it.
|
|
115
390
|
|
|
116
391
|
```bash
|
|
117
|
-
adiff
|
|
392
|
+
adiff draft list --repo . --branch their-change
|
|
393
|
+
adiff draft add --repo . --branch their-change --file src/api.ts --start 40 --end 52 --body "…"
|
|
394
|
+
adiff draft edit --repo . --branch their-change --id d1 --body "…"
|
|
395
|
+
adiff draft drop --repo . --branch their-change --id d1
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
`draft add` anchors the same way `comment send` does, so `--side old` is the version being replaced.
|
|
399
|
+
The `id` you pass to `draft edit` and `draft drop` is the one `draft list` reports.
|
|
400
|
+
|
|
401
|
+
A comment can ask you to rewrite one draft in particular. It carries `"draft": "<id>"` beside
|
|
402
|
+
`theirs`, and its body is the instruction:
|
|
403
|
+
|
|
404
|
+
```json
|
|
405
|
+
{"id":"c8","body":"shorter, and less sure","theirs":true,"draft":"4f1c…"}
|
|
118
406
|
```
|
|
119
407
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
408
|
+
Rewrite that draft with `draft edit`, then answer the comment by its id, saying what you changed. A
|
|
409
|
+
draft you wrote or rewrote reads as unread in the review until the reviewer opens it, and the review
|
|
410
|
+
will not send while one is unread, so say you rewrote it rather than leaving the reviewer to notice.
|
|
411
|
+
|
|
412
|
+
Rules for drafting on somebody else's behalf:
|
|
413
|
+
|
|
414
|
+
- **You never write to the pull request.** `draft send`, `remark reply` and `remark accept` all do,
|
|
415
|
+
and every one is the reviewer's, not yours. The reviewer signs the review, so the reviewer sends
|
|
416
|
+
it. Anything that must reach the pull request goes through a draft.
|
|
417
|
+
- **Write what the reviewer meant, not what you would say.** They told you the point; your job is
|
|
418
|
+
the wording. If you are not sure what the point is, ask rather than inventing one.
|
|
419
|
+
- **One draft per point.** A held comment that covers three things cannot be dropped in part.
|
|
420
|
+
- **Say what you drafted.** List the drafts back after you write them, so the reviewer can read
|
|
421
|
+
them over rather than discovering them at the moment of sending.
|
|
422
|
+
- **A draft is not a review of the reviewer.** Do not soften a point they meant sharply, or sharpen
|
|
423
|
+
one they meant gently.
|
|
123
424
|
|
|
124
425
|
## Discovering the rest
|
|
125
426
|
|
|
@@ -127,8 +428,9 @@ you address a review, write the story again.
|
|
|
127
428
|
adiff describe
|
|
128
429
|
```
|
|
129
430
|
|
|
130
|
-
Returns every command with its options, which are required,
|
|
131
|
-
|
|
431
|
+
Returns every command with its options, which are required, which part of the loop it belongs to,
|
|
432
|
+
and where its payload sits. `adiff <command> --help` says the same for one command in plain text.
|
|
433
|
+
Use either instead of guessing, and use `--fields` to keep answers small:
|
|
132
434
|
|
|
133
435
|
```bash
|
|
134
436
|
adiff branch list --repo . --fields branch,files
|