@eliya-oss/agent-diff 0.1.0-alpha.13 → 0.1.0-alpha.131

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.13",
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.131",
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",
@@ -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
 
@@ -39,6 +41,10 @@ Run the wait in the background, not in the foreground. A foreground wait holds t
39
41
  cannot do anything else and the person you are working with cannot talk to you. Backgrounded, the
40
42
  harness brings you back the moment a comment lands.
41
43
 
44
+ Keep one wait per worktree. A second wait returns the same comments as the first, so two of them
45
+ running at once is two of you answering the same comment. Before starting one, check whether one is
46
+ already running.
47
+
42
48
  Re-arm it after each comment you handle, and keep it running while you work. A reviewer reads at
43
49
  their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
44
50
  events rather than by you asking. When you finish a piece of work, say you are still listening.
@@ -58,15 +64,29 @@ Answer when the change alone does not carry the reasoning: what you did instead
58
64
  what you found while doing it, or why the comment does not apply. A comment that asked a question
59
65
  deserves an answer even when nothing changed.
60
66
 
61
- Add `--asks` when you need the reviewer to decide before you continue:
67
+ Add `--question` when you need the reviewer to decide before you continue:
62
68
 
63
69
  ```bash
64
- adiff comment answer --worktree . --id <id> --asks --body "Drop it, or keep it and map the error?"
70
+ adiff comment answer --worktree . --id <id> --question --body "Drop it, or keep it and map the error?"
65
71
  ```
66
72
 
67
73
  That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
68
74
  the work genuinely stops without an answer.
69
75
 
76
+ ## When the reviewer writes back
77
+
78
+ A reviewer can reply to an answer, and the reply arrives through `comment take` like any other
79
+ comment — with an `id` of its own that you answer against, and a `thread` carrying what was said
80
+ before it, oldest first:
81
+
82
+ ```json
83
+ {"body":"the imports","replyTo":"c1","thread":[{"voice":"reviewer","body":"why two of these"},{"voice":"agent","body":"which two did you mean"}]}
84
+ ```
85
+
86
+ Read the thread before answering. A reply is usually short because it is the rest of a sentence you
87
+ already have: "the imports" only means something next to the question it answers. Answer it against
88
+ its own id, not the id of the comment that started the thread.
89
+
70
90
  Settling a thread is the reviewer's to do, not yours. They raised the point, so they decide it is
71
91
  closed.
72
92
 
@@ -89,15 +109,75 @@ Failures go to **stderr**, never stdout, so stdout is always safe to parse. The
89
109
  what kind of problem it is: `2` the request was malformed, `3` the branch or file does not exist,
90
110
  `1` something unexpected.
91
111
 
112
+ Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
113
+ `--branch <name>`. Standing in the worktree, `--worktree .` is always enough.
114
+
92
115
  Read `suggestion` before doing anything else — it names the command that resolves the failure.
93
116
  Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
94
117
  about, because the reviewer has not opened it; report that rather than looping.
95
118
 
