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

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.
@@ -49,6 +49,31 @@ vitest directly. A test that does not still records; it just has no captions.
49
49
  The recording is driven by the test's own trace, so it cannot show something the test does not do. If
50
50
  a test fails, nothing is recorded — a green run is the precondition, not a claim to make in prose.
51
51
 
52
+ ## A recording replays keys, and nothing else
53
+
54
+ The replay rebuilds the world from the trace — the branch fixture and the layers, and nothing more —
55
+ then presses the keys. Anything a test does by another route is not there: a file changed or
56
+ committed after the world was built, a comment or an answer seeded through the store or the command
57
+ line, a preference set from outside. A test that does any of those marks its trace unreplayable, and
58
+ `pnpm record` skips it and says which route it took.
59
+
60
+ So a test that needs one of those things has two honest endings, and no third:
61
+
62
+ - **Write it with keys instead**, if the same rule can be reached that way. A reviewer's reply
63
+ exercises the same drawing rule an agent's answer does, and a reply is keys. That test records.
64
+ - **Let it be skipped**, and say in the PR body which behavior has no film and why.
65
+
66
+ **Never paste a recording you have not looked at.** Take the still of the same trace and read it:
67
+
68
+ ```bash
69
+ pnpm shot --trace <trace.jsonl> --test-name "<when> > <then>" --keep
70
+ ```
71
+
72
+ The still is the last frame of the film. If it does not show the behavior the test names, the film
73
+ does not either — and a film that shows the wrong screen is worse than no film, because a reviewer
74
+ believes it. `pnpm record` writes its trace to a temp directory and prints the path in its error
75
+ output; to keep one, run the tests yourself with `ADIFF_TRACE=<path>` set.
76
+
52
77
  ## What gets recorded
53
78
 
54
79
  Every test the branch adds, one recording each, not a representative sample. Skip only when the
@@ -151,8 +151,6 @@ tests, or how long it took you. Those belong in the PR.
151
151
  ### The template
152
152
 
153
153
  ```markdown
154
- One paragraph. What this changes, and what prompted it. Two or three sentences.
155
-
156
154
  ## What changed
157
155
 
158
156
  ### Fixed
@@ -183,6 +181,11 @@ The repro. Then what the fix was.
183
181
 
184
182
  - The **title** is the entry sentence without the `kind(area):` prefix, and follows the same
185
183
  no-gerund rule.
184
+ - **Nothing comes before `## What changed`.** No opening paragraph, no framing, no "two things a
185
+ reviewer hits". The bullets say what changed; a reader who wants the story reads the section for
186
+ the one that bit them. The template's paragraph is for a PR with no change intent at all.
187
+ - **Every section is two or three sentences.** The repro, then what it does now. A reader deciding
188
+ whether this is their bug does not read a fourth sentence.
186
189
  - **`## What changed` is generated, never typed.** `node scripts/pr-summary.ts` prints it from the
187
190
  change intents on this branch. The PR and the changelog then cannot drift apart. Commit the
188
191
  intent first — the summary is read from the diff against `origin/main`, so an uncommitted file
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.142
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(diff): a comment moves to wherever its code went when the agent edits the file above it.
8
+
9
+ <details><summary>What was wrong</summary>
10
+
11
+ A comment was drawn at the line number it was written at. When the agent added or removed lines
12
+ above that code, every comment in the file stayed on its old number and pointed at whatever had
13
+ moved into it. A comment carries the exact snippet it was written against, and that is now what
14
+ places it.
15
+
16
+ </details>
17
+
18
+ fix(diff): a comment whose code the agent rewrote is not drawn against the line that took its place.
19
+
20
+ <details><summary>What was wrong</summary>
21
+
22
+ When the code a comment was about was changed rather than moved, there was nothing to move the
23
+ comment to, and it stayed on its old line — reading as a remark about code it was never about. Such
24
+ a thread is now left off the diff and kept in the review panel, which says it is not in the diff.
25
+
26
+ </details>
27
+
28
+ fix(diff): an answer with more than one line keeps its lines.
29
+
30
+ <details><summary>What was wrong</summary>
31
+
32
+ An agent's answer and a reviewer's reply were flattened to a single paragraph, so a bulleted answer
33
+ read as one run-on sentence. The reviewer's own comment kept its breaks, so the two sides of a
34
+ thread were drawn by different rules.
35
+
36
+ </details>
37
+
3
38
  ## 0.1.0-alpha.141
