@eliya-oss/agent-diff 0.1.0-alpha.14 → 0.1.0-alpha.141

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/package.json CHANGED
@@ -2,10 +2,12 @@
2
2
  "name": "@eliya-oss/agent-diff",
3
3
  "type": "module",
4
4
  "devDependencies": {
5
- "@effect/vitest": "^4.0.0-beta.102",
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-beta.102",
8
- "oxlint": "^1.76.0",
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
  },
@@ -21,8 +23,8 @@
21
23
  "bin": {
22
24
  "adiff": "./bin/adiff.js"
23
25
  },
24
- "version": "0.1.0-alpha.14",
25
- "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
+ "version": "0.1.0-alpha.141",
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,7 @@
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-style.ts",
46
+ "lint": "oxlint && node scripts/check-rules.ts",
45
47
  "test": "NODE_OPTIONS=--experimental-ffi vitest run",
46
48
  "test:watch": "NODE_OPTIONS=--experimental-ffi vitest",
47
49
  "dev": "node --experimental-ffi --disable-warning=ExperimentalWarning src/main.ts",
@@ -51,6 +53,10 @@
51
53
  "sketch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/sketch.ts",
52
54
  "watch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/watch.ts",
53
55
  "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"
56
+ "play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts",
57
+ "shot": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/shot.ts",
58
+ "pr-summary": "node scripts/pr-summary.ts",
59
+ "scenario": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/scenario.ts",
60
+ "record": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/record.ts"
55
61
  }
56
62
  }
@@ -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 write the layers that explains the diff. 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.
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,7 +24,9 @@ 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 is handed over exactly once. A second `take` returns only what was written since.
27
+ A comment keeps coming back until it is answered. A second `take` returns it again, so answer what
28
+ you take. Settling or removing it also retires it: those are the reviewer saying they no longer
29
+ need one.
28
30
 
29
31
  ## Wait for the next one
30
32
 
@@ -35,14 +37,30 @@ adiff comment take --worktree . --wait 300
35
37
  Blocks until a comment arrives or the timeout in seconds elapses, then returns the same envelope.
36
38
  An empty `comments` array means the wait expired with nothing new — that is not an error.
37
39
 
40
+ `--wait` takes a whole number of seconds from 1 to 86400. A value outside that is refused on
41
+ stderr with exit 2, because an instant empty answer would read exactly like a wait that expired:
42
+ if a wait comes back at once, you are not waiting.
43
+
44
+ Arm the wait as the first thing you do in a turn, before the work. A turn that is interrupted
45
+ half-way then still leaves a listener running, and a wait armed at the end of a turn is a wait that
46
+ often never gets armed.
47
+
38
48
  Run the wait in the background, not in the foreground. A foreground wait holds the turn, so you
39
49
  cannot do anything else and the person you are working with cannot talk to you. Backgrounded, the
40
50
  harness brings you back the moment a comment lands.
41
51
 
52
+ Keep one wait per worktree. A second wait returns the same comments as the first, so two of them
53
+ running at once is two of you answering the same comment. Before starting one, check whether one is
54
+ already running.
55
+
42
56
  Re-arm it after each comment you handle, and keep it running while you work. A reviewer reads at
43
57
  their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
44
58
  events rather than by you asking. When you finish a piece of work, say you are still listening.
45
59
 
60
+ A backgrounded wait that is killed rather than expiring is not the reviewer going quiet, and not a
61
+ reason to stop listening. A kill loses whatever the wait would have handed you, so take once
62
+ without `--wait` to collect what landed, then arm a new wait.
63
+
46
64
  ## Answering a comment
47
65
 
48
66
  Say what you did, against the comment you were handed:
@@ -58,15 +76,29 @@ Answer when the change alone does not carry the reasoning: what you did instead
58
76
  what you found while doing it, or why the comment does not apply. A comment that asked a question
59
77
  deserves an answer even when nothing changed.
60
78
 