96
- ## Handing work over: write the layers
119
+ ## Handing work over
120
+
121
+ Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
122
+ them if they asked for one, and say how to read it. That is the whole handover. A reading order is
123
+ extra work you do on request, and it has its own section further down.
124
+
125
+ ## Put the review in front of them
126
+
127
+ When someone asks you for a review, open it rather than describing how:
128
+
129
+ ```bash
130
+ adiff review pane --repo <repo> --branch <branch>
131
+ ```
132
+
133
+ It splits the pane they are already looking at, so their next move is to look right rather than to
134
+ type. The answer says what happened:
135
+
136
+ ```json
137
+ {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api --branch cdr-1"}
138
+ ```
139
+
140
+ `opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
141
+ WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
142
+ line and let them run it.
143
+
144
+ Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
145
+ someone's screen uninvited is worse than a line they have to copy.
97
146
 
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
147
+ ## Tell the reviewer how to read it
148
+
149
+ Whether or not a pane opened, say what to do with it. Name the repository they should point at,
150
+ which is the repository the worktree belongs to:
151
+
152
+ > Open it with `adiff review open --repo <repo> --branch <branch>`, which lands on this branch's
153
+ > diff. The sidebar lists the files; `j` and `k` move down the diff, `]` and `[` walk between
154
+ > files, `}` and `{` jump to the next and previous change, `G` goes to the end. Select lines with
155
+ > `v`, write a comment with `c`, and send it with `ctrl+s`. Press `?` for the rest.
156
+
157
+ Fill the repository path and the branch in yourself, so nobody has to compose the command or find
158
+ the branch in a list. `--branch` takes the name `branch list` reports; without it the review opens
159
+ on the worktree list.
160
+
161
+ Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
162
+ doubt spends their attention there. Offer a reading order rather than writing one: if the change is
163
+ long enough that the order matters, say you can publish one and let them decide.
164
+
165
+ ## Publishing a reading order, when you are asked for one
166
+
167
+ Only when the reviewer asks. A reading order is a real piece of work, it can be wrong, and one
168
+ nobody wanted spends their attention on your summary rather than on the code.
169
+
170
+ The ask often arrives as a comment. Pressing `L` in the review sends you one of these:
171
+
172
+ - "Please write a reading order for this branch with `adiff layers set` …" — there is none yet.
173
+ - "The reading order on this branch describes an older commit …" — read the diff again from
174
+ scratch. Do not patch the old layers; line numbers have moved.
175
+ - "Please revise the reading order …" — there is one and the reviewer wants it different. Ask what
176
+ is wrong with it if the comment does not say.
177
+
178
+ Answer it like any other comment when you are done.
179
+
180
+ When they do ask, write **layers**: an ordered set over the diff, each one a claim about a span of
101
181
  code. The reviewer then walks the argument instead of the filesystem.
102
182
 
103
183
  ```bash
@@ -133,42 +213,75 @@ Rules that make a layers worth reading:
133
213
  - **A title is a claim, not a file name.** "Add the invitation API", never "changes to
134
214
  src/api/invites.ts".
135
215
  - **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.
216
+ - **Cover everything.** adiff computes coverage itself and answers with the changed lines no layer
217
+ claims; those show up for the reviewer under "not in any layer" whatever you do. A layer set that
218
+ quietly skips a third of the diff is worse than none, so put the leftovers in a final layer and
219
+ say they are mechanical. Claim the lines you actually read: a span reaching past them counts only
220
+ the changed lines inside it, so padding the range buys nothing.
140
221
 
141
222
  The answer to `layers set` is the honest report — check it before you claim to be done:
142
223
 
143
224
  ```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"]}]}}
225
+ {"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":[]}]}}
226
+
227
+ `covered`, `partial` and `vanished` appear per layer as well as for the document, so you can tell
228
+ which of your own layers is the thin one. `vanished` on a layer names paths it claims that are not
229
+ in the diff — usually a typo or a file that moved.
230
+
231
+ `layers set` refuses a document it cannot use and says which layer is wrong and why: a span that
232
+ ends before it starts, a span starting below line 1, a start or end that is not a whole number, a
233
+ block with no `kind`, a layer with no title. It no longer drops a bad span quietly, so a layer that
234
+ used to cover less than you thought now fails loudly instead.
145
235
  ```
146
236
 
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:
237
+ `total` counts hunks. `covered` counts the ones where every changed line sits inside a layer, and
238
+ `partial` the ones a layer explains only some of. `uncovered` names the runs of changed lines no
239
+ layer claims, so it reads as line numbers a reviewer would otherwise have to find alone: claim them
240
+ and set the layers again. Done means `uncovered` is empty. `vanished` names paths a layer points at
241
+ that this branch does not change, which usually means a typo in a path. Read it back at any time
242
+ with:
150
243
 
151
244
  ```bash
152
- adiff layers show --worktree . --fields covered,total,uncovered
245
+ adiff layers show --worktree . --fields covered,partial,total,uncovered
153
246
  ```
154
247
 
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.
248
+ Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
249
+ was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
250
+ reviewer has a reading order, keep it true: write it again after you address their comments.
158
251
 
159
- ## Tell the reviewer how to read it
252
+ When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
253
+ the files, each layer shows the files it covers with the ones already reviewed ticked off, and `]`
254
+ and `[` walk those files in the order you put them in — from the last file of one layer into the
255
+ first of the next.
256
+
257
+ ## Helping draft a review of somebody else's pull request
258
+
259
+ Sometimes the reviewer is not reading your work — they are reading a stranger's pull request and
260
+ want you to think it through with them before they say anything on it. There, a comment is not an
261
+ instruction to you. It is a draft of what the reviewer will say, in the reviewer's name.
262
+
263
+ Comments on a pull request are **held**. Nothing reaches the forge until the reviewer sends them.
264
+
265
+ ```bash
266
+ adiff draft list --repo . --branch their-change
267
+ adiff draft add --repo . --branch their-change --file src/api.ts --start 40 --end 52 --body "…"
268
+ adiff draft edit --repo . --branch their-change --id d1 --body "…"
269
+ adiff draft drop --repo . --branch their-change --id d1
270
+ ```
160
271
 
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:
272
+ `draft add` anchors the same way `comment send` does, so `--side old` is the version being replaced.
164
273
 
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.
274
+ Rules for drafting on somebody else's behalf:
169
275
 
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.
276
+ - **You never send.** There is no command that dispatches, on purpose. The reviewer signs the
277
+ review, so the reviewer sends it.
278
+ - **Write what the reviewer meant, not what you would say.** They told you the point; your job is
279
+ the wording. If you are not sure what the point is, ask rather than inventing one.
280
+ - **One draft per point.** A held comment that covers three things cannot be dropped in part.
281
+ - **Say what you drafted.** List the drafts back after you write them, so the reviewer can read
282
+ them over rather than discovering them at the moment of sending.
283
+ - **A draft is not a review of the reviewer.** Do not soften a point they meant sharply, or sharpen
284
+ one they meant gently.
172
285
 
173
286
  ## Discovering the rest
174
287
 
@@ -176,8 +289,9 @@ doubt spends their attention there.
176
289
  adiff describe
177
290
  ```
178
291
 
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:
292
+ Returns every command with its options, which are required, which part of the loop it belongs to,
293
+ and where its payload sits. `adiff <command> --help` says the same for one command in plain text.
294
+ Use either instead of guessing, and use `--fields` to keep answers small:
181
295
 
182
296
  ```bash
183
297
  adiff branch list --repo . --fields branch,files