@eliya-oss/agent-diff 0.1.0-alpha.30 → 0.1.0-alpha.32
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/CHANGELOG.md +12 -0
- package/README.md +2 -1
- package/dist/main.js +42 -23
- package/package.json +1 -1
- package/skills/adiff/SKILL.md +69 -51
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- The skill publishes a reading order on request, and tells the reviewer how to open the review.
|
|
8
|
+
|
|
9
|
+
## 0.1.0-alpha.31
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Coverage counts the changed lines a layer claims, not the hunks a span touches.
|
|
14
|
+
|
|
3
15
|
## 0.1.0-alpha.30
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -64,7 +64,8 @@ A comment is handed over exactly once, so a second `take` returns only what was
|
|
|
64
64
|
## The reading order
|
|
65
65
|
|
|
66
66
|
An agent knows the order it built a change in. Rebuilding that order by reading forty files is the
|
|
67
|
-
expensive way to learn something it already has, so it can publish the reading itself
|
|
67
|
+
expensive way to learn something it already has, so it can publish the reading itself when you ask
|
|
68
|
+
for one:
|
|
68
69
|
|
|
69
70
|
```bash
|
|
70
71
|
adiff layers set --worktree . --json -
|
package/dist/main.js
CHANGED
|
@@ -17143,8 +17143,11 @@ const INSTRUCTIONS = [
|
|
|
17143
17143
|
"",
|
|
17144
17144
|
"Review of work in this repository happens in adiff. Before you say you are done, run",
|
|
17145
17145
|
"`adiff comment take --worktree . --wait 300` in the background and handle what arrives.",
|
|
17146
|
-
"Answer a comment with `adiff comment answer --worktree . --id <id> --body <text
|
|
17147
|
-
"
|
|
17146
|
+
"Answer a comment with `adiff comment answer --worktree . --id <id> --body <text>`.",
|
|
17147
|
+
"When you hand work over, say it is ready and name the command that opens the review:",
|
|
17148
|
+
"`adiff review open --repo <repo>`, or `adiff review pane --repo <repo>` to open it alongside.",
|
|
17149
|
+
"Publish a reading order with `adiff layers set` only when you are asked for one.",
|
|
17150
|
+
"`adiff describe` lists the rest.",
|
|
17148
17151
|
END
|
|
17149
17152
|
].join("\n");
|
|
17150
17153
|
const IMPORT = [
|
|
@@ -17409,29 +17412,43 @@ const spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({
|
|
|
17409
17412
|
start,
|
|
17410
17413
|
end
|
|
17411
17414
|
})));
|
|
17412
|
-
const
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17415
|
+
const changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
|
|
17416
|
+
onNone: () => [],
|
|
17417
|
+
onSome: (line) => [line]
|
|
17418
|
+
}));
|
|
17419
|
+
const holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
|
|
17420
|
+
const runsOf = (path, lines) => {
|
|
17421
|
+
const runs = [];
|
|
17422
|
+
for (const line of lines.toSorted((a, b) => a - b)) {
|
|
17423
|
+
const open = runs.at(-1);
|
|
17424
|
+
if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
|
|
17425
|
+
else runs.push({
|
|
17426
|
+
path,
|
|
17427
|
+
start: line,
|
|
17428
|
+
end: line
|
|
17429
|
+
});
|
|
17430
|
+
}
|
|
17431
|
+
return runs;
|
|
17432
|
+
};
|
|
17433
|
+
const tallyOf = (patch, hunk, claimed) => {
|
|
17434
|
+
const changed = changedLines(hunk);
|
|
17435
|
+
const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
|
|
17436
|
+
const whole = changed.length > 0 && loose.length === 0;
|
|
17437
|
+
const some = loose.length > 0 && loose.length < changed.length;
|
|
17438
|
+
return {
|
|
17439
|
+
covered: whole ? 1 : 0,
|
|
17440
|
+
partial: some ? 1 : 0,
|
|
17441
|
+
missing: runsOf(patch.path, loose)
|
|
17442
|
+
};
|
|
17422
17443
|
};
|
|
17423
|
-
const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
|
|
17424
17444
|
const coverage = (patches, layers) => {
|
|
17425
17445
|
const claimed = spansOf$1(layers);
|
|
17426
|
-
const
|
|
17427
|
-
onNone: () => [],
|
|
17428
|
-
onSome: (s) => [s]
|
|
17429
|
-
})));
|
|
17430
|
-
const missing = hunks.filter((hunk) => !claimed.some((span) => overlaps(span, hunk)));
|
|
17446
|
+
const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
|
|
17431
17447
|
return {
|
|
17432
|
-
total:
|
|
17433
|
-
covered:
|
|
17434
|
-
|
|
17448
|
+
total: tallies.length,
|
|
17449
|
+
covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
|
|
17450
|
+
partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
|
|
17451
|
+
missing: tallies.flatMap((tally) => tally.missing)
|
|
17435
17452
|
};
|
|
17436
17453
|
};
|
|
17437
17454
|
const withFullCoverage = (patches, layers) => {
|
|
@@ -17441,7 +17458,7 @@ const withFullCoverage = (patches, layers) => {
|
|
|
17441
17458
|
title: REMAINDER_TITLE,
|
|
17442
17459
|
blocks: [{
|
|
17443
17460
|
kind: "prose",
|
|
17444
|
-
markdown: `${gap.missing.length}
|
|
17461
|
+
markdown: `${gap.missing.length} runs of changed lines the agent did not account for.`
|
|
17445
17462
|
}, ...gap.missing.map((span) => codeBlockOf$1(span))]
|
|
17446
17463
|
};
|
|
17447
17464
|
return {
|
|
@@ -17491,6 +17508,7 @@ const statusOf = (patches, layers, branchHead) => {
|
|
|
17491
17508
|
uncovered: gap.missing,
|
|
17492
17509
|
vanished: [...mentioned].filter((path) => !present.has(path)),
|
|
17493
17510
|
covered: gap.covered,
|
|
17511
|
+
partial: gap.partial,
|
|
17494
17512
|
total: gap.total
|
|
17495
17513
|
};
|
|
17496
17514
|
};
|
|
@@ -17592,6 +17610,7 @@ const reportOf = (patches, layers, branchHead) => {
|
|
|
17592
17610
|
written: layers.written,
|
|
17593
17611
|
summary: layers.summary,
|
|
17594
17612
|
covered: status.covered,
|
|
17613
|
+
partial: status.partial,
|
|
17595
17614
|
total: status.total,
|
|
17596
17615
|
uncovered: status.uncovered,
|
|
17597
17616
|
vanished: status.vanished,
|
|
@@ -18207,7 +18226,7 @@ const banner = () => [
|
|
|
18207
18226
|
"",
|
|
18208
18227
|
" adiff comment take --worktree . --wait 300 block until a comment arrives",
|
|
18209
18228
|
" adiff comment answer --worktree . --id <id> --body '…'",
|
|
18210
|
-
" adiff layers set --worktree . --json - publish
|
|
18229
|
+
" adiff layers set --worktree . --json - publish a reading order, when asked",
|
|
18211
18230
|
"",
|
|
18212
18231
|
"Every comment carries an id, and an answer goes back to the reviewer under it.",
|
|
18213
18232
|
"",
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"bin": {
|
|
24
24
|
"adiff": "./bin/adiff.js"
|
|
25
25
|
},
|
|
26
|
-
"version": "0.1.0-alpha.
|
|
26
|
+
"version": "0.1.0-alpha.32",
|
|
27
27
|
"description": "A code review your agent can answer: comments carry ids, the agent replies under them, and it publishes the reading order for its own diff.",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|
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
|
|
@@ -93,11 +93,56 @@ Read `suggestion` before doing anything else — it names the command that resol
|
|
|
93
93
|
Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
|
|
94
94
|
about, because the reviewer has not opened it; report that rather than looping.
|
|
95
95
|
|
|
96
|
-
## Handing work over
|
|
96
|
+
## Handing work over
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
|
|
99
|
+
them if they asked for one, and say how to read it. That is the whole handover. A reading order is
|
|
100
|
+
extra work you do on request, and it has its own section further down.
|
|
101
|
+
|
|
102
|
+
## Put the review in front of them
|
|
103
|
+
|
|
104
|
+
When someone asks you for a review, open it rather than describing how:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
adiff review pane --repo <repo>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
It splits the pane they are already looking at, so their next move is to look right rather than to
|
|
111
|
+
type. The answer says what happened:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
|
|
118
|
+
WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
|
|
119
|
+
line and let them run it.
|
|
120
|
+
|
|
121
|
+
Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
|
|
122
|
+
someone's screen uninvited is worse than a line they have to copy.
|
|
123
|
+
|
|
124
|
+
## Tell the reviewer how to read it
|
|
125
|
+
|
|
126
|
+
Whether or not a pane opened, say what to do with it. Name the repository they should point at,
|
|
127
|
+
which is the repository the worktree belongs to:
|
|
128
|
+
|
|
129
|
+
> Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
|
|
130
|
+
> lists the files; `j` and `k` move down the diff, `]` and `[` walk between files. Select lines with
|
|
131
|
+
> `v`, write a comment with `c`, stage it with `ctrl+a`, and send the whole review with `S`. Press
|
|
132
|
+
> `?` for the rest.
|
|
133
|
+
|
|
134
|
+
Fill the repository path in yourself so nobody has to compose the command.
|
|
135
|
+
|
|
136
|
+
Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
|
|
137
|
+
doubt spends their attention there. Offer a reading order rather than writing one: if the change is
|
|
138
|
+
long enough that the order matters, say you can publish one and let them decide.
|
|
139
|
+
|
|
140
|
+
## Publishing a reading order, when you are asked for one
|
|
141
|
+
|
|
142
|
+
Only when the reviewer asks. A reading order is a real piece of work, it can be wrong, and one
|
|
143
|
+
nobody wanted spends their attention on your summary rather than on the code.
|
|
144
|
+
|
|
145
|
+
When they do ask, write **layers**: an ordered set over the diff, each one a claim about a span of
|
|
101
146
|
code. The reviewer then walks the argument instead of the filesystem.
|
|
102
147
|
|
|
103
148
|
```bash
|
|
@@ -133,63 +178,36 @@ Rules that make a layers worth reading:
|
|
|
133
178
|
- **A title is a claim, not a file name.** "Add the invitation API", never "changes to
|
|
134
179
|
src/api/invites.ts".
|
|
135
180
|
- **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
|
|
137
|
-
those show up for the reviewer under "not in any layer" whatever you do. A
|
|
138
|
-
skips a third of the diff is worse than
|
|
139
|
-
they are mechanical.
|
|
181
|
+
- **Cover everything.** adiff computes coverage itself and answers with the changed lines no layer
|
|
182
|
+
claims; those show up for the reviewer under "not in any layer" whatever you do. A layer set that
|
|
183
|
+
quietly skips a third of the diff is worse than none, so put the leftovers in a final layer and
|
|
184
|
+
say they are mechanical. Claim the lines you actually read: a span reaching past them counts only
|
|
185
|
+
the changed lines inside it, so padding the range buys nothing.
|
|
140
186
|
|
|
141
187
|
The answer to `layers set` is the honest report — check it before you claim to be done:
|
|
142
188
|
|
|
143
189
|
```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"]}]}}
|
|
145
|
-
```
|
|
146
|
-
|
|
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:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
adiff layers show --worktree . --fields covered,total,uncovered
|
|
190
|
+
{"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"]}]}}
|
|
153
191
|
```
|
|
154
192
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
When someone asks you for a review, open it rather than describing how:
|
|
193
|
+
`total` counts hunks. `covered` counts the ones where every changed line sits inside a layer, and
|
|
194
|
+
`partial` the ones a layer explains only some of. `uncovered` names the runs of changed lines no
|
|
195
|
+
layer claims, so it reads as line numbers a reviewer would otherwise have to find alone: claim them
|
|
196
|
+
and set the layers again. Done means `uncovered` is empty. `vanished` names paths a layer points at
|
|
197
|
+
that this branch does not change, which usually means a typo in a path. Read it back at any time
|
|
198
|
+
with:
|
|
162
199
|
|
|
163
200
|
```bash
|
|
164
|
-
adiff
|
|
201
|
+
adiff layers show --worktree . --fields covered,partial,total,uncovered
|
|
165
202
|
```
|
|
166
203
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
```json
|
|
171
|
-
{"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
`opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
|
|
175
|
-
WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
|
|
176
|
-
line and let them run it.
|
|
177
|
-
|
|
178
|
-
Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
|
|
179
|
-
someone's screen uninvited is worse than a line they have to copy.
|
|
180
|
-
|
|
181
|
-
## Tell the reviewer how to read it
|
|
182
|
-
|
|
183
|
-
Whether or not a pane opened, say what to do with it. Name the repository they should point at,
|
|
184
|
-
which is the repository the worktree belongs to:
|
|
185
|
-
|
|
186
|
-
> Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
|
|
187
|
-
> lists the layers in reading order; `j` and `k` move between them and the diff follows. Inside a
|
|
188
|
-
> layer, `]` and `[` walk its files. Select lines with `v`, write a comment with `c`, stage it with
|
|
189
|
-
> `ctrl+a`, and send the whole review with `S`. Press `?` for the rest.
|
|
204
|
+
Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
|
|
205
|
+
was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
|
|
206
|
+
reviewer has a reading order, keep it true: write it again after you address their comments.
|
|
190
207
|
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
|
|
209
|
+
the files, `j` and `k` move between layers with the diff following, and `]` and `[` walk the files
|
|
210
|
+
inside a layer.
|
|
193
211
|
|
|
194
212
|
## Discovering the rest
|
|
195
213
|
|