@eliya-oss/agent-diff 0.1.0-alpha.15 → 0.1.0-alpha.151

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