61
- Add `--asks` when you need the reviewer to decide before you continue:
79
+ Add `--question` when you need the reviewer to decide before you continue:
62
80
 
63
81
  ```bash
64
- adiff comment answer --worktree . --id <id> --asks --body "Drop it, or keep it and map the error?"
82
+ adiff comment answer --worktree . --id <id> --question --body "Drop it, or keep it and map the error?"
65
83
  ```
66
84
 
67
85
  That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
68
86
  the work genuinely stops without an answer.
69
87
 
88
+ ## When the reviewer writes back
89
+
90
+ A reviewer can reply to an answer, and the reply arrives through `comment take` like any other
91
+ comment — with an `id` of its own that you answer against, and a `thread` carrying what was said
92
+ before it, oldest first:
93
+
94
+ ```json
95
+ {"body":"the imports","replyTo":"c1","thread":[{"voice":"reviewer","body":"why two of these"},{"voice":"agent","body":"which two did you mean"}]}
96
+ ```
97
+
98
+ Read the thread before answering. A reply is usually short because it is the rest of a sentence you
99
+ already have: "the imports" only means something next to the question it answers. Answer it against
100
+ its own id, not the id of the comment that started the thread.
101
+
70
102
  Settling a thread is the reviewer's to do, not yours. They raised the point, so they decide it is
71
103
  closed.
72
104
 
@@ -89,15 +121,75 @@ Failures go to **stderr**, never stdout, so stdout is always safe to parse. The
89
121
  what kind of problem it is: `2` the request was malformed, `3` the branch or file does not exist,
90
122
  `1` something unexpected.
91
123
 
124
+ Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
125
+ `--branch <name>`. Standing in the worktree, `--worktree .` is always enough.
126
+
92
127
  Read `suggestion` before doing anything else — it names the command that resolves the failure.
93
128
  Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
94
129
  about, because the reviewer has not opened it; report that rather than looping.
95
130
 