4
39
 
5
40
  ### Patch Changes
package/dist/main.js CHANGED
@@ -9592,7 +9592,7 @@ var init_model$3 = __esmMin((() => {
9592
9592
  }));
9593
9593
  //#endregion
9594
9594
  //#region src/domain/patch/anchor.ts
9595
- var sideOf, linesOn, anchorFor, rowsForRange;
9595
+ var sideOf, linesOn, anchorFor, rowsForRange, sideLines, runsAt, nearestRun, foundAgain;
9596
9596
  var init_anchor = __esmMin((() => {
9597
9597
  init_dist();
9598
9598
  init_model$3();
@@ -9628,6 +9628,38 @@ var init_anchor = __esmMin((() => {
9628
9628
  if (first === void 0 || last === void 0) return none();
9629
9629
  return some([first.index, last.index]);
9630
9630
  };
9631
+ sideLines = (patch, side) => patch.rows.flatMap((row) => match$3(lineOn(row, side), {
9632
+ onNone: () => [],
9633
+ onSome: (line) => [{
9634
+ line,
9635
+ text: row.text
9636
+ }]
9637
+ }));
9638
+ runsAt = (lines, wanted, at) => wanted.every((text, step) => {
9639
+ const here = lines[at + step];
9640
+ return here !== void 0 && here.text === text && here.line === (lines[at]?.line ?? 0) + step;
9641
+ });
9642
+ nearestRun = (lines, said, near) => lines.flatMap((here, at) => runsAt(lines, said, at) ? [here.line] : []).toSorted((one, other) => Math.abs(one - near) - Math.abs(other - near))[0];
9643
+ foundAgain = (patch, wanted) => {
9644
+ const said = wanted.snippet.split("\n");
9645
+ if (said.every((text) => text.trim().length === 0)) return none();
9646
+ const lines = sideLines(patch, wanted.side);
9647
+ const whole = nearestRun(lines, said, wanted.start);
9648
+ if (whole !== void 0) return some({
9649
+ side: wanted.side,
9650
+ start: whole,
9651
+ end: whole + said.length - 1
9652
+ });
9653
+ const first = said[0] ?? "";
9654
+ if (said.length === 1 || first.trim().length === 0) return none();
9655
+ const opening = nearestRun(lines, [first], wanted.start);
9656
+ if (opening === void 0) return none();
9657
+ return some({
9658
+ side: wanted.side,
9659
+ start: opening,
9660
+ end: opening
9661
+ });
9662
+ };
9631
9663
  }));
9632
9664
  //#endregion
9633
9665
  //#region src/domain/patch/parse.ts
@@ -10243,7 +10275,7 @@ var init_error = __esmMin((() => {
10243
10275
  }));
10244
10276
  //#endregion
10245
10277
  //#region src/cli/commands.ts
10246
- var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$1, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, setBase, clearBase, markRead;
10278
+ var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$1, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, setBase, clearBase, markRead;
10247
10279
  var init_commands = __esmMin((() => {
10248
10280
  init_dist();
10249
10281
  init_patch();
@@ -10462,7 +10494,7 @@ var init_commands = __esmMin((() => {
10462
10494
  settled: Object.hasOwn(settled, comment.id),
10463
10495
  removed: Object.hasOwn(removed, comment.id),
10464
10496
  stale: comment.head !== head,
10465
- outside: !shown.has(comment.file),
10497
+ outside: !shown.has(comment.file) || comment.placed === false,
10466
10498
  unread: Math.max(0, said.length - seen),
10467
10499
  asks: last?.voice === "agent" && last.asks,
10468
10500
  ...takenAt === void 0 ? {} : { takenAt },
@@ -10473,13 +10505,36 @@ var init_commands = __esmMin((() => {
10473
10505
  }))
10474
10506
  };
10475
10507
  };
10508
+ whereItSitsNow$1 = (patches, comment) => {
10509
+ const patch = patches.find((candidate) => candidate.path === comment.file);
10510
+ if (patch === void 0) return {
10511
+ ...comment,
10512
+ placed: false
10513
+ };
10514
+ if (comment.snippet.trim().length === 0) return {
10515
+ ...comment,
10516
+ placed: true
10517
+ };
10518
+ return match$3(foundAgain(patch, comment), {
10519
+ onNone: () => ({
10520
+ ...comment,
10521
+ placed: false
10522
+ }),
10523
+ onSome: (range) => ({
10524
+ ...comment,
10525
+ start: range.start,
10526
+ end: range.end,
10527
+ placed: true
10528
+ })
10529
+ });
10530
+ };
10476
10531
  sentIn = fn("Cli.sentIn")(function* (reading) {
10477
10532
  const store = yield* Store;
10478
10533
  const worktree = reading.worktree;
10479
10534
  const spoken = yield* store.answers(worktree.path);
10480
10535
  const current = yield* store.state(worktree.path);
10481
10536
  const shown = new Set(reading.patches.map((patch) => patch.path));
10482
- const held = flatten(yield* store.inbox(worktree.path));
10537
+ const held = flatten(yield* store.inbox(worktree.path)).map((comment) => whereItSitsNow$1(reading.patches, comment));
10483
10538
  const replies = held.filter((comment) => comment.replyTo !== void 0);
10484
10539
  const conversation = {
10485
10540
  spoken,
@@ -11116,7 +11171,7 @@ var init_pane = __esmMin((() => {
11116
11171
  init_drafts();
11117
11172
  init_init();
11118
11173
  init_pane();
11119
- var version$1 = "0.1.0-alpha.141";
11174
+ var version$1 = "0.1.0-alpha.142";
11120
11175
  //#endregion
11121
11176
  //#region src/cli/upgrade.ts
11122
11177
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -11738,9 +11793,10 @@ var init_layers = __esmMin((() => {
11738
11793
  }));
11739
11794
  //#endregion
11740
11795
  //#region src/cli/threads.ts
11741
- var stateOf, spoken$1, turnsOf, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleIn, settleThread, removeIn, removeComment, without, restoreIn, restoreComment, settleRead;
11796
+ var stateOf, whereItSitsNow, spoken$1, turnsOf, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleIn, settleThread, removeIn, removeComment, without, restoreIn, restoreComment, settleRead;
11742
11797
  var init_threads = __esmMin((() => {
11743
11798
  init_dist();
11799
+ init_patch();
11744
11800
  init_store();
11745
11801
  init_commands();
11746
11802
  init_layers();
@@ -11752,6 +11808,27 @@ var init_threads = __esmMin((() => {
11752
11808
  if (last === void 0 || last.voice === "reviewer") return "sent";
11753
11809
  return asked ? "question" : "answered";
11754
11810
  };
11811
+ whereItSitsNow = (patches, anchor) => {
11812
+ const patch = patches.find((candidate) => candidate.path === anchor.path);
11813
+ if (patch === void 0) return {
11814
+ ...anchor,
11815
+ placed: false
11816
+ };
11817
+ if (anchor.snippet.trim().length === 0) return {
11818
+ ...anchor,
11819
+ placed: true
11820
+ };
11821
+ return match$3(foundAgain(patch, anchor), {
11822
+ onNone: () => ({
11823
+ ...anchor,
11824
+ placed: false
11825
+ }),
11826
+ onSome: (range) => ({
11827
+ ...range,
11828
+ placed: true
11829
+ })
11830
+ });
11831
+ };
11755
11832
  spoken$1 = (entry) => ({
11756
11833
  body: entry.body,
11757
11834
  at: entry.at,
@@ -11773,16 +11850,17 @@ var init_threads = __esmMin((() => {
11773
11850
  const seen = [...ids].reduce((total, id) => total + (reading.read[id] ?? 0), 0);
11774
11851
  const turns = turnsOf(replies, mine);
11775
11852
  const settled = Object.hasOwn(reading.settled, comment.id);
11853
+ const sits = whereItSitsNow(reading.patches, comment.anchor);
11776
11854
  return {
11777
11855
  id: comment.id,
11778
11856
  file: comment.anchor.path,
11779
11857
  side: comment.anchor.side,
11780
- start: comment.anchor.start,
11781
- end: comment.anchor.end,
11858
+ start: sits.start,
11859
+ end: sits.end,
11782
11860
  body: comment.body,
11783
11861
  state: stateOf(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(reading.removed, comment.id)),
11784
11862
  stale: batch.head !== reading.head,
11785
- outside: !reading.shown.has(comment.anchor.path),
11863
+ outside: !reading.shown.has(comment.anchor.path) || !sits.placed,
11786
11864
  unread: Math.max(0, mine.length - seen),
11787
11865
  answers: mine.map(spoken$1),
11788
11866
  turns,
@@ -11807,12 +11885,14 @@ var init_threads = __esmMin((() => {
11807
11885
  const store = yield* Store;
11808
11886
  const worktree = yield* findBranch(repo, branch, base);
11809
11887
  const current = yield* store.state(worktree.path);
11888
+ const patches = yield* patchesOf(worktree);
11810
11889
  return threadsIn(yield* store.inbox(worktree.path), {
11811
11890
  answers: yield* store.answers(worktree.path),
11812
11891
  settled: current.settled,
11813
11892
  removed: current.removed,
11814
11893
  head: worktree.head,
11815
- shown: new Set((yield* patchesOf(worktree)).map((patch) => patch.path)),
11894
+ shown: new Set(patches.map((patch) => patch.path)),
11895
+ patches,
11816
11896
  read: current.read
11817
11897
  });
11818
11898
  });
@@ -13566,7 +13646,7 @@ var init_model = __esmMin((() => {
13566
13646
  const patch = selectedPatch(state);
13567
13647
  const found = /* @__PURE__ */ new Map();
13568
13648
  if (patch === void 0) return found;
13569
- const here = state.sent.filter((entry) => entry.file === patch.path && entry.removed !== true);
13649
+ const here = state.sent.filter((entry) => entry.file === patch.path && entry.removed !== true && entry.outside !== true);
13570
13650
  for (const entry of here) {
13571
13651
  const stand = threadStand(entry);
13572
13652
  for (const row of rowsUnder(patch, entry)) found.set(row, louder(stand, found.get(row) ?? "gone"));
@@ -13733,14 +13813,14 @@ var init_model = __esmMin((() => {
13733
13813
  commentRowsIn = (state, fileIndex) => {
13734
13814
  const patch = fileIndex === state.patchIndex ? selectedPatch(state) : state.patches[fileIndex];
13735
13815
  if (patch === void 0) return [];
13736
- const notes = state.sent.filter((entry) => entry.file === patch.path);
13816
+ const notes = state.sent.filter((entry) => entry.file === patch.path && entry.outside !== true);
13737
13817
  return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
13738
13818
  };
13739
13819
  threadsAtRow = (state, row) => {
13740
13820
  const patch = selectedPatch(state);
13741
13821
  const here = patch?.rows[row];
13742
13822
  if (patch === void 0 || here === void 0) return [];
13743
- return state.sent.filter((entry) => entry.file === patch.path && entry.id !== void 0 && entry.removed !== true && lineOnSide(here, entry.side) === entry.end);
13823
+ return state.sent.filter((entry) => entry.file === patch.path && entry.id !== void 0 && entry.removed !== true && entry.outside !== true && lineOnSide(here, entry.side) === entry.end);
13744
13824
  };
13745
13825
  stopsAtRow = (state, row) => 1 + threadsAtRow(state, row).length;
13746
13826
  threadHere = (state) => threadChosen(state) ?? threadAtStop(state) ?? threadAtRow(state, state.cursor);
@@ -13749,12 +13829,12 @@ var init_model = __esmMin((() => {
13749
13829
  const patch = selectedPatch(state);
13750
13830
  const here = patch?.rows[row];
13751
13831
  if (patch === void 0 || here === void 0) return void 0;
13752
- return state.sent.find((entry) => entry.file === patch.path && entry.id !== void 0 && entry.removed !== true && lineOnSide(here, entry.side) === entry.end);
13832
+ return state.sent.find((entry) => entry.file === patch.path && entry.id !== void 0 && entry.removed !== true && entry.outside !== true && lineOnSide(here, entry.side) === entry.end);
13753
13833
  };
13754
13834
  openCommentRows = (state) => {
13755
13835
  const patch = selectedPatch(state);
13756
13836
  if (patch === void 0) return [];
13757
- const open = state.sent.filter((entry) => entry.file === patch.path && entry.settled !== true && entry.removed !== true);
13837
+ const open = state.sent.filter((entry) => entry.file === patch.path && entry.settled !== true && entry.removed !== true && entry.outside !== true);
13758
13838
  return patch.rows.filter((row) => open.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index);
13759
13839
  };
13760
13840
  filesWithComments = (state) => state.patches.flatMap((patch, index) => state.sent.some((entry) => entry.file === patch.path) ? [index] : []);
@@ -16443,7 +16523,7 @@ var init_diffview = __esmMin((() => {
16443
16523
  return `${marks().waiting} picked up ${sinceThen(note.takenAt, note.now)}${moved}`;
16444
16524
  };
16445
16525
  spokenLines = (body, room, mark) => {
16446
- return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${mark} ${text}` : ` ${text}`);
16526
+ return body.split("\n").flatMap((line) => wrap(line, Math.max(NOTE_MIN, room - 2))).map((text, at) => at === 0 ? `${mark} ${text}` : ` ${text}`);
16447
16527
  };
16448
16528
  answerLines = (note, room) => note.turns.length > 0 ? note.turns.flatMap((turn) => spokenLines(turn.body, room, turn.voice === "agent" ? ANSWER_MARK : REPLY_MARK)) : note.answers.flatMap((body) => spokenLines(body, room, ANSWER_MARK));
16449
16529
  noteLines = (note, room) => note.folded ? [`${headOf(note)} · press l`] : [
@@ -17166,7 +17246,7 @@ var init_render = __esmMin((() => {
17166
17246
  notesOf = (comments, path, sent, shown = {
17167
17247
  opened: [],
17168
17248
  now: Date.now()
17169
- }) => comments.filter((entry) => entry.file === path).map((entry) => ({
17249
+ }) => comments.filter((entry) => entry.file === path && entry.outside !== true).map((entry) => ({
17170
17250
  id: entry.id ?? "",
17171
17251
  folded: entry.settled === true && !(entry.id !== void 0 && shown.opened.includes(entry.id)),
17172
17252
  side: entry.side,
@@ -17472,7 +17552,7 @@ var init_render = __esmMin((() => {
17472
17552
  };
17473
17553
  };
17474
17554
  panelWhere = (entry, room) => {
17475
- const where = `:${entry.comment.end}`;
17555
+ const where = entry.comment.outside === true ? " · not in the diff" : `:${entry.comment.end}`;
17476
17556
  return `${clipPath(entry.comment.file, Math.max(4, room - where.length))}${where}`;
17477
17557
  };
17478
17558
  panelBody = (entry) => entry.comment.body.split("\n").find((line) => line.trim().length > 0) ?? "";
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.141",
26
+ "version": "0.1.0-alpha.142",
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": {