@eliya-oss/agent-diff 0.1.0-alpha.195 → 0.1.0-alpha.197

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.197
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(layers): `layers show` and `layers set` give every layer `added` and `removed`, the changed lines inside its own spans.
8
+
9
+ feat(layers rail): a folded layer's count line carries the lines it adds and removes, next to how many of its files are read.
10
+
11
+ feat(layers): `layers show` says which layer is `done` and which one is the `unclaimed` layer of lines no layer claims.
12
+
13
+ ## 0.1.0-alpha.196
14
+
15
+ ### Patch Changes
16
+
17
+ - feat(CLI): `comment take --new` hands over only comments the review has not handed over before, so a `--wait` ends on a new comment, a reply, or a thread reopened or restored rather than on one the agent is already working on.
18
+
19
+ <details><summary>What was wrong</summary>
20
+
21
+ A wait returned at once whenever any comment was still owed an answer, so an agent listening in the background was woken again and again by the comment it was already working on.
22
+
23
+ </details>
24
+
3
25
  ## 0.1.0-alpha.195
4
26
 
5
27
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10083,7 +10083,7 @@ var init_config = __esmMin((() => {
10083
10083
  //#region package.json
10084
10084
  init_pane();
10085
10085
  init_config();
10086
- var version$1 = "0.1.0-alpha.195";
10086
+ var version$1 = "0.1.0-alpha.197";
10087
10087
  //#endregion
10088
10088
  //#region src/cli/error.ts
10089
10089
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
@@ -10602,14 +10602,23 @@ var init_catalog = __esmMin((() => {
10602
10602
  group: ANSWER_COMMENTS,
10603
10603
  addresses: "review",
10604
10604
  safety: "read",
10605
- options: [...addressing, {
10606
- name: "wait",
10607
- required: false,
10608
- value: "seconds",
10609
- about: `Block until a comment arrives or the timeout elapses. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10610
- }],
10605
+ options: [
10606
+ ...addressing,
10607
+ {
10608
+ name: "wait",
10609
+ required: false,
10610
+ value: "seconds",
10611
+ about: `Block until a comment arrives or the timeout elapses. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10612
+ },
10613
+ {
10614
+ name: "new",
10615
+ required: false,
10616
+ value: "flag",
10617
+ about: "Hand over only comments this review has not handed over before, so a wait ends on something new"
10618
+ }
10619
+ ],
10611
10620
  dataKey: "comments",
10612
- example: "adiff comment take --worktree . --wait 300"
10621
+ example: "adiff comment take --worktree . --new --wait 6900"
10613
10622
  },
10614
10623
  {
10615
10624
  name: "comment answer",
@@ -12852,11 +12861,12 @@ var init_service$1 = __esmMin((() => {
12852
12861
  }
12853
12862
  });
12854
12863
  cursorOps = (state, inbox, spoken, changeState) => {
12855
- const owedIn = fn("Store.owedIn")(function* (worktreePath) {
12864
+ const handedIn = fn("Store.handedIn")(function* (worktreePath, handing) {
12856
12865
  const batches = yield* inbox(worktreePath);
12857
12866
  const current = yield* state(worktreePath);
12858
12867
  const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
12859
- const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id);
12868
+ const taken = current.taken ?? {};
12869
+ const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id) && (handing === "owed" || !Object.hasOwn(taken, comment.id));
12860
12870
  return batches.flatMap((batch) => {
12861
12871
  const comments = batch.comments.filter(owed);
12862
12872
  return comments.length === 0 ? [] : [{
@@ -12867,9 +12877,10 @@ var init_service$1 = __esmMin((() => {
12867
12877
  }];
12868
12878
  });
12869
12879
  });
12880
+ const owedIn = (worktreePath) => handedIn(worktreePath, "owed");
12870
12881
  return {
12871
- take: fn("Store.take")(function* (worktreePath, at) {
12872
- const batches = yield* owedIn(worktreePath);
12882
+ take: fn("Store.take")(function* (worktreePath, at, handing = "owed") {
12883
+ const batches = yield* handedIn(worktreePath, handing);
12873
12884
  const ids = idsIn$1(batches);
12874
12885
  if (ids.length > 0) yield* changeState(worktreePath, takes(ids, at));
12875
12886
  return batches;
@@ -13556,7 +13567,7 @@ var init_model$3 = __esmMin((() => {
13556
13567
  }));
13557
13568
  //#endregion
13558
13569
  //#region src/domain/layers/coverage.ts
13559
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
13570
+ var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, claimedRow, claimedRows, linesClaimed, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
13560
13571
  var init_coverage = __esmMin((() => {
13561
13572
  init_dist();
13562
13573
  init_model$3();
@@ -13613,6 +13624,23 @@ var init_coverage = __esmMin((() => {
13613
13624
  return last !== void 0 && last.end >= line;
13614
13625
  };
13615
13626
  claimedBy = (reaches, changed) => changed.some((line) => reaching(reaches, line));
13627
+ claimedRow = (reaches, row) => row.kind !== "context" && match$3(orElse(row.newLine, () => row.oldLine), {
13628
+ onNone: () => false,
13629
+ onSome: (line) => reaching(reaches, line)
13630
+ });
13631
+ claimedRows = (claims, patch) => {
13632
+ const reaches = claims.get(patch.path) ?? NOTHING;
13633
+ if (reaches.length === 0) return [];
13634
+ return patch.hunks.flatMap((hunk) => hunk.rows).filter((row) => claimedRow(reaches, row));
13635
+ };
13636
+ linesClaimed = (patches, layer) => {
13637
+ const claims = claimsOf(spansOf$1([layer]));
13638
+ const rows = patches.flatMap((patch) => claimedRows(claims, patch));
13639
+ return {
13640
+ added: rows.filter((row) => row.kind === "added").length,
13641
+ removed: rows.filter((row) => row.kind === "removed").length
13642
+ };
13643
+ };
13616
13644
  runsOf = (path, lines) => {
13617
13645
  const runs = [];
13618
13646
  for (const line of lines.toSorted((a, b) => a - b)) {
@@ -14135,12 +14163,12 @@ var init_comments$1 = __esmMin((() => {
14135
14163
  onSome: (held) => held.layers
14136
14164
  });
14137
14165
  });
14138
- take = fn("Review.Comment.take")(function* (worktreePath) {
14166
+ take = fn("Review.Comment.take")(function* (worktreePath, handing = "owed") {
14139
14167
  const store = yield* Store;
14140
14168
  const resolved = yield* realOf(worktreePath);
14141
14169
  const at = (/* @__PURE__ */ new Date()).toISOString();
14142
14170
  yield* ignore(store.noteWatching(resolved, at));
14143
- const owed = flatten(yield* store.take(resolved, at));
14171
+ const owed = flatten(yield* store.take(resolved, at, handing));
14144
14172
  if (owed.length === 0) return owed;
14145
14173
  const layers = yield* layersOn(resolved);
14146
14174
  const under = (one) => {
@@ -14153,7 +14181,7 @@ var init_comments$1 = __esmMin((() => {
14153
14181
  const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
14154
14182
  return owed.map(carried).map(under);
14155
14183
  });
14156
- awaitTaken = (worktreePath, deadline) => take(worktreePath).pipe(flatMap((comments) => comments.length > 0 || Date.now() >= deadline ? succeed$1(comments) : sleep(POLL).pipe(flatMap(() => awaitTaken(worktreePath, deadline)))));
14184
+ awaitTaken = (worktreePath, deadline, handing = "owed") => take(worktreePath, handing).pipe(flatMap((comments) => comments.length > 0 || Date.now() >= deadline ? succeed$1(comments) : sleep(POLL).pipe(flatMap(() => awaitTaken(worktreePath, deadline, handing)))));
14157
14185
  markRead = fn("Review.Comment.markRead")(function* (worktree, id) {
14158
14186
  const store = yield* Store;
14159
14187
  const spoken = yield* store.answers(worktree.path);
@@ -14370,7 +14398,8 @@ var init_threads$1 = __esmMin((() => {
14370
14398
  yield* store.changeState(worktree.path, (was) => ({
14371
14399
  ...was,
14372
14400
  settled: without$1(was.settled, id),
14373
- read: without$1(was.read, id)
14401
+ read: without$1(was.read, id),
14402
+ taken: without$1(was.taken ?? {}, id)
14374
14403
  }));
14375
14404
  return { unsettled: id };
14376
14405
  });
@@ -14397,7 +14426,8 @@ var init_threads$1 = __esmMin((() => {
14397
14426
  yield* known(worktree, id);
14398
14427
  yield* store.changeState(worktree.path, (was) => ({
14399
14428
  ...was,
14400
- removed: without$1(was.removed, id)
14429
+ removed: without$1(was.removed, id),
14430
+ taken: without$1(was.taken ?? {}, id)
14401
14431
  }));
14402
14432
  return { restored: id };
14403
14433
  });
@@ -15631,9 +15661,10 @@ var init_layers = __esmMin((() => {
15631
15661
  });
15632
15662
  reportedLayers = (patches, layers) => {
15633
15663
  const present = new Set(patches.map((patch) => patch.path));
15634
- return withFullCoverage(patches, layers).layers.map((layer) => {
15664
+ return withFullCoverage(patches, layers).layers.map((layer, at) => {
15635
15665
  const named = unique(spansOfLayer(layer).map((span) => span.path));
15636
15666
  const gap = coverage(patches, [layer]);
15667
+ const lines = linesClaimed(patches, layer);
15637
15668
  return {
15638
15669
  title: layer.title,
15639
15670
  note: noteOf(layer),
@@ -15642,7 +15673,10 @@ var init_layers = __esmMin((() => {
15642
15673
  prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path)),
15643
15674
  covered: gap.covered,
15644
15675
  partial: gap.partial,
15645
- vanished: named.filter((path) => !present.has(path))
15676
+ added: lines.added,
15677
+ removed: lines.removed,
15678
+ vanished: named.filter((path) => !present.has(path)),
15679
+ unclaimed: at >= layers.layers.length
15646
15680
  };
15647
15681
  });
15648
15682
  };
@@ -15698,10 +15732,13 @@ var init_layers = __esmMin((() => {
15698
15732
  });
15699
15733
  withRead = (report, reading) => ({
15700
15734
  ...report,
15701
- layers: report.layers.map((layer) => ({
15702
- ...layer,
15703
- read: readInLayer(layer, reading)
15704
- }))
15735
+ layers: report.layers.map((layer) => {
15736
+ const read = readInLayer(layer, reading);
15737
+ return Object.assign({}, layer, {
15738
+ read,
15739
+ done: layer.files.length > 0 && read.length === layer.files.length
15740
+ });
15741
+ })
15705
15742
  });
15706
15743
  show$1 = fn("Review.Layers.show")(function* (worktree) {
15707
15744
  const store = yield* Store;
@@ -16226,7 +16263,8 @@ const banner = () => [
16226
16263
  "",
16227
16264
  "An agent working in that worktree answers them:",
16228
16265
  "",
16229
- " adiff comment take --worktree . --wait 300 block until a comment arrives",
16266
+ " adiff comment take --worktree . collect every comment owed an answer",
16267
+ " adiff comment take --worktree . --new --wait 6900 block until a new comment arrives",
16230
16268
  " adiff comment answer --worktree . --id <id> --body '…'",
16231
16269
  " adiff layers set --worktree . --json - publish a reading order, when asked",
16232
16270
  "",
@@ -18345,7 +18383,7 @@ var init_words = __esmMin((() => {
18345
18383
  return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
18346
18384
  };
18347
18385
  clip = (label, room) => label.length > room ? `${label.slice(0, Math.max(0, room - 1))}…` : label;
18348
- })), proseFor, layerHolding, layerOpen, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, NOTHING_LEFT, textRows, emptyRows, layerBody, holdsCursor, layerCard, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
18386
+ })), proseFor, layerHolding, layerOpen, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, NOTHING_LEFT, textRows, linesSaid, countRow, emptyRows, layerBody, holdsCursor, layerCard, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
18349
18387
  var init_layerview = __esmMin((() => {
18350
18388
  init_files();
18351
18389
  init_layout();
@@ -18431,18 +18469,6 @@ var init_layerview = __esmMin((() => {
18431
18469
  const read = layerRead(state, layerIndex);
18432
18470
  return read.all > 0 && read.done === read.all;
18433
18471
  };
18434
- countRow = (state, index, room) => {
18435
- const read = layerRead(state, index);
18436
- if (read.all === 0) return [];
18437
- const one = read.all === 1 ? "file" : "files";
18438
- const said = `${read.done} of ${read.all} ${one} read`;
18439
- return [{
18440
- index,
18441
- kind: "count",
18442
- text: clip(said, room),
18443
- lead: false
18444
- }];
18445
- };
18446
18472
  NOTHING_LEFT = "nothing in this diff";
18447
18473
  textRows = (index, text, room, kind) => wrapped(text, room).map((line) => ({
18448
18474
  index,
@@ -18450,6 +18476,18 @@ var init_layerview = __esmMin((() => {
18450
18476
  text: line,
18451
18477
  lead: false
18452
18478
  }));
18479
+ linesSaid = (layer) => {
18480
+ if (layer === void 0) return "";
18481
+ const signs = [...layer.added > 0 ? [`+${layer.added}`] : [], ...layer.removed > 0 ? [`−${layer.removed}`] : []];
18482
+ return signs.length === 0 ? "" : ` · ${signs.join(" ")}`;
18483
+ };
18484
+ countRow = (state, index, room) => {
18485
+ const read = layerRead(state, index);
18486
+ if (read.all === 0) return [];
18487
+ const one = read.all === 1 ? "file" : "files";
18488
+ const said = `${read.done} of ${read.all} ${one} read${linesSaid(state.layers[index])}`;
18489
+ return textRows(index, said, room, "count");
18490
+ };
18453
18491
  emptyRows = (state, index, room) => {
18454
18492
  const layer = state.layers[index];
18455
18493
  if (layer === void 0) return [];
@@ -26038,11 +26076,12 @@ const commentReply = fn("Main.commentReply")(function* (options) {
26038
26076
  });
26039
26077
  yield* answer(options, { batch });
26040
26078
  });
26041
- const NOTHING_WAITING = "No comment is waiting. Pass --wait <seconds> to block until one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26079
+ const NOTHING_WAITING = "No comment is waiting. Pass --new --wait <seconds> to block until a new one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26042
26080
  const commentTake = fn("Main.commentTake")(function* (options) {
26043
26081
  const worktree = yield* required(options, "worktree");
26044
26082
  const wait = yield* seconds(options, "wait");
26045
- const comments = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT) : yield* take(worktree);
26083
+ const handing = options["new"] === void 0 ? "owed" : "new";
26084
+ const comments = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT, handing) : yield* take(worktree, handing);
26046
26085
  const hint = comments.length === 0 ? { hint: NOTHING_WAITING } : {};
26047
26086
  yield* answer(options, {
26048
26087
  comments,
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.195",
26
+ "version": "0.1.0-alpha.197",
27
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.",
28
28
  "license": "MIT",
29
29
  "repository": {
@@ -29,8 +29,8 @@ revision has it. The code the layer describes is about to change under your hand
29
29
  stale the moment you act on the comment: write a new revision with `adiff layers set` before you
30
30
  answer, and say in the answer that you did.
31
31
 
32
- A comment keeps coming back until it is answered. A second `take` returns it again, so answer what
33
- you take. Settling or removing it also retires it: those are the reviewer saying they no longer
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
34
  need one.
35
35
 
36
36
  ## A remark is context, a comment is work
@@ -43,12 +43,35 @@ one. Never act on a remark that has not been accepted, and never accept one your
43
43
 
44
44
  ## Wait for the next one
45
45
 
46
+ Start a session with a plain take, which collects everything still owed an answer:
47
+
46
48
  ```bash
47
- adiff comment take --worktree . --wait 300
49
+ adiff comment take --worktree .
48
50
  ```
49
51
 
50
- Blocks until a comment arrives or the timeout in seconds elapses, then returns the same envelope.
51
- An empty `comments` array means the wait expired with nothing new — that is not an error.
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.
52
75
 
53
76
  `--wait` takes a whole number of seconds from 1 to 86400. A value outside that is refused on
54
77
  stderr with exit 2, because an instant empty answer would read exactly like a wait that expired:
@@ -58,21 +81,17 @@ Arm the wait as the first thing you do in a turn, before the work. A turn that i
58
81
  half-way then still leaves a listener running, and a wait armed at the end of a turn is a wait that
59
82
  often never gets armed.
60
83
 
61
- Run the wait in the background, not in the foreground. A foreground wait holds the turn, so you
62
- cannot do anything else and the person you are working with cannot talk to you. Backgrounded, the
63
- harness brings you back the moment a comment lands.
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.
64
86
 
65
- Keep one wait per worktree. A second wait returns the same comments as the first, so two of them
66
- running at once is two of you answering the same comment. Before starting one, check whether one is
67
- already running.
68
-
69
- Re-arm it after each comment you handle, and keep it running while you work. A reviewer reads at
70
- their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
71
- events rather than by you asking. When you finish a piece of work, say you are still listening.
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.
72
91
 
73
92
  A backgrounded wait that is killed rather than expiring is not the reviewer going quiet, and not a
74
- reason to stop listening. A kill loses whatever the wait would have handed you, so take once
75
- without `--wait` to collect what landed, then arm a new wait.
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.
76
95
 
77
96
  ## Answering a comment
78
97
 
@@ -149,7 +168,8 @@ answer as many comments as it addresses. When a comment is a question rather tha
149
168
  it with `adiff comment answer` too; an answer written into a commit message never reaches the
150
169
  reviewer's screen.
151
170
 
152
- Handle every comment in the batch before taking again.
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.
153
173
 
154
174
  ## Failure
155
175
 
@@ -168,8 +188,9 @@ about, because the reviewer has not opened it; report that rather than looping.
168
188
  ## Handing work over
169
189
 
170
190
  Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
171
- them if they asked for one, and say how to read it. That is the whole handover. A reading order is
172
- extra work you do on request, and it has its own section further down.
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.
173
194
 
174
195
  ## Put the review in front of them
175
196
 
@@ -209,13 +230,15 @@ the branch in a list. `--branch` takes the name `branch list` reports; without i
209
230
  on the worktree list.
210
231
 
211
232
  Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
212
- doubt spends their attention there. Offer a reading order rather than writing one: if the change is
213
- long enough that the order matters, say you can publish one and let them decide.
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.
214
236
 
215
237
  ## Publishing a reading order, when you are asked for one
216
238
 
217
- Only when the reviewer asks. A reading order is a real piece of work, it can be wrong, and one
218
- nobody wanted spends their attention on your summary rather than on the code.
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.
219
242
 
220
243
  The ask often arrives as a comment. Pressing `L` in the review sends you one of these:
221
244
 
@@ -278,12 +301,15 @@ Rules that make a layers worth reading:
278
301
  The answer to `layers set` is the honest report — check it before you claim to be done:
279
302
 
280
303
  ```json
281
- {"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":[]}]}}
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":[]}]}}
282
305
 
283
306
  `covered`, `partial` and `vanished` appear per layer as well as for the document, so you can tell
284
307
  which of your own layers is the thin one. `vanished` on a layer names paths it claims that are not
285
308
  in the diff — usually a typo or a file that moved.
286
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
+
287
313
  `layers set` refuses a document it cannot use and says which layer is wrong and why: a span that
288
314
  ends before it starts, a span starting below line 1, a start or end that is not a whole number, a
289
315
  block with no `kind`, a layer with no title. It no longer drops a bad span quietly, so a layer that
@@ -319,13 +345,31 @@ each claim their own run. Done means `uncovered` is empty **and** `shared` is ze
319
345
 
320
346
  Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
321
347
  was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
322
- reviewer has a reading order, keep it true: write it again after you address their comments.
348
+ reviewer has a reading order, keep it true, as the next section says.
323
349
 
324
350
  When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
325
351
  the files, each layer shows the files it covers with the ones already reviewed ticked off, and `]`
326
352
  and `[` walk those files in the order you put them in — from the last file of one layer into the
327
353
  first of the next.
328
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
+
329
373
  ## Helping draft a review of somebody else's pull request
330
374
 
331
375
  Sometimes the reviewer is not reading your work — they are reading a stranger's pull request,