@eliya-oss/agent-diff 0.1.0-alpha.80 → 0.1.0-alpha.82

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,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.82
4
+
5
+ ### Minor Changes
6
+
7
+ - A reviewer can write back to an answer. Press `R` on a thread, in the diff or in the review panel, and the reply continues that thread rather than opening a second one about the same line. It reaches the agent through `comment take` like any other comment, carrying the conversation so far, and `adiff comment reply --to <id>` does the same from the command line.
8
+
9
+ ## 0.1.0-alpha.81
10
+
11
+ ### Patch Changes
12
+
13
+ - Opening a branch asks git for its diff once rather than four times over, which takes about forty milliseconds off every branch opened or reopened.
14
+
3
15
  ## 0.1.0-alpha.80
4
16
 
5
17
  ### Patch Changes
package/dist/main.js CHANGED
@@ -8709,7 +8709,8 @@ var init_schema = __esmMin((() => {
8709
8709
  StoredComment = Struct({
8710
8710
  id: String$1,
8711
8711
  anchor: Anchor,
8712
- body: String$1
8712
+ body: String$1,
8713
+ replyTo: optionalKey(String$1)
8713
8714
  });
8714
8715
  StoredAnswer = Struct({
8715
8716
  comment: String$1,
@@ -9107,7 +9108,7 @@ var init_error$1 = __esmMin((() => {
9107
9108
  }));
9108
9109
  //#endregion
9109
9110
  //#region src/cli/commands.ts
9110
- var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, AT_ONCE, summaryOf, summaryFor, listBranches, blobOf, toggleVouch, reviewProgress, bodyOf, sentOf, listSent, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, saveSticky, setBase, clearBase, markRead;
9111
+ var CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, AT_ONCE, summaryOf, summaryFor, listBranches, blobOf, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, sentIn, listSent, submitComment, without$1, submitReply, listPatches, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, saveWrap, saveSticky, setBase, clearBase, markRead;
9111
9112
  var init_commands = __esmMin((() => {
9112
9113
  init_dist();
9113
9114
  init_patch();
@@ -9271,23 +9272,46 @@ var init_commands = __esmMin((() => {
9271
9272
  total: patches.length
9272
9273
  };
9273
9274
  });
9274
- reviewProgress = fn("Cli.reviewProgress")(function* (repo, branch, base) {
9275
- const store = yield* Store;
9275
+ readingOf = fn("Cli.readingOf")(function* (repo, branch, base) {
9276
9276
  const worktree = yield* findBranch(repo, branch, base);
9277
- const patches = yield* patchesOf(worktree);
9278
- const current = yield* store.state(worktree.path);
9279
9277
  return {
9280
- vouched: patches.map((patch) => ({
9278
+ worktree,
9279
+ patches: yield* patchesOf(worktree)
9280
+ };
9281
+ });
9282
+ progressIn = fn("Cli.progressIn")(function* (reading) {
9283
+ const current = yield* (yield* Store).state(reading.worktree.path);
9284
+ return {
9285
+ vouched: reading.patches.map((patch) => ({
9281
9286
  path: patch.path,
9282
9287
  blob: patch.blob
9283
9288
  })).filter((file) => isVouched(current.vouches, file.path, file.blob)).map((f) => f.path),
9284
- total: patches.length
9289
+ total: reading.patches.length
9285
9290
  };
9286
9291
  });
9292
+ reviewProgress = fn("Cli.reviewProgress")(function* (repo, branch, base) {
9293
+ return yield* progressIn(yield* readingOf(repo, branch, base));
9294
+ });
9287
9295
  bodyOf = (entry) => entry.body;
9288
- sentOf = (comment, reading) => {
9296
+ saidTo = (spoken, id) => spoken.filter((entry) => entry.comment === id).length;
9297
+ spunOf = (replies, said) => [...replies.map((reply) => ({
9298
+ voice: "reviewer",
9299
+ body: reply.body,
9300
+ at: reply.at,
9301
+ asks: false
9302
+ })), ...said.map((entry) => ({
9303
+ voice: "agent",
9304
+ body: entry.body,
9305
+ at: entry.at,
9306
+ asks: entry.asks
9307
+ }))].toSorted((one, other) => one.at < other.at ? -1 : one.at > other.at ? 1 : 0);
9308
+ sentOf = (comment, replies, reading) => {
9289
9309
  const { spoken, settled, head, shown, read } = reading;
9290
- const mine = spoken.filter((entry) => entry.comment === comment.id);
9310
+ const ids = /* @__PURE__ */ new Set([comment.id, ...replies.map((reply) => reply.id)]);
9311
+ const said = spoken.filter((entry) => ids.has(entry.comment));
9312
+ const seen = [...ids].reduce((total, id) => total + (read[id] ?? 0), 0);
9313
+ const spun = spunOf(replies, said);
9314
+ const last = spun.at(-1);
9291
9315
  return {
9292
9316
  id: comment.id,
9293
9317
  file: comment.file,
@@ -9298,24 +9322,35 @@ var init_commands = __esmMin((() => {
9298
9322
  settled: Object.hasOwn(settled, comment.id),
9299
9323
  stale: comment.head !== head,
9300
9324
  outside: !shown.has(comment.file),
9301
- unread: Math.max(0, mine.length - (read[comment.id] ?? 0)),
9302
- asks: mine.at(-1)?.asks === true,
9303
- answers: mine.map(bodyOf)
9325
+ unread: Math.max(0, said.length - seen),
9326
+ asks: last?.voice === "agent" && last.asks,
9327
+ answers: said.map(bodyOf),
9328
+ turns: spun.map((turn) => ({
9329
+ voice: turn.voice,
9330
+ body: turn.body
9331
+ }))
9304
9332
  };
9305
9333
  };
9306
- listSent = fn("Cli.listSent")(function* (repo, branch, base) {
9334
+ sentIn = fn("Cli.sentIn")(function* (reading) {
9307
9335
  const store = yield* Store;
9308
- const worktree = yield* findBranch(repo, branch, base);
9336
+ const worktree = reading.worktree;
9309
9337
  const spoken = yield* store.answers(worktree.path);
9310
9338
  const current = yield* store.state(worktree.path);
9311
- const shown = new Set((yield* patchesOf(worktree)).map((patch) => patch.path));
9312
- return flatten(yield* store.inbox(worktree.path)).filter((comment) => !Object.hasOwn(current.removed, comment.id)).map((comment) => sentOf(comment, {
9339
+ const shown = new Set(reading.patches.map((patch) => patch.path));
9340
+ const held = flatten(yield* store.inbox(worktree.path)).filter((comment) => !Object.hasOwn(current.removed, comment.id));
9341
+ const replies = held.filter((comment) => comment.replyTo !== void 0);
9342
+ const conversation = {
9313
9343
  spoken,
9314
9344
  settled: current.settled,
9315
9345
  head: worktree.head,
9316
9346
  shown,
9317
9347
  read: current.read
9318
- }));
9348
+ };
9349
+ const under = (comment) => replies.filter((reply) => reply.replyTo === comment.id);
9350
+ return held.filter((comment) => comment.replyTo === void 0).map((comment) => sentOf(comment, under(comment), conversation));
9351
+ });
9352
+ listSent = fn("Cli.listSent")(function* (repo, branch, base) {
9353
+ return yield* sentIn(yield* readingOf(repo, branch, base));
9319
9354
  });
9320
9355
  submitComment = fn("Cli.submitComment")(function* (request) {
9321
9356
  const store = yield* Store;
@@ -9354,6 +9389,32 @@ var init_commands = __esmMin((() => {
9354
9389
  yield* store.submit(worktree.path, batch);
9355
9390
  return batch;
9356
9391
  });
9392
+ without$1 = (held, key) => Object.fromEntries(Object.entries(held).filter(([held_]) => held_ !== key));
9393
+ submitReply = fn("Cli.submitReply")(function* (request) {
9394
+ const store = yield* Store;
9395
+ const worktree = yield* findBranch(request.repo, request.branch);
9396
+ const found = (yield* store.inbox(worktree.path)).flatMap((batch) => batch.comments).find((one) => one.id === request.to);
9397
+ if (found === void 0) return yield* new UnknownComment({ id: request.to });
9398
+ const root = found.replyTo ?? found.id;
9399
+ const batch = {
9400
+ id: request.id,
9401
+ at: request.at,
9402
+ head: worktree.head,
9403
+ comments: [{
9404
+ id: request.id,
9405
+ anchor: found.anchor,
9406
+ body: request.body,
9407
+ replyTo: root
9408
+ }]
9409
+ };
9410
+ yield* store.submit(worktree.path, batch);
9411
+ const current = yield* store.state(worktree.path);
9412
+ if (Object.hasOwn(current.settled, root)) yield* store.saveState(worktree.path, {
9413
+ ...current,
9414
+ settled: without$1(current.settled, root)
9415
+ });
9416
+ return batch;
9417
+ });
9357
9418
  listPatches = fn("Cli.listPatches")(function* (repo, branch, context = CONTEXT) {
9358
9419
  const worktree = yield* findBranch(repo, branch);
9359
9420
  const git = yield* Git;
@@ -9368,12 +9429,28 @@ var init_commands = __esmMin((() => {
9368
9429
  start: comment.anchor.start,
9369
9430
  end: comment.anchor.end,
9370
9431
  snippet: comment.anchor.snippet,
9371
- body: comment.body
9432
+ body: comment.body,
9433
+ replyTo: comment.replyTo
9372
9434
  })));
9435
+ threadBefore = (reply, held, spoken) => {
9436
+ const root = reply.replyTo;
9437
+ const mine = held.filter((one) => one.id === root || one.replyTo === root);
9438
+ const ids = new Set(mine.map((one) => one.id));
9439
+ const said = spoken.filter((entry) => ids.has(entry.comment));
9440
+ return spunOf(mine.filter((one) => one.at < reply.at), said.filter((entry) => entry.at < reply.at)).map((turn) => ({
9441
+ voice: turn.voice,
9442
+ body: turn.body
9443
+ }));
9444
+ };
9373
9445
  takeComments = fn("Cli.takeComments")(function* (worktree) {
9374
9446
  const store = yield* Store;
9375
9447
  const resolved = yield* promise(() => realpath(worktree));
9376
- return flatten(yield* store.take(resolved));
9448
+ const owed = flatten(yield* store.take(resolved));
9449
+ if (owed.every((one) => one.replyTo === void 0)) return owed;
9450
+ const held = flatten(yield* store.inbox(resolved));
9451
+ const spoken = yield* store.answers(resolved);
9452
+ const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
9453
+ return owed.map(carried);
9377
9454
  });
9378
9455
  repoOf$1 = fn("Cli.repoOf")(function* (worktree) {
9379
9456
  return yield* (yield* Git).repoOf(worktree);
@@ -9450,18 +9527,22 @@ var init_commands = __esmMin((() => {
9450
9527
  markRead = fn("Cli.markRead")(function* (repo, branch, id) {
9451
9528
  const store = yield* Store;
9452
9529
  const worktree = yield* findBranch(repo, branch);
9453
- const seen = (yield* store.answers(worktree.path)).filter((entry) => entry.comment === id).length;
9530
+ const spoken = yield* store.answers(worktree.path);
9531
+ const counted = [id, ...flatten(yield* store.inbox(worktree.path)).filter((one) => one.replyTo === id).map((one) => one.id)].map((one) => ({
9532
+ id: one,
9533
+ seen: saidTo(spoken, one)
9534
+ }));
9454
9535
  const current = yield* store.state(worktree.path);
9455
- if ((current.read[id] ?? 0) >= seen) return {
9536
+ const owed = counted.filter((one) => (current.read[one.id] ?? 0) < one.seen);
9537
+ if (owed.length === 0) return {
9456
9538
  id,
9457
9539
  unread: 0
9458
9540
  };
9541
+ const read = { ...current.read };
9542
+ for (const one of owed) read[one.id] = one.seen;
9459
9543
  yield* store.saveState(worktree.path, {
9460
9544
  ...current,
9461
- read: {
9462
- ...current.read,
9463
- [id]: seen
9464
- }
9545
+ read
9465
9546
  });
9466
9547
  return {
9467
9548
  id,
@@ -9723,7 +9804,7 @@ var init_pane = __esmMin((() => {
9723
9804
  init_commands();
9724
9805
  init_init();
9725
9806
  init_pane();
9726
- var version$1 = "0.1.0-alpha.80";
9807
+ var version$1 = "0.1.0-alpha.82";
9727
9808
  //#endregion
9728
9809
  //#region src/cli/upgrade.ts
9729
9810
  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, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -10111,10 +10192,7 @@ var init_layers$1 = __esmMin((() => {
10111
10192
  init_coverage();
10112
10193
  init_version();
10113
10194
  init_model$1();
10114
- }));
10115
- //#endregion
10116
- //#region src/cli/layers.ts
10117
- var STALE_ADVICE, unique, spansOfLayer, isSpan, isBlock, codeBlockOf, blocksOf, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, listLayers;
10195
+ })), STALE_ADVICE, unique, spansOfLayer, isSpan, isBlock, codeBlockOf, blocksOf, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, layersIn;
10118
10196
  var init_layers = __esmMin((() => {
10119
10197
  init_dist();
10120
10198
  init_layers$1();
@@ -10275,44 +10353,60 @@ var init_layers = __esmMin((() => {
10275
10353
  });
10276
10354
  return reportOf(patches, layers, worktree.head);
10277
10355
  });
10278
- listLayers = fn("Cli.listLayers")(function* (repo, branch) {
10279
- const worktree = yield* findBranch(repo, branch);
10356
+ layersIn = fn("Cli.layersIn")(function* (reading) {
10357
+ const worktree = reading.worktree;
10280
10358
  const found = yield* storedLayers(worktree);
10281
10359
  if (isNone(found)) return {
10282
10360
  layers: [],
10283
10361
  stale: false
10284
10362
  };
10285
- const patches = yield* patchesOf(worktree);
10286
10363
  return {
10287
- layers: reportedLayers(patches, found.value),
10364
+ layers: reportedLayers(reading.patches, found.value),
10288
10365
  stale: found.value.head !== worktree.head,
10289
10366
  rebased: found.value.base !== worktree.base
10290
10367
  };
10291
10368
  });
10369
+ fn("Cli.listLayers")(function* (repo, branch) {
10370
+ return yield* layersIn(yield* readingOf(repo, branch));
10371
+ });
10292
10372
  }));
10293
10373
  //#endregion
10294
10374
  //#region src/cli/threads.ts
10295
- var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread, removeComment, without, restoreComment, settleRead;
10375
+ var stateOf$1, spoken$1, turnsOf, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread, removeComment, without, restoreComment, settleRead;
10296
10376
  var init_threads = __esmMin((() => {
10297
10377
  init_dist();
10298
10378
  init_store();
10299
10379
  init_commands();
10300
10380
  init_layers();
10301
10381
  init_error$1();
10302
- stateOf$1 = (answers, isSettled, isRemoved) => {
10382
+ stateOf$1 = (turns, asked, isSettled, isRemoved) => {
10303
10383
  if (isRemoved) return "removed";
10304
10384
  if (isSettled) return "done";
10305
- const last = answers.at(-1);
10306
- if (last === void 0) return "sent";
10307
- return last.asks ? "question" : "answered";
10385
+ const last = turns.at(-1);
10386
+ if (last === void 0 || last.voice === "reviewer") return "sent";
10387
+ return asked ? "question" : "answered";
10308
10388
  };
10309
10389
  spoken$1 = (entry) => ({
10310
10390
  body: entry.body,
10311
10391
  at: entry.at,
10312
10392
  asks: entry.asks
10313
10393
  });
10314
- threadOf = (comment, batch, reading) => {
10315
- const mine = reading.answers.filter((entry) => entry.comment === comment.id);
10394
+ turnsOf = (replies, said) => [...replies.map((held) => ({
10395
+ voice: "reviewer",
10396
+ body: held.comment.body,
10397
+ at: held.batch.at
10398
+ })), ...said.map((entry) => ({
10399
+ voice: "agent",
10400
+ body: entry.body,
10401
+ at: entry.at
10402
+ }))].toSorted((one, other) => one.at < other.at ? -1 : one.at > other.at ? 1 : 0);
10403
+ threadOf = (held, replies, reading) => {
10404
+ const { comment, batch } = held;
10405
+ const ids = /* @__PURE__ */ new Set([comment.id, ...replies.map((one) => one.comment.id)]);
10406
+ const mine = reading.answers.filter((entry) => ids.has(entry.comment));
10407
+ const seen = [...ids].reduce((total, id) => total + (reading.read[id] ?? 0), 0);
10408
+ const turns = turnsOf(replies, mine);
10409
+ const settled = Object.hasOwn(reading.settled, comment.id);
10316
10410
  return {
10317
10411
  id: comment.id,
10318
10412
  file: comment.anchor.path,
@@ -10320,14 +10414,24 @@ var init_threads = __esmMin((() => {
10320
10414
  start: comment.anchor.start,
10321
10415
  end: comment.anchor.end,
10322
10416
  body: comment.body,
10323
- state: stateOf$1(mine, Object.hasOwn(reading.settled, comment.id), Object.hasOwn(reading.removed, comment.id)),
10417
+ state: stateOf$1(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(reading.removed, comment.id)),
10324
10418
  stale: batch.head !== reading.head,
10325
10419
  outside: !reading.shown.has(comment.anchor.path),
10326
- unread: Math.max(0, mine.length - (reading.read[comment.id] ?? 0)),
10327
- answers: mine.map(spoken$1)
10420
+ unread: Math.max(0, mine.length - seen),
10421
+ answers: mine.map(spoken$1),
10422
+ turns,
10423
+ settled
10328
10424
  };
10329
10425
  };
10330
- threadsIn = (batches, reading) => batches.flatMap((batch) => batch.comments.map((comment) => threadOf(comment, batch, reading)));
10426
+ threadsIn = (batches, reading) => {
10427
+ const held = batches.flatMap((batch) => batch.comments.map((comment) => ({
10428
+ comment,
10429
+ batch
10430
+ })));
10431
+ const replies = held.filter((one) => one.comment.replyTo !== void 0);
10432
+ const under = (one) => replies.filter((reply) => reply.comment.replyTo === one.comment.id);
10433
+ return held.filter((one) => one.comment.replyTo === void 0).map((one) => threadOf(one, under(one), reading));
10434
+ };
10331
10435
  idsIn = (batches) => batches.flatMap((batch) => batch.comments.map((comment) => comment.id));
10332
10436
  isKnown = fn("Cli.isKnown")(function* (worktreePath, id) {
10333
10437
  const store = yield* Store;
@@ -10637,6 +10741,30 @@ var init_catalog = __esmMin((() => {
10637
10741
  dataKey: "batch",
10638
10742
  example: "adiff comment send --repo . --branch cdr-1 --file src/api.ts --start 4 --end 5 --body \"why\""
10639
10743
  },
10744
+ {
10745
+ name: "comment reply",
10746
+ about: "Write back to a comment already sent, continuing its thread",
10747
+ group: WRITE_COMMENTS,
10748
+ addresses: "review",
10749
+ safety: "write",
10750
+ options: [
10751
+ ...addressing,
10752
+ {
10753
+ name: "to",
10754
+ required: true,
10755
+ value: "id",
10756
+ about: "The comment being continued, as `comment list` reports it"
10757
+ },
10758
+ {
10759
+ name: "body",
10760
+ required: true,
10761
+ value: "text",
10762
+ about: "What to tell the agent"
10763
+ }
10764
+ ],
10765
+ dataKey: "batch",
10766
+ example: "adiff comment reply --repo . --branch cdr-1 --to c1 --body \"the other one\""
10767
+ },
10640
10768
  {
10641
10769
  name: "comment take",
10642
10770
  about: "Collect the comments this review is still owed an answer on. Repeats until answered",
@@ -11456,7 +11584,7 @@ var init_tree = __esmMin((() => {
11456
11584
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11457
11585
  };
11458
11586
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
11459
- })), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, pickedText, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelIndexOf, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11587
+ })), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, replyTarget, pickedText, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelIndexOf, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11460
11588
  var init_model = __esmMin((() => {
11461
11589
  init_dist();
11462
11590
  init_patch();
@@ -11765,6 +11893,7 @@ var init_model = __esmMin((() => {
11765
11893
  composeRoom$1 = (columns) => Math.max(COMPOSE_LEAST, composeBox(columns) - COMPOSE_PAD);
11766
11894
  composeTarget = (state) => {
11767
11895
  const patch = selectedPatch(state);
11896
+ if (state.replyTo !== void 0) return replyTarget(state);
11768
11897
  if (patch === void 0) return "";
11769
11898
  const [from, to] = selectionRange(state);
11770
11899
  const anchor = anchorFor(patch, from, to);
@@ -11774,6 +11903,11 @@ var init_model = __esmMin((() => {
11774
11903
  });
11775
11904
  return span === "" ? `Comment on ${patch.path}` : `Comment on ${patch.path}:${span}`;
11776
11905
  };
11906
+ replyTarget = (state) => {
11907
+ const thread = state.sent.find((entry) => entry.id === state.replyTo);
11908
+ if (thread === void 0) return "Reply";
11909
+ return `Reply on ${thread.file}:${thread.end}`;
11910
+ };
11777
11911
  pickedText = (state) => {
11778
11912
  const picked = state.picked;
11779
11913
  const patch = selectedPatch(state);
@@ -12442,6 +12576,17 @@ var init_command = __esmMin((() => {
12442
12576
  hint: "settle read",
12443
12577
  rank: 1
12444
12578
  }),
12579
+ command({
12580
+ action: "thread.reply",
12581
+ panes: ["review", "diff"],
12582
+ hint: "reply",
12583
+ rank: 1,
12584
+ title: "Write back to the thread here",
12585
+ category: "Comments",
12586
+ keys: ["R"],
12587
+ screens: ["review"],
12588
+ whenThread: true
12589
+ }),
12445
12590
  command({
12446
12591
  action: "thread.remove",
12447
12592
  panes: ["review"],
@@ -13036,6 +13181,7 @@ var init_reduce = __esmMin((() => {
13036
13181
  ...state,
13037
13182
  screen: "compose",
13038
13183
  draft: "",
13184
+ replyTo: void 0,
13039
13185
  anchorRow: state.selecting ? state.anchorRow : state.cursor
13040
13186
  };
13041
13187
  };
@@ -13064,7 +13210,8 @@ var init_reduce = __esmMin((() => {
13064
13210
  if (state.screen === "compose") return {
13065
13211
  ...state,
13066
13212
  screen: "review",
13067
- draft: ""
13213
+ draft: "",
13214
+ replyTo: void 0
13068
13215
  };
13069
13216
  if (state.selecting) return {
13070
13217
  ...state,
@@ -13136,6 +13283,7 @@ var init_reduce = __esmMin((() => {
13136
13283
  "select.swap": swapEnds,
13137
13284
  "compose.open": openCompose,
13138
13285
  "compose.submit": (state) => state,
13286
+ "thread.reply": (state) => state,
13139
13287
  "focus.toggle": (state) => ({
13140
13288
  ...state,
13141
13289
  focus: focusStepped(state, 1),
@@ -13586,7 +13734,7 @@ var init_theme = __esmMin((() => {
13586
13734
  }));
13587
13735
  //#endregion
13588
13736
  //#region src/tui/diffview.ts
13589
- var WASH, NOTE_MIN, ANSWER_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, takenOver, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13737
+ var WASH, NOTE_MIN, ANSWER_MARK, REPLY_MARK, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, takenOver, wheelTo, SIGNS, numberFor, DiffView, startsOf, bareOf, keyOf, groupOf, isChrome, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, headOf, spokenLines, answerLines, noteLines, noteRows, proseRows, proseAt, notesAt, codeRow, rowsFor, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
13590
13738
  var init_diffview = __esmMin((() => {
13591
13739
  init_dist();
13592
13740
  init_patch();
@@ -13604,6 +13752,7 @@ var init_diffview = __esmMin((() => {
13604
13752
  };
13605
13753
  NOTE_MIN = 24;
13606
13754
  ANSWER_MARK = "↳";
13755
+ REPLY_MARK = "»";
13607
13756
  OVERSCAN = 2;
13608
13757
  SIGN_WIDTH = 2;
13609
13758
  SCROLL_ROWS = 1;
@@ -14138,10 +14287,10 @@ var init_diffview = __esmMin((() => {
14138
14287
  if (note.answers.length > 0) return `${marks().sent} answered${moved}`;
14139
14288
  return `${marks().sent} sent${moved}`;
14140
14289
  };
14141
- spokenLines = (body, room) => {
14142
- return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
14290
+ spokenLines = (body, room, mark) => {
14291
+ return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${mark} ${text}` : ` ${text}`);
14143
14292
  };
14144
- answerLines = (note, room) => note.answers.flatMap((body) => spokenLines(body, room));
14293
+ 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));
14145
14294
  noteLines = (note, room) => note.folded ? [`${headOf(note)} · press l`] : [
14146
14295
  headOf(note),
14147
14296
  ...note.body.split("\n").flatMap((line) => wrap(line, room)),
@@ -14691,7 +14840,8 @@ var init_render = __esmMin((() => {
14691
14840
  settled: entry.settled === true,
14692
14841
  stale: entry.stale === true,
14693
14842
  asks: entry.asks === true,
14694
- answers: entry.answers ?? []
14843
+ answers: entry.answers ?? [],
14844
+ turns: entry.turns ?? []
14695
14845
  }));
14696
14846
  notesFor = (state, path) => notesOf(state.sent, path, true, state.opened);
14697
14847
  paired = (chunks) => {
@@ -16055,6 +16205,7 @@ var init_app = __esmMin((() => {
16055
16205
  "thread.settle": () => this.settleHere(),
16056
16206
  "thread.settleRead": () => this.settleWhatIsRead(),
16057
16207
  "thread.remove": () => this.removeHere(),
16208
+ "thread.reply": () => this.replyHere(),
16058
16209
  "selection.copy": () => sync(() => this.copySelection(false)),
16059
16210
  "search.open": () => this.findSelection(),
16060
16211
  "search.jump": () => this.openMatch(),
@@ -16158,13 +16309,13 @@ var init_app = __esmMin((() => {
16158
16309
  }
16159
16310
  readBranch(name) {
16160
16311
  return gen({ self: this }, function* () {
16161
- const [patches, progress, layers, sent] = yield* all([
16162
- listPatches(this.repo, name),
16163
- reviewProgress(this.repo, name),
16164
- listLayers(this.repo, name),
16165
- this.loadSent(name)
16312
+ const reading = yield* readingOf(this.repo, name);
16313
+ const [progress, layers, sent] = yield* all([
16314
+ progressIn(reading),
16315
+ layersIn(reading),
16316
+ sentIn(reading)
16166
16317
  ], { concurrency: "unbounded" });
16167
- const opened = withVouched(withPatches(this.state, patches), progress.vouched);
16318
+ const opened = withVouched(withPatches(this.state, reading.patches), progress.vouched);
16168
16319
  return withLayers(withSent(opened, sent), layers);
16169
16320
  });
16170
16321
  }
@@ -16337,6 +16488,21 @@ var init_app = __esmMin((() => {
16337
16488
  this.commit(withNotice(this.staying(held, id), "settled"));
16338
16489
  });
16339
16490
  }
16491
+ replyHere() {
16492
+ return sync(() => {
16493
+ const thread = threadChosen(this.state) ?? threadAtStop(this.state) ?? threadAtRow(this.state, this.state.cursor);
16494
+ if (thread?.id === void 0) {
16495
+ this.commit(withNotice(this.state, "no thread here"));
16496
+ return;
16497
+ }
16498
+ this.commit({
16499
+ ...this.state,
16500
+ screen: "compose",
16501
+ draft: "",
16502
+ replyTo: thread.id
16503
+ });
16504
+ });
16505
+ }
16340
16506
  staying(state, id) {
16341
16507
  const at = panelIndexOf(state, id);
16342
16508
  const last = Math.max(0, panelEntries(state).length - 1);
@@ -16591,6 +16757,28 @@ var init_app = __esmMin((() => {
16591
16757
  });
16592
16758
  }
16593
16759
  send() {
16760
+ return this.state.replyTo === void 0 ? this.sendComment() : this.sendReply(this.state.replyTo);
16761
+ }
16762
+ sendReply(to) {
16763
+ return gen({ self: this }, function* () {
16764
+ const branch = selectedBranch(this.state);
16765
+ if (branch === void 0 || this.state.draft.length === 0) return;
16766
+ yield* submitReply({
16767
+ repo: this.repo,
16768
+ branch: branch.branch,
16769
+ to,
16770
+ body: yield* this.display.written,
16771
+ id: randomUUID(),
16772
+ at: (/* @__PURE__ */ new Date()).toISOString()
16773
+ });
16774
+ const sent = yield* this.loadSent(branch.branch);
16775
+ this.commit(withNotice(withSent({
16776
+ ...this.state,
16777
+ replyTo: void 0
16778
+ }, sent), "sent to the agent"));
16779
+ });
16780
+ }
16781
+ sendComment() {
16594
16782
  return gen({ self: this }, function* () {
16595
16783
  const patch = selectedPatch(this.state);
16596
16784
  const branch = selectedBranch(this.state);
@@ -16782,6 +16970,17 @@ const commentSend = fn("Main.commentSend")(function* (options) {
16782
16970
  });
16783
16971
  yield* answer(options, { batch });
16784
16972
  });
16973
+ const commentReply = fn("Main.commentReply")(function* (options) {
16974
+ const batch = yield* submitReply({
16975
+ repo: yield* required(options, "repo"),
16976
+ branch: yield* required(options, "branch"),
16977
+ to: yield* required(options, "to"),
16978
+ body: yield* required(options, "body"),
16979
+ id: options["id"] ?? randomUUID(),
16980
+ at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
16981
+ });
16982
+ yield* answer(options, { batch });
16983
+ });
16785
16984
  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 '…'`.";
16786
16985
  const commentTake = fn("Main.commentTake")(function* (options) {
16787
16986
  const worktree = yield* required(options, "worktree");
@@ -16891,6 +17090,7 @@ const routes = {
16891
17090
  "base set": baseSet,
16892
17091
  "base clear": baseClear,
16893
17092
  "comment send": commentSend,
17093
+ "comment reply": commentReply,
16894
17094
  "comment take": commentTake,
16895
17095
  "comment answer": commentAnswer,
16896
17096
  "comment list": commentList,
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.80",
26
+ "version": "0.1.0-alpha.82",
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": {
@@ -73,6 +73,20 @@ adiff comment answer --worktree . --id <id> --question --body "Drop it, or keep
73
73
  That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
74
74
  the work genuinely stops without an answer.
75
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
+
76
90
  Settling a thread is the reviewer's to do, not yours. They raised the point, so they decide it is
77
91
  closed.
78
92