96
- ## Handing work over: write the layers
131
+ ## Handing work over
132
+
133
+ Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
134
+ them if they asked for one, and say how to read it. That is the whole handover. A reading order is
135
+ extra work you do on request, and it has its own section further down.
136
+
137
+ ## Put the review in front of them
138
+
139
+ When someone asks you for a review, open it rather than describing how:
140
+
141
+ ```bash
142
+ adiff review pane --repo <repo> --branch <branch>
143
+ ```
144
+
145
+ It splits the pane they are already looking at, so their next move is to look right rather than to
146
+ type. The answer says what happened:
147
+
148
+ ```json
149
+ {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api --branch add-invitations"}
150
+ ```
151
+
152
+ `opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
153
+ WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
154
+ line and let them run it.
155
+
156
+ Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
157
+ someone's screen uninvited is worse than a line they have to copy.
97
158
 
98
- You know the order the change was built in. The reviewer does not, and rebuilding it by reading
99
- every file is the most expensive way to learn something you already have. When you finish a piece
100
- of work, write a **layers**: an ordered set of layers over the diff, each one a claim about a span of
159
+ ## Tell the reviewer how to read it
160
+
161
+ Whether or not a pane opened, say what to do with it. Name the repository they should point at,
162
+ which is the repository the worktree belongs to:
163
+
164
+ > Open it with `adiff review open --repo <repo> --branch <branch>`, which lands on this branch's
165
+ > diff. The sidebar lists the files; `j` and `k` move down the diff, `]` and `[` walk between
166
+ > files, `}` and `{` jump to the next and previous change, `G` goes to the end. Select lines with
167
+ > `v`, write a comment with `c`, and send it with `ctrl+s`. Press `?` for the rest.
168
+
169
+ Fill the repository path and the branch in yourself, so nobody has to compose the command or find
170
+ the branch in a list. `--branch` takes the name `branch list` reports; without it the review opens
171
+ on the worktree list.
172
+
173
+ Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
174
+ doubt spends their attention there. Offer a reading order rather than writing one: if the change is
175
+ long enough that the order matters, say you can publish one and let them decide.
176
+
177
+ ## Publishing a reading order, when you are asked for one
178
+
179
+ Only when the reviewer asks. A reading order is a real piece of work, it can be wrong, and one
180
+ nobody wanted spends their attention on your summary rather than on the code.
181
+
182
+ The ask often arrives as a comment. Pressing `L` in the review sends you one of these:
183
+
184
+ - "Please write a reading order for this branch with `adiff layers set` …" — there is none yet.
185
+ - "The reading order on this branch describes an older commit …" — read the diff again from
186
+ scratch. Do not patch the old layers; line numbers have moved.
187
+ - "Please revise the reading order …" — there is one and the reviewer wants it different. Ask what
188
+ is wrong with it if the comment does not say.
189
+
190
+ Answer it like any other comment when you are done.
191
+
192
+ When they do ask, write **layers**: an ordered set over the diff, each one a claim about a span of
101
193
  code. The reviewer then walks the argument instead of the filesystem.
102
194
 
103
195
  ```bash
@@ -133,42 +225,84 @@ Rules that make a layers worth reading:
133
225
  - **A title is a claim, not a file name.** "Add the invitation API", never "changes to
134
226
  src/api/invites.ts".
135
227
  - **Line numbers are the new side of the diff**, the same numbers `adiff comment take` reports.
136
- - **Cover everything.** adiff computes coverage itself and answers with the hunks no layer claims;
137
- those show up for the reviewer under "not in any layer" whatever you do. A layers that quietly
138
- skips a third of the diff is worse than no layers, so put the leftovers in a final layer and say
139
- they are mechanical.
228
+ - **Cover everything.** adiff computes coverage itself and answers with the changed lines no layer
229
+ claims; those show up for the reviewer under "not in any layer" whatever you do. A layer set that
230
+ quietly skips a third of the diff is worse than none, so put the leftovers in a final layer and
231
+ say they are mechanical. Claim the lines you actually read: a span reaching past them counts only
232
+ the changed lines inside it, so padding the range buys nothing.
140
233
 
141
234
  The answer to `layers set` is the honest report — check it before you claim to be done:
142
235
 
143
236
  ```json
144
- {"ok":true,"layers":{"version":1,"stale":false,"covered":7,"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"]}]}}
237
+ {"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,"vanished":[]}]}}
238
+
239
+ `covered`, `partial` and `vanished` appear per layer as well as for the document, so you can tell
240
+ which of your own layers is the thin one. `vanished` on a layer names paths it claims that are not
241
+ in the diff — usually a typo or a file that moved.
242
+
243
+ `layers set` refuses a document it cannot use and says which layer is wrong and why: a span that
244
+ ends before it starts, a span starting below line 1, a start or end that is not a whole number, a
245
+ block with no `kind`, a layer with no title. It no longer drops a bad span quietly, so a layer that
246
+ used to cover less than you thought now fails loudly instead.
145
247
  ```
146
248
 
147
- `covered`/`total` count hunks. `uncovered` names the ones no layer claims — claim them and set the
148
- layers again. `vanished` names paths a layer points at that this branch does not change, which
149
- usually means a typo in a path. Read it back at any time with:
249
+ `total` counts hunks. `covered` counts the ones where every changed line sits inside a layer, and
250
+ `partial` the ones a layer explains only some of. `uncovered` names the runs of changed lines no
251
+ layer claims, so it reads as line numbers a reviewer would otherwise have to find alone: claim them
252
+ and set the layers again. Done means `uncovered` is empty. `vanished` names paths a layer points at
253
+ that this branch does not change, which usually means a typo in a path. Read it back at any time
254
+ with:
150
255
 
151
256
  ```bash
152
- adiff layers show --worktree . --fields covered,total,uncovered
257
+ adiff layers show --worktree . --fields covered,partial,total,uncovered
153
258
  ```
154
259
 
155
- Setting a layers again supersedes the previous one and bumps `version`; the layers records the commit
156
- it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
157
- you address a review, write the layers again.
260
+ `uncovered` does not always empty out by claiming lines you can see. A deleted line is counted at
261
+ the number it had in the old file, so a branch that cuts a file from 409 lines to 394 reports an
262
+ uncovered run at 395-409 — line numbers past the end of the file as it now stands. A span over the
263
+ new file cannot reach them; only a span whose `end` runs past the end of the file can. Write one, or
264
+ say the run is unreachable, rather than reading the leftover as a layer you forgot.
158
265
 
159
- ## Tell the reviewer how to read it
266
+ That is also the case for spans generally: `start` 1 to past the last line covers a file whatever
267
+ happens to it, while a tight range goes stale on the next push that moves the lines under it.
268
+
269
+ Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
270
+ was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
271
+ reviewer has a reading order, keep it true: write it again after you address their comments.
272
+
273
+ When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
274
+ the files, each layer shows the files it covers with the ones already reviewed ticked off, and `]`
275
+ and `[` walk those files in the order you put them in — from the last file of one layer into the
276
+ first of the next.
277
+
278
+ ## Helping draft a review of somebody else's pull request
279
+
280
+ Sometimes the reviewer is not reading your work — they are reading a stranger's pull request and
281
+ want you to think it through with them before they say anything on it. There, a comment is not an
282
+ instruction to you. It is a draft of what the reviewer will say, in the reviewer's name.
283
+
284
+ Comments on a pull request are **held**. Nothing reaches the forge until the reviewer sends them.
285
+
286
+ ```bash
287
+ adiff draft list --repo . --branch their-change
288
+ adiff draft add --repo . --branch their-change --file src/api.ts --start 40 --end 52 --body "…"
289
+ adiff draft edit --repo . --branch their-change --id d1 --body "…"
290
+ adiff draft drop --repo . --branch their-change --id d1
291
+ ```
160
292
 
161
- The person you are handing work to has to open the review themselves, so end your reply with the
162
- command and the keys. Name the repository they should point at, which is the repository the
163
- worktree belongs to:
293
+ `draft add` anchors the same way `comment send` does, so `--side old` is the version being replaced.
164
294
 
165
- > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
166
- > lists the layers in reading order; `j` and `k` move between them and the diff follows. Inside a
167
- > layer, `]` and `[` walk its files. Select lines with `v`, write a comment with `c`, stage it with
168
- > `ctrl+a`, and send the whole review with `S`. Press `?` for the rest.
295
+ Rules for drafting on somebody else's behalf:
169
296
 
170
- Say what you want looked at hardest, and where you are unsure. A reviewer who knows which layer you
171
- doubt spends their attention there.
297
+ - **You never send.** There is no command that dispatches, on purpose. The reviewer signs the
298
+ review, so the reviewer sends it.
299
+ - **Write what the reviewer meant, not what you would say.** They told you the point; your job is
300
+ the wording. If you are not sure what the point is, ask rather than inventing one.
301
+ - **One draft per point.** A held comment that covers three things cannot be dropped in part.
302
+ - **Say what you drafted.** List the drafts back after you write them, so the reviewer can read
303
+ them over rather than discovering them at the moment of sending.
304
+ - **A draft is not a review of the reviewer.** Do not soften a point they meant sharply, or sharpen
305
+ one they meant gently.
172
306
 
173
307
  ## Discovering the rest
174
308
 
@@ -176,8 +310,9 @@ doubt spends their attention there.
176
310
  adiff describe
177
311
  ```
178
312
 
179
- Returns every command with its options, which are required, and where its payload sits. Use it
180
- instead of guessing, and use `--fields` to keep answers small:
313
+ Returns every command with its options, which are required, which part of the loop it belongs to,
314
+ and where its payload sits. `adiff <command> --help` says the same for one command in plain text.
315
+ Use either instead of guessing, and use `--fields` to keep answers small:
181
316
 
182
317
  ```bash
183
318
  adiff branch list --repo . --fields branch,files