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

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/main.js +493 -139
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.198
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(CLI): `comment list` gives every comment its mark (`stand`), its review panel `section`, `movedPast`, `about` for a request about the whole branch, `settleable` and the `layers` it is read in, and each file its loudest open mark.
8
+
9
+ feat(layers): `layers show` gives every layer its open comments and loudest mark, and a `parts` list with each file's own added and removed lines, read mark and open comments in that layer.
10
+
11
+ feat(CLI): `patch show` lists files in the terminal's tree order as `order`, and tags each row a layer holds with that layer.
12
+
13
+ feat(CLI): `review progress` names the layers whose lines changed since a file was marked reviewed.
14
+
15
+ feat(CLI): `file review` answers with the layers as they stand after the mark.
16
+
17
+ fix(layers rail): a file marked reviewed stays read in every layer whose lines did not change since, so a change in one layer's lines asks for a re-read only there.
18
+
19
+ feat(CLI): `comment send --from new:12 --to old:14` and `draft add` with the same options file a comment on the rows a reader picked, choosing the side as the terminal does.
20
+
21
+ feat(CLI): `patch since` tags each row with the layer that holds it, as `patch show` does.
22
+
23
+ feat(CLI): a review `adiff serve` watches names what changed (`comments`, `state`, `layers`, `watch`), so a second client re-reads only that instead of the whole review on every change, and never on an agent's half-second look for comments.
24
+
3
25
  ## 0.1.0-alpha.197
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.197";
10086
+ var version$1 = "0.1.0-alpha.198";
10087
10087
  //#endregion
10088
10088
  //#region src/cli/error.ts
10089
10089
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
@@ -10291,7 +10291,7 @@ var init_upgrade$1 = __esmMin((() => {
10291
10291
  }));
10292
10292
  //#endregion
10293
10293
  //#region src/cli/catalog.ts
10294
- var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10294
+ var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, picking, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10295
10295
  var init_catalog = __esmMin((() => {
10296
10296
  WAIT_MOST = 86400;
10297
10297
  worktreeOf$1 = {
@@ -10348,19 +10348,31 @@ var init_catalog = __esmMin((() => {
10348
10348
  value: "path",
10349
10349
  about: "File path as it appears in the diff"
10350
10350
  };
10351
- range = [
10351
+ picking = [
10352
10352
  file,
10353
10353
  {
10354
10354
  name: "start",
10355
- required: true,
10355
+ required: false,
10356
10356
  value: "line",
10357
- about: "First line of the range"
10357
+ about: "First line of the range, with --end"
10358
10358
  },
10359
10359
  {
10360
10360
  name: "end",
10361
- required: true,
10361
+ required: false,
10362
10362
  value: "line",
10363
- about: "Last line of the range"
10363
+ about: "Last line of the range, with --start"
10364
+ },
10365
+ {
10366
+ name: "from",
10367
+ required: false,
10368
+ value: "new|old:line",
10369
+ about: "The first row picked in the diff, as `new:12` or `old:40`. adiff chooses the side the terminal would: the new one when any picked row has a new line"
10370
+ },
10371
+ {
10372
+ name: "to",
10373
+ required: false,
10374
+ value: "new|old:line",
10375
+ about: "The last row picked, in the form of --from"
10364
10376
  },
10365
10377
  {
10366
10378
  name: "body",
@@ -10372,7 +10384,7 @@ var init_catalog = __esmMin((() => {
10372
10384
  name: "side",
10373
10385
  required: false,
10374
10386
  value: "new|old",
10375
- about: "Which version the lines are on. Defaults to new"
10387
+ about: "Which version --start and --end count on. Defaults to new"
10376
10388
  }
10377
10389
  ];
10378
10390
  READ_A_BRANCH = "Read a branch";
@@ -10564,11 +10576,11 @@ var init_catalog = __esmMin((() => {
10564
10576
  },
10565
10577
  {
10566
10578
  name: "comment send",
10567
- about: "Send one comment against a line range, straight to the agent",
10579
+ about: "Send one comment against a line range, straight to the agent. Name the range with --start and --end, or with the rows a reader picked, --from and --to",
10568
10580
  group: WRITE_COMMENTS,
10569
10581
  addresses: "review",
10570
10582
  safety: "write",
10571
- options: [...addressing, ...range],
10583
+ options: [...addressing, ...picking],
10572
10584
  dataKey: "batch",
10573
10585
  example: "adiff comment send --repo . --branch add-invitations --file src/api.ts --start 4 --end 5 --body \"why\""
10574
10586
  },
@@ -10727,11 +10739,11 @@ var init_catalog = __esmMin((() => {
10727
10739
  },
10728
10740
  {
10729
10741
  name: "draft add",
10730
- about: "Hold one comment against a line range, to be sent with the rest",
10742
+ about: "Hold one comment against a line range, to be sent with the rest. Name the range with --start and --end, or with the rows a reader picked, --from and --to",
10731
10743
  group: DRAFTS,
10732
10744
  addresses: "review",
10733
10745
  safety: "write",
10734
- options: [...addressing, ...range],
10746
+ options: [...addressing, ...picking],
10735
10747
  dataKey: "draft",
10736
10748
  example: "adiff draft add --repo . --branch their-change --file src/api.ts --start 4 --end 5 --body \"why\""
10737
10749
  },
@@ -11126,7 +11138,7 @@ var init_catalog = __esmMin((() => {
11126
11138
  }));
11127
11139
  //#endregion
11128
11140
  //#region src/cli/parse.ts
11129
- var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, numeric, WHOLE, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11141
+ var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, numeric, SPOT, spot, WHOLE, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11130
11142
  var init_parse$1 = __esmMin((() => {
11131
11143
  init_dist();
11132
11144
  init_catalog();
@@ -11213,6 +11225,20 @@ var init_parse$1 = __esmMin((() => {
11213
11225
  allowed: ["a whole number of 1 or more"]
11214
11226
  });
11215
11227
  });
11228
+ SPOT = /^(?<side>new|old):(?<line>[1-9]\d*)$/;
11229
+ spot = fn("Cli.spot")(function* (options, name) {
11230
+ const raw = yield* required(options, name);
11231
+ const found = SPOT.exec(raw)?.groups;
11232
+ const side = found?.["side"] === "old" ? "old" : "new";
11233
+ return yield* found === void 0 ? new BadOption({
11234
+ option: name,
11235
+ given: raw,
11236
+ allowed: ["new:<line>", "old:<line>"]
11237
+ }) : succeed$1({
11238
+ side,
11239
+ line: Number(found["line"])
11240
+ });
11241
+ });
11216
11242
  WHOLE = "all";
11217
11243
  around$1 = fn("Cli.around")(function* (options, name) {
11218
11244
  const raw = options[name];
@@ -11504,7 +11530,7 @@ var init_report$1 = __esmMin((() => {
11504
11530
  }));
11505
11531
  //#endregion
11506
11532
  //#region src/cli/serve.ts
11507
- var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11533
+ var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11508
11534
  var init_serve = __esmMin((() => {
11509
11535
  init_dist();
11510
11536
  init_error$5();
@@ -11540,21 +11566,37 @@ var init_serve = __esmMin((() => {
11540
11566
  answer: JSON.parse(heard.at(-1) ?? "{}")
11541
11567
  })), catchCause((cause) => succeed$1(refused(squash(cause)))));
11542
11568
  };
11569
+ KIND_OF = {
11570
+ "inbox.jsonl": "comments",
11571
+ "outbox.jsonl": "comments",
11572
+ "state.json": "state",
11573
+ "layers.json": "layers",
11574
+ "watch.json": "watch"
11575
+ };
11576
+ kindOf = (name) => name === null ? "other" : KIND_OF[name] ?? "other";
11543
11577
  settled$1 = (folder, tell) => {
11544
11578
  mkdirSync(folder, { recursive: true });
11545
11579
  let timer;
11546
- const watcher = watch(folder, () => {
11580
+ const seen = /* @__PURE__ */ new Set();
11581
+ const told = () => {
11582
+ const what = [...seen].toSorted();
11583
+ seen.clear();
11584
+ tell(what);
11585
+ };
11586
+ const watcher = watch(folder, (_event, name) => {
11587
+ seen.add(kindOf(name));
11547
11588
  if (timer !== void 0) clearTimeout(timer);
11548
- timer = setTimeout(tell, SETTLE_MS$1);
11589
+ timer = setTimeout(told, SETTLE_MS$1);
11549
11590
  });
11550
11591
  watcher.on("error", () => void 0);
11551
11592
  return watcher;
11552
11593
  };
11553
11594
  watching = (serving, request, watchers) => serving.folderOf(optionsFrom(request.watch ?? [], valuedIn("comment list"))).pipe(map$1((folder) => {
11554
11595
  watchers.get(request.id)?.close();
11555
- watchers.set(request.id, settled$1(folder, () => write({
11596
+ watchers.set(request.id, settled$1(folder, (what) => write({
11556
11597
  id: request.id,
11557
- event: "changed"
11598
+ event: "changed",
11599
+ what
11558
11600
  })));
11559
11601
  return {
11560
11602
  exit: 0,
@@ -11855,6 +11897,51 @@ var init_follow = __esmMin((() => {
11855
11897
  };
11856
11898
  }));
11857
11899
  //#endregion
11900
+ //#region src/domain/patch/order.ts
11901
+ var compareEntries, folder, folderAt, walk, treeOrder;
11902
+ var init_order = __esmMin((() => {
11903
+ compareEntries = (left, right) => {
11904
+ if (left.kind !== right.kind) return left.kind === "directory" ? -1 : 1;
11905
+ return left.name.localeCompare(right.name);
11906
+ };
11907
+ folder = () => ({
11908
+ folders: /* @__PURE__ */ new Map(),
11909
+ files: []
11910
+ });
11911
+ folderAt = (root, segments) => segments.reduce((at, segment) => {
11912
+ const found = at.folders.get(segment);
11913
+ if (found !== void 0) return found;
11914
+ const made = folder();
11915
+ at.folders.set(segment, made);
11916
+ return made;
11917
+ }, root);
11918
+ walk = (at) => [...[...at.folders].toSorted(([left], [right]) => compareEntries({
11919
+ name: left,
11920
+ kind: "directory"
11921
+ }, {
11922
+ name: right,
11923
+ kind: "directory"
11924
+ })).flatMap(([, inner]) => walk(inner)), ...at.files.toSorted((left, right) => compareEntries({
11925
+ ...left,
11926
+ kind: "file"
11927
+ }, {
11928
+ ...right,
11929
+ kind: "file"
11930
+ })).map((file) => file.path)];
11931
+ treeOrder = (paths) => {
11932
+ const root = folder();
11933
+ for (const path of paths) {
11934
+ const segments = path.split("/").filter((segment) => segment.length > 0);
11935
+ const name = segments.at(-1);
11936
+ if (name !== void 0) folderAt(root, segments.slice(0, -1)).files.push({
11937
+ name,
11938
+ path
11939
+ });
11940
+ }
11941
+ return walk(root);
11942
+ };
11943
+ }));
11944
+ //#endregion
11858
11945
  //#region src/domain/patch/reindent.ts
11859
11946
  var LCS_ROOM, body, isBlock, openBlock, sideOf, blocksOf$1, at, fillRow, lcsTable, joined, stepAt, walked, canFold, folded, rowsOf, reindexed, foldReindents;
11860
11947
  var init_reindent = __esmMin((() => {
@@ -12163,6 +12250,7 @@ var init_parse = __esmMin((() => {
12163
12250
  var init_patch = __esmMin((() => {
12164
12251
  init_anchor();
12165
12252
  init_follow();
12253
+ init_order();
12166
12254
  init_parse();
12167
12255
  init_sticky();
12168
12256
  init_model$5();
@@ -13453,7 +13541,7 @@ var init_branches$1 = __esmMin((() => {
13453
13541
  }));
13454
13542
  //#endregion
13455
13543
  //#region src/review/patches.ts
13456
- var findPatch, blobOf, anchorWith, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$1, show$3;
13544
+ var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$1, show$3;
13457
13545
  var init_patches = __esmMin((() => {
13458
13546
  init_dist();
13459
13547
  init_patch();
@@ -13462,17 +13550,42 @@ var init_patches = __esmMin((() => {
13462
13550
  init_branches$1();
13463
13551
  findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
13464
13552
  blobOf = (patches, file) => map$5(findPatch(patches, file), (patch) => patch.blob);
13465
- anchorWith = fn("Review.Diff.anchorWith")(function* (worktree, request) {
13466
- const only = yield* patches(worktree, WHOLE_FILE, request.file);
13553
+ wholeFile = fn("Review.Diff.wholeFile")(function* (worktree, file) {
13554
+ const only = yield* patches(worktree, WHOLE_FILE, file);
13467
13555
  const found = only.length > 0 ? only : yield* patches(worktree, WHOLE_FILE);
13468
- const patch = findPatch(found, request.file);
13469
- const resolved = yield* match$3(patch, {
13556
+ return yield* match$3(findPatch(found, file), {
13470
13557
  onNone: () => new UnknownFile({
13471
- file: request.file,
13558
+ file,
13472
13559
  known: found.map((candidate) => candidate.path)
13473
13560
  }),
13474
13561
  onSome: succeed$1
13475
13562
  });
13563
+ });
13564
+ rowAt = (patch, spot) => patch.rows.findIndex((row) => match$3(lineOn(row, spot.side), {
13565
+ onNone: () => false,
13566
+ onSome: (line) => line === spot.line
13567
+ }));
13568
+ picked = fn("Review.Diff.picked")(function* (worktree, request) {
13569
+ const resolved = yield* wholeFile(worktree, request.file);
13570
+ const first = rowAt(resolved, request.from);
13571
+ const last = rowAt(resolved, request.to);
13572
+ const anchored = first === -1 || last === -1 ? none() : anchorFor(resolved, first, last);
13573
+ return yield* match$3(anchored, {
13574
+ onNone: () => new UnselectableRange({
13575
+ file: request.file,
13576
+ start: request.from.line,
13577
+ end: request.to.line
13578
+ }),
13579
+ onSome: (made) => succeed$1({
13580
+ file: request.file,
13581
+ side: made.side,
13582
+ start: made.start,
13583
+ end: made.end
13584
+ })
13585
+ });
13586
+ });
13587
+ anchorWith = fn("Review.Diff.anchorWith")(function* (worktree, request) {
13588
+ const resolved = yield* wholeFile(worktree, request.file);
13476
13589
  const anchored = flatMap$2(rowsForRange(resolved, request), ([first, last]) => anchorFor(resolved, first, last, request.side));
13477
13590
  return yield* match$3(anchored, {
13478
13591
  onNone: () => new UnselectableRange({
@@ -13548,14 +13661,15 @@ var init_patches = __esmMin((() => {
13548
13661
  show$3 = fn("Review.Diff.show")(function* (based, showing) {
13549
13662
  const git = yield* Git;
13550
13663
  const { worktree } = based;
13551
- const patches$3 = yield* patches(worktree, linesAround(showing.context), showing.file);
13552
- const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$1(patches$3))], { concurrency: 2 });
13664
+ const patches$2 = yield* patches(worktree, linesAround(showing.context), showing.file);
13665
+ const [generated] = yield* all([git.generated(worktree, patches$2.map((patch) => patch.path)), git.keep(worktree, onDisk$1(patches$2))], { concurrency: 2 });
13553
13666
  return {
13554
13667
  branch: worktree.branch,
13555
13668
  base: based.base,
13556
13669
  mergeBase: worktree.base,
13557
13670
  head: worktree.head,
13558
- files: yield* forEach(patches$3, fileShown$1(worktree, generated), { concurrency: 16 })
13671
+ files: yield* forEach(patches$2, fileShown$1(worktree, generated), { concurrency: 16 }),
13672
+ order: treeOrder(patches$2.map((patch) => patch.path))
13559
13673
  };
13560
13674
  });
13561
13675
  }));
@@ -14208,13 +14322,81 @@ var init_comments$1 = __esmMin((() => {
14208
14322
  });
14209
14323
  }));
14210
14324
  //#endregion
14325
+ //#region src/domain/review/vouch.ts
14326
+ var SHORTEST_BLOB, sameBlob, isVouched, vouch$1, partOf, isPartVouched, vouchPart$1;
14327
+ var init_vouch = __esmMin((() => {
14328
+ SHORTEST_BLOB = 7;
14329
+ sameBlob = (left, right) => {
14330
+ if (left === void 0 || right === void 0) return false;
14331
+ if (left === right) return true;
14332
+ if (left.length < SHORTEST_BLOB || right.length < SHORTEST_BLOB) return false;
14333
+ return left.startsWith(right) || right.startsWith(left);
14334
+ };
14335
+ isVouched = (vouches, path, blob) => sameBlob(vouches[path], blob);
14336
+ vouch$1 = (vouches, path, blob) => {
14337
+ if (isVouched(vouches, path, blob)) {
14338
+ const { [path]: _cleared, ...rest } = vouches;
14339
+ return rest;
14340
+ }
14341
+ return {
14342
+ ...vouches,
14343
+ [path]: blob
14344
+ };
14345
+ };
14346
+ partOf = (path, runs) => {
14347
+ return `${path}@${[...runs].toSorted((left, right) => left.start - right.start || left.end - right.end).map((run) => `${run.start}-${run.end}`).join(",")}`;
14348
+ };
14349
+ isPartVouched = (vouches, part, blob) => sameBlob(vouches[part], blob);
14350
+ vouchPart$1 = (vouches, part, blob) => vouch$1(vouches, part, blob);
14351
+ }));
14352
+ //#endregion
14353
+ //#region src/domain/review/stand.ts
14354
+ var standOf, isMovedPast, SECTION_OF, sectionOf$1, STAND_WEIGHT, louderOf, isOpen;
14355
+ var init_stand = __esmMin((() => {
14356
+ standOf = (facts) => {
14357
+ if (facts.removed) return "gone";
14358
+ if (facts.settled) return "settled";
14359
+ if (facts.asks) return "asked";
14360
+ if (facts.answeredLast) return "answered";
14361
+ return facts.taken ? "waiting" : "filed";
14362
+ };
14363
+ isMovedPast = (facts) => facts.outside || facts.outdated && !facts.reworded;
14364
+ SECTION_OF = {
14365
+ filed: "filed",
14366
+ gone: "removed",
14367
+ settled: "settled",
14368
+ asked: "asked",
14369
+ answered: "answered",
14370
+ waiting: "with"
14371
+ };
14372
+ sectionOf$1 = (stand, movedPast) => movedPast && stand !== "settled" && stand !== "gone" ? "movedOn" : SECTION_OF[stand];
14373
+ STAND_WEIGHT = {
14374
+ gone: 0,
14375
+ settled: 1,
14376
+ filed: 2,
14377
+ waiting: 2,
14378
+ answered: 3,
14379
+ asked: 4
14380
+ };
14381
+ louderOf = (one, other) => STAND_WEIGHT[one] > STAND_WEIGHT[other] ? one : other;
14382
+ isOpen = (stand) => stand !== "settled" && stand !== "gone";
14383
+ }));
14384
+ //#endregion
14385
+ //#region src/domain/review/index.ts
14386
+ var init_review$1 = __esmMin((() => {
14387
+ init_vouch();
14388
+ init_stand();
14389
+ }));
14390
+ //#endregion
14211
14391
  //#region src/review/threads.ts
14212
- var stateOf$2, choicesOf, answerOf, turnsOf, threadOf, threadsIn$1, idsIn, rootIn, rootOf, isKnown, known, list$3, clearDoing, doing, answer$3, repliesTo, settle, without$1, unsettle, remove, restore$1, settleRead;
14392
+ var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf, threadsIn$1, idsIn, rootIn, rootOf, isKnown, known, list$3, clearDoing, doing, answer$3, repliesTo, settle, without$1, unsettle, remove, restore$1, settleRead, fileThreads, byFile$1;
14213
14393
  var init_threads$1 = __esmMin((() => {
14214
14394
  init_dist();
14215
14395
  init_store();
14216
14396
  init_error$2();
14217
14397
  init_placing();
14398
+ init_review$1();
14399
+ ASK_LEAD = "About this branch, not about this line.";
14218
14400
  stateOf$2 = (turns, asked, isSettled, isRemoved) => {
14219
14401
  if (isRemoved) return "removed";
14220
14402
  if (isSettled) return "done";
@@ -14239,6 +14421,41 @@ var init_threads$1 = __esmMin((() => {
14239
14421
  at: entry.at,
14240
14422
  ...choicesOf(entry)
14241
14423
  }))].toSorted((one, other) => one.at < other.at ? -1 : one.at > other.at ? 1 : 0);
14424
+ judged = (facts) => {
14425
+ const removed = facts.state === "removed";
14426
+ const stand = standOf({
14427
+ removed,
14428
+ settled: facts.settled,
14429
+ asks: facts.asks,
14430
+ answeredLast: facts.agentLast && facts.answers > 0,
14431
+ taken: facts.taken
14432
+ });
14433
+ const movedPast = isMovedPast(facts);
14434
+ return {
14435
+ movedPast,
14436
+ stand,
14437
+ section: sectionOf$1(stand, movedPast),
14438
+ settleable: facts.answers > 0 && facts.unread === 0 && !facts.settled && !removed
14439
+ };
14440
+ };
14441
+ factsOf = (gathered, conversation) => {
14442
+ const { held, ids, mine, turns, sits, settled, seen } = gathered;
14443
+ const path = held.comment.anchor.path;
14444
+ const agentLast = turns.at(-1)?.voice === "agent";
14445
+ const asked = mine.at(-1)?.asks === true;
14446
+ return {
14447
+ state: stateOf$2(turns, asked, settled, Object.hasOwn(conversation.removed, held.comment.id)),
14448
+ outdated: sits.placed && sits.outdated,
14449
+ outside: !conversation.shown.has(path) || !sits.placed,
14450
+ reworded: sits.placed && sits.reworded,
14451
+ unread: Math.max(0, mine.length - seen),
14452
+ taken: [...ids].some((id) => Object.hasOwn(conversation.taken, id)),
14453
+ settled,
14454
+ asks: agentLast && asked,
14455
+ answers: mine.length,
14456
+ agentLast
14457
+ };
14458
+ };
14242
14459
  threadOf = (held, replies, conversation) => {
14243
14460
  const { comment, batch } = held;
14244
14461
  const ids = /* @__PURE__ */ new Set([comment.id, ...replies.map((one) => one.comment.id)]);
@@ -14253,6 +14470,15 @@ var init_threads$1 = __esmMin((() => {
14253
14470
  reworded: false
14254
14471
  };
14255
14472
  const doing = conversation.doing[comment.id];
14473
+ const facts = factsOf({
14474
+ held,
14475
+ ids,
14476
+ mine,
14477
+ turns,
14478
+ sits,
14479
+ settled,
14480
+ seen
14481
+ }, conversation);
14256
14482
  return {
14257
14483
  id: comment.id,
14258
14484
  file: comment.anchor.path,
@@ -14262,12 +14488,15 @@ var init_threads$1 = __esmMin((() => {
14262
14488
  snippet: comment.anchor.snippet,
14263
14489
  body: comment.body,
14264
14490
  at: batch.at,
14265
- state: stateOf$2(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(conversation.removed, comment.id)),
14491
+ state: facts.state,
14266
14492
  stale: batch.head !== conversation.head,
14267
- outdated: sits.placed && sits.outdated,
14268
- outside: !conversation.shown.has(comment.anchor.path) || !sits.placed,
14269
- unread: Math.max(0, mine.length - seen),
14270
- taken: [...ids].some((id) => Object.hasOwn(conversation.taken, id)),
14493
+ outdated: facts.outdated,
14494
+ outside: facts.outside,
14495
+ reworded: facts.reworded,
14496
+ ...judged(facts),
14497
+ about: comment.body.startsWith("About this branch, not about this line.") ? "branch" : "line",
14498
+ unread: facts.unread,
14499
+ taken: facts.taken,
14271
14500
  answers: mine.map(answerOf),
14272
14501
  turns,
14273
14502
  settled,
@@ -14451,6 +14680,18 @@ var init_threads$1 = __esmMin((() => {
14451
14680
  }));
14452
14681
  return { settled: ripe.length };
14453
14682
  });
14683
+ fileThreads = (path, threads) => {
14684
+ const here = threads.filter((thread) => thread.file === path);
14685
+ return {
14686
+ path,
14687
+ open: here.length,
14688
+ stand: here.reduce((stand, one) => louderOf(stand, one.stand), "gone")
14689
+ };
14690
+ };
14691
+ byFile$1 = (threads) => {
14692
+ const open = threads.filter((thread) => isOpen(thread.stand) && thread.about === "line");
14693
+ return [...new Set(open.map((thread) => thread.file))].map((path) => fileThreads(path, open));
14694
+ };
14454
14695
  }));
14455
14696
  //#endregion
14456
14697
  //#region src/service/forge/error.ts
@@ -15157,41 +15398,8 @@ var init_remarks$1 = __esmMin((() => {
15157
15398
  });
15158
15399
  }));
15159
15400
  //#endregion
15160
- //#region src/domain/review/vouch.ts
15161
- var SHORTEST_BLOB, sameBlob, isVouched, vouch$1, partOf, isPartVouched, vouchPart$1;
15162
- var init_vouch = __esmMin((() => {
15163
- SHORTEST_BLOB = 7;
15164
- sameBlob = (left, right) => {
15165
- if (left === void 0 || right === void 0) return false;
15166
- if (left === right) return true;
15167
- if (left.length < SHORTEST_BLOB || right.length < SHORTEST_BLOB) return false;
15168
- return left.startsWith(right) || right.startsWith(left);
15169
- };
15170
- isVouched = (vouches, path, blob) => sameBlob(vouches[path], blob);
15171
- vouch$1 = (vouches, path, blob) => {
15172
- if (isVouched(vouches, path, blob)) {
15173
- const { [path]: _cleared, ...rest } = vouches;
15174
- return rest;
15175
- }
15176
- return {
15177
- ...vouches,
15178
- [path]: blob
15179
- };
15180
- };
15181
- partOf = (path, runs) => {
15182
- return `${path}@${[...runs].toSorted((left, right) => left.start - right.start || left.end - right.end).map((run) => `${run.start}-${run.end}`).join(",")}`;
15183
- };
15184
- isPartVouched = (vouches, part, blob) => sameBlob(vouches[part], blob);
15185
- vouchPart$1 = (vouches, part, blob) => vouch$1(vouches, part, blob);
15186
- }));
15187
- //#endregion
15188
- //#region src/domain/review/index.ts
15189
- var init_review$1 = __esmMin((() => {
15190
- init_vouch();
15191
- }));
15192
- //#endregion
15193
15401
  //#region src/review/vouching.ts
15194
- var pathOfMark, changedSince, readParts, restamped, now, keepMarked, fullBlob, blobIn, stateAfter, toggle, marksOf, newestFirst, speaking, contentNow, diffSince, placesIn, counted$1, reportSince, isGone, goneSince, lapsedIn, sinceReview, progress, unchanged, markOf, since;
15402
+ var pathOfMark, changedSince, readParts, restamped, now, keepMarked, fullBlob, blobIn, stateAfter, toggle, marksOf, newestFirst, speaking, contentNow, diffSince, placesIn, counted$1, nearestNew$1, touchedIn, touchedLines, holdsAny, layersTouched, untouchedParts, partsStillRead, stillRead, reportSince, isGone, goneSince, lapsedIn, sinceReview, progress, unchanged, markOf, since;
15195
15403
  var init_vouching$1 = __esmMin((() => {
15196
15404
  init_dist();
15197
15405
  init_patch();
@@ -15315,7 +15523,39 @@ var init_vouching$1 = __esmMin((() => {
15315
15523
  places: placesIn(found)
15316
15524
  })
15317
15525
  });
15318
- reportSince = fn("Review.Vouch.reportSince")(function* (worktree, asked) {
15526
+ nearestNew$1 = (rows, at) => {
15527
+ const near = [...rows.slice(at + 1), ...rows.slice(0, at).toReversed()].find((row) => isSome(row.newLine));
15528
+ return near === void 0 ? [] : toArray(near.newLine);
15529
+ };
15530
+ touchedIn = (rows) => rows.flatMap((row, at) => {
15531
+ if (row.kind === "context") return [];
15532
+ return isSome(row.newLine) ? [row.newLine.value] : nearestNew$1(rows, at);
15533
+ });
15534
+ touchedLines = (patch) => patch.hunks.flatMap((hunk) => touchedIn(hunk.rows));
15535
+ holdsAny = (own, path, lines) => own.some((span) => span.path === path && lines.some((line) => line >= span.start && line <= span.end));
15536
+ layersTouched = (spans, path, patch) => {
15537
+ const lines = match$3(patch, {
15538
+ onNone: () => [],
15539
+ onSome: touchedLines
15540
+ });
15541
+ return spans.flatMap((own, at) => holdsAny(own, path, lines) ? [at + 1] : []);
15542
+ };
15543
+ untouchedParts = (spans, path, touched) => spans.flatMap((own, at) => {
15544
+ const mine = own.filter((span) => span.path === path);
15545
+ return mine.length === 0 || touched.includes(at + 1) ? [] : [partOf(path, mine)];
15546
+ });
15547
+ partsStillRead = fn("Review.Vouch.partsStillRead")(function* (worktree, patch, marked, spans) {
15548
+ const kept = yield* (yield* Git).kept(worktree, marked);
15549
+ if (isNone(kept)) return [];
15550
+ const since = yield* diffSince(worktree, patch.path, kept.value, 3);
15551
+ return untouchedParts(spans, patch.path, layersTouched(spans, patch.path, since));
15552
+ });
15553
+ stillRead = fn("Review.Vouch.stillRead")(function* (reading, vouches, spans) {
15554
+ if (spans.length === 0) return [];
15555
+ const lapsed = reading.patches.filter((patch) => Object.hasOwn(vouches, patch.path) && !isVouched(vouches, patch.path, patch.blob));
15556
+ return (yield* forEach(lapsed, (patch) => partsStillRead(reading.worktree, patch, vouches[patch.path] ?? "", spans), { concurrency: 8 })).flat();
15557
+ });
15558
+ reportSince = fn("Review.Vouch.reportSince")(function* (worktree, asked, spans) {
15319
15559
  const git = yield* Git;
15320
15560
  const { mark } = asked;
15321
15561
  const told = {
@@ -15330,13 +15570,15 @@ var init_vouching$1 = __esmMin((() => {
15330
15570
  added: 0,
15331
15571
  removed: 0,
15332
15572
  places: 0,
15333
- kept: false
15573
+ kept: false,
15574
+ layers: []
15334
15575
  };
15335
15576
  const patch = yield* diffSince(worktree, mark.path, kept.value, 3);
15336
15577
  return {
15337
15578
  ...told,
15338
15579
  ...counted$1(patch),
15339
- kept: true
15580
+ kept: true,
15581
+ layers: layersTouched(spans, mark.path, patch)
15340
15582
  };
15341
15583
  });
15342
15584
  isGone = fn("Review.Vouch.isGone")(function* (worktree, path) {
@@ -15352,16 +15594,16 @@ var init_vouching$1 = __esmMin((() => {
15352
15594
  mark,
15353
15595
  deleted: patch.status === "deleted"
15354
15596
  })));
15355
- sinceReview = fn("Review.Vouch.sinceReview")(function* (reading, state, changed) {
15597
+ sinceReview = fn("Review.Vouch.sinceReview")(function* (reading, state, changed, spans) {
15356
15598
  const marks = marksOf(state);
15357
15599
  const gone = yield* goneSince(reading.worktree, marks, reading.patches);
15358
15600
  const asked = [...lapsedIn(reading.patches, marks, changed), ...gone.map((mark) => ({
15359
15601
  mark,
15360
15602
  deleted: true
15361
15603
  }))];
15362
- return yield* forEach(asked, (one) => reportSince(reading.worktree, one), { concurrency: 8 });
15604
+ return yield* forEach(asked, (one) => reportSince(reading.worktree, one, spans), { concurrency: 8 });
15363
15605
  });
15364
- progress = fn("Review.Vouch.progress")(function* (reading) {
15606
+ progress = fn("Review.Vouch.progress")(function* (reading, spans = []) {
15365
15607
  const current = yield* (yield* Store).state(reading.worktree.path);
15366
15608
  const files = reading.patches.map((patch) => ({
15367
15609
  path: patch.path,
@@ -15370,9 +15612,9 @@ var init_vouching$1 = __esmMin((() => {
15370
15612
  const changed = changedSince([current.vouches, current.parts], files);
15371
15613
  return {
15372
15614
  vouched: files.filter((file) => isVouched(current.vouches, file.path, file.blob)).map((f) => f.path),
15373
- parts: readParts(current.parts, files),
15615
+ parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current.vouches, spans)],
15374
15616
  changed,
15375
- since: yield* sinceReview(reading, current, changed),
15617
+ since: yield* sinceReview(reading, current, changed, spans),
15376
15618
  total: reading.patches.length
15377
15619
  };
15378
15620
  });
@@ -15550,7 +15792,7 @@ var init_preferences = __esmMin((() => {
15550
15792
  }));
15551
15793
  //#endregion
15552
15794
  //#region src/review/layers.ts
15553
- var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, storedLayers, set, readInLayer, withRead, show$1, read, partsOfFile, vouchPart, ASK_LEAD, askingFor, ask, claims, vouchIn;
15795
+ var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, partIn, reportedLayers, reportOf, storedLayers, set, readInLayer, withRead, coversThread, readsFile, lastHolding, layersHolding$1, loudest, partWithThreads, withThreads, readReport, view, show$1, placeThreads, spansIn, layersAt, taggedRow, nearestNew, lineNow, taggedHunk, taggedFile, tagSince, tagRows, read, partsOfFile, vouchPart, askingFor, ask, claims, vouchIn;
15554
15796
  var init_layers = __esmMin((() => {
15555
15797
  init_dist();
15556
15798
  init_layers$1();
@@ -15558,6 +15800,7 @@ var init_layers = __esmMin((() => {
15558
15800
  init_review$1();
15559
15801
  init_error$2();
15560
15802
  init_comments$1();
15803
+ init_threads$1();
15561
15804
  init_branches$1();
15562
15805
  init_vouching$1();
15563
15806
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
@@ -15659,16 +15902,18 @@ var init_layers = __esmMin((() => {
15659
15902
  ...layers,
15660
15903
  parent: getOrUndefined$1(layers.parent)
15661
15904
  });
15905
+ partIn = (patches, layer, path) => Object.assign({ path }, linesClaimed(patches.filter((patch) => patch.path === path), layer));
15662
15906
  reportedLayers = (patches, layers) => {
15663
15907
  const present = new Set(patches.map((patch) => patch.path));
15664
15908
  return withFullCoverage(patches, layers).layers.map((layer, at) => {
15665
15909
  const named = unique(spansOfLayer(layer).map((span) => span.path));
15666
15910
  const gap = coverage(patches, [layer]);
15667
15911
  const lines = linesClaimed(patches, layer);
15912
+ const files = named.filter((path) => present.has(path));
15668
15913
  return {
15669
15914
  title: layer.title,
15670
15915
  note: noteOf(layer),
15671
- files: named.filter((path) => present.has(path)),
15916
+ files,
15672
15917
  spans: spansOfLayer(layer),
15673
15918
  prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path)),
15674
15919
  covered: gap.covered,
@@ -15676,7 +15921,8 @@ var init_layers = __esmMin((() => {
15676
15921
  added: lines.added,
15677
15922
  removed: lines.removed,
15678
15923
  vanished: named.filter((path) => !present.has(path)),
15679
- unclaimed: at >= layers.layers.length
15924
+ unclaimed: at >= layers.layers.length,
15925
+ parts: files.map((path) => partIn(patches, layer, path))
15680
15926
  };
15681
15927
  });
15682
15928
  };
@@ -15736,29 +15982,128 @@ var init_layers = __esmMin((() => {
15736
15982
  const read = readInLayer(layer, reading);
15737
15983
  return Object.assign({}, layer, {
15738
15984
  read,
15739
- done: layer.files.length > 0 && read.length === layer.files.length
15985
+ done: layer.files.length > 0 && read.length === layer.files.length,
15986
+ parts: layer.parts.map((part) => ({
15987
+ ...part,
15988
+ read: read.includes(part.path)
15989
+ }))
15740
15990
  });
15741
15991
  })
15742
15992
  });
15743
- show$1 = fn("Review.Layers.show")(function* (worktree) {
15744
- const store = yield* Store;
15745
- const patches$2 = yield* patches(worktree);
15746
- const found = yield* storedLayers(worktree);
15747
- const layers = yield* match$3(found, {
15748
- onNone: () => new NoLayers({ worktree: worktree.path }),
15749
- onSome: succeed$1
15993
+ coversThread = (layer, thread) => thread.side === "new" && layer.spans.some((span) => span.path === thread.file && thread.start <= span.end && thread.end >= span.start);
15994
+ readsFile = (layer, file) => layer.read?.includes(file) === true;
15995
+ lastHolding = (layers, file, at) => layers.every((other, index) => index === at || !claims(other, file) || readsFile(other, file));
15996
+ layersHolding$1 = (layers, thread) => {
15997
+ if (thread.about === "branch") return [];
15998
+ const covering = layers.flatMap((layer, at) => coversThread(layer, thread) ? [at + 1] : []);
15999
+ if (covering.length > 0) return covering;
16000
+ return layers.flatMap((layer, at) => claims(layer, thread.file) && lastHolding(layers, thread.file, at) ? [at + 1] : []);
16001
+ };
16002
+ loudest = (threads) => threads.reduce((stand, thread) => louderOf(stand, thread.stand), "gone");
16003
+ partWithThreads = (part, threads) => {
16004
+ const here = threads.filter((thread) => thread.file === part.path);
16005
+ return Object.assign({}, part, {
16006
+ open: here.length,
16007
+ stand: loudest(here)
15750
16008
  });
15751
- const current = yield* store.state(worktree.path);
15752
- const files = patches$2.map((patch) => ({
16009
+ };
16010
+ withThreads = (report, threads) => {
16011
+ const open = threads.filter((thread) => isOpen(thread.stand)).map((thread) => ({
16012
+ thread,
16013
+ layers: layersHolding$1(report.layers, thread)
16014
+ }));
16015
+ return {
16016
+ ...report,
16017
+ layers: report.layers.map((layer, at) => {
16018
+ const mine = open.filter((one) => one.layers.includes(at + 1)).map((one) => one.thread);
16019
+ return Object.assign({}, layer, {
16020
+ open: mine.length,
16021
+ stand: loudest(mine),
16022
+ parts: layer.parts.map((part) => partWithThreads(part, mine))
16023
+ });
16024
+ })
16025
+ };
16026
+ };
16027
+ readReport = fn("Review.Layers.readReport")(function* (reading) {
16028
+ const store = yield* Store;
16029
+ const found = yield* storedLayers(reading.worktree);
16030
+ if (isNone(found)) return none();
16031
+ const current = yield* store.state(reading.worktree.path);
16032
+ const files = reading.patches.map((patch) => ({
15753
16033
  path: patch.path,
15754
16034
  blob: patch.blob
15755
16035
  }));
15756
- return withRead(reportOf(patches$2, layers, worktree.head), {
15757
- patches: patches$2,
16036
+ const report = reportOf(reading.patches, found.value, reading.worktree.head);
16037
+ const spans = report.layers.map((layer) => layer.spans);
16038
+ return some(withRead(report, {
16039
+ patches: reading.patches,
15758
16040
  vouches: current.vouches,
15759
- parts: readParts(current.parts, files)
16041
+ parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current.vouches, spans)]
16042
+ }));
16043
+ });
16044
+ view = fn("Review.Layers.view")(function* (reading) {
16045
+ const found = yield* readReport(reading);
16046
+ if (isNone(found)) return none();
16047
+ return some(withThreads(found.value, yield* list$3(reading)));
16048
+ });
16049
+ show$1 = fn("Review.Layers.show")(function* (worktree) {
16050
+ const found = yield* view({
16051
+ worktree,
16052
+ patches: yield* patches(worktree)
16053
+ });
16054
+ return yield* match$3(found, {
16055
+ onNone: () => new NoLayers({ worktree: worktree.path }),
16056
+ onSome: succeed$1
15760
16057
  });
15761
16058
  });
16059
+ placeThreads = fn("Review.Layers.placeThreads")(function* (reading, threads) {
16060
+ const found = yield* readReport(reading);
16061
+ return threads.map((thread) => ({
16062
+ ...thread,
16063
+ layers: match$3(found, {
16064
+ onNone: () => [],
16065
+ onSome: (report) => layersHolding$1(report.layers, thread)
16066
+ })
16067
+ }));
16068
+ });
16069
+ spansIn = fn("Review.Layers.spansIn")(function* (reading) {
16070
+ const found = yield* storedLayers(reading.worktree);
16071
+ return match$3(found, {
16072
+ onNone: () => [],
16073
+ onSome: (layers) => reportedLayers(reading.patches, layers).map((layer) => layer.spans)
16074
+ });
16075
+ });
16076
+ layersAt = (spans, path, line) => spans.flatMap((own, at) => own.some((span) => span.path === path && span.start <= line && span.end >= line) ? [at + 1] : []);
16077
+ taggedRow = (spans, path, row, line) => {
16078
+ if (row.kind === "note" || line === void 0) return row;
16079
+ const layers = layersAt(spans, path, line);
16080
+ return layers.length === 0 ? row : {
16081
+ ...row,
16082
+ layers
16083
+ };
16084
+ };
16085
+ nearestNew = (rows, at) => [...rows.slice(at + 1), ...rows.slice(0, at).toReversed()].find((row) => row.new !== void 0)?.new;
16086
+ lineNow = (rows, row, at) => row.new ?? (row.kind === "removed" ? nearestNew(rows, at) : void 0);
16087
+ taggedHunk = (spans, path, hunk, newOnly = false) => Object.assign({}, hunk, { rows: hunk.rows.map((row, at) => taggedRow(spans, path, row, newOnly ? lineNow(hunk.rows, row, at) : row.new ?? row.old)) });
16088
+ taggedFile = (spans, file, newOnly = false) => Object.assign({}, file, { hunks: file.hunks.map((hunk) => taggedHunk(spans, file.path, hunk, newOnly)) });
16089
+ tagSince = fn("Review.Layers.tagSince")(function* (worktree, shown) {
16090
+ const spans = yield* spansIn({
16091
+ worktree,
16092
+ patches: yield* patches(worktree)
16093
+ });
16094
+ return spans.length === 0 ? shown : taggedFile(spans, shown, true);
16095
+ });
16096
+ tagRows = fn("Review.Layers.tagRows")(function* (worktree, shown) {
16097
+ const spans = yield* spansIn({
16098
+ worktree,
16099
+ patches: yield* patches(worktree)
16100
+ });
16101
+ if (spans.length === 0) return shown;
16102
+ return {
16103
+ ...shown,
16104
+ files: shown.files.map((file) => taggedFile(spans, file))
16105
+ };
16106
+ });
15762
16107
  read = fn("Review.Layers.read")(function* (reading) {
15763
16108
  const worktree = reading.worktree;
15764
16109
  const found = yield* storedLayers(worktree);
@@ -15812,7 +16157,6 @@ var init_layers = __esmMin((() => {
15812
16157
  total: reading.patches.length
15813
16158
  };
15814
16159
  });
15815
- ASK_LEAD = "About this branch, not about this line.";
15816
16160
  askingFor = (told) => {
15817
16161
  if (told.count === 0) return `${ASK_LEAD} Please write a reading order for it with \`adiff layers set\`, so the diff can be read in the order the change was made rather than by filename.`;
15818
16162
  if (told.stale) return `${ASK_LEAD} The reading order on it describes an older commit — please read the diff again and write a new one with \`adiff layers set\`.`;
@@ -17788,6 +18132,7 @@ var init_match = __esmMin((() => {
17788
18132
  var HOLDS$1, chosenNow, withChosen, EDITOR_ROW, editorRow, preferenceRows, nothingReviewed, nothingFound, initialState, selectedBranch, selectedPatch, pullHere, authorHere, theirPull, heldWhere, noteEditing, hasNoPull, onLayers, selectedLayer, movedPast;
17789
18133
  var init_state = __esmMin((() => {
17790
18134
  init_preferences$1();
18135
+ init_review$1();
17791
18136
  init_gaps();
17792
18137
  HOLDS$1 = {
17793
18138
  wrap: "wrap",
@@ -17933,7 +18278,11 @@ var init_state = __esmMin((() => {
17933
18278
  hasNoPull = (state) => state.forge === "answered" && pullHere(state).length === 0;
17934
18279
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
17935
18280
  selectedLayer = (state) => state.layers[state.layerIndex];
17936
- movedPast = (comment) => comment.outside === true || comment.outdated === true && comment.reworded !== true;
18281
+ movedPast = (comment) => isMovedPast({
18282
+ outside: comment.outside === true,
18283
+ outdated: comment.outdated === true,
18284
+ reworded: comment.reworded === true
18285
+ });
17937
18286
  }));
17938
18287
  //#endregion
17939
18288
  //#region src/tui/cursor.ts
@@ -18020,6 +18369,7 @@ var init_cursor = __esmMin((() => {
18020
18369
  //#region src/tui/tree.ts
18021
18370
  var add, directoryOf, compare, buildTree, chain, visit, flattenTree, directFiles, filesUnder, crowdedDirectories;
18022
18371
  var init_tree = __esmMin((() => {
18372
+ init_patch();
18023
18373
  add = (tree, input) => {
18024
18374
  const id = tree.nodes.length;
18025
18375
  tree.nodes.push({
@@ -18059,8 +18409,7 @@ var init_tree = __esmMin((() => {
18059
18409
  const a = tree.nodes[left];
18060
18410
  const b = tree.nodes[right];
18061
18411
  if (a === void 0 || b === void 0) return 0;
18062
- if (a.kind !== b.kind) return a.kind === "directory" ? -1 : 1;
18063
- return a.name.localeCompare(b.name);
18412
+ return compareEntries(a, b);
18064
18413
  };
18065
18414
  buildTree = (paths) => {
18066
18415
  const tree = {
@@ -18568,9 +18917,10 @@ var init_layerview = __esmMin((() => {
18568
18917
  }));
18569
18918
  //#endregion
18570
18919
  //#region src/tui/panel.ts
18571
- var PANEL_SECTIONS, answersIn, newerOf, lastVoice, SECTION_OF, outsideOpen, sectionOf, sentEntry, remarkRows, panelHolds, panelEntries, panelEntry, threadChosen, MINUTE, HOUR, DAY, agoText, threadStand, STAND_WEIGHT, louderOf;
18920
+ var PANEL_SECTIONS, answersIn, newerOf, lastVoice, sectionOf, sentEntry, remarkRows, panelHolds, panelEntries, panelEntry, threadChosen, MINUTE, HOUR, DAY, agoText, threadStand;
18572
18921
  var init_panel = __esmMin((() => {
18573
18922
  init_state();
18923
+ init_review$1();
18574
18924
  PANEL_SECTIONS = [
18575
18925
  "remarks",
18576
18926
  "held",
@@ -18591,16 +18941,7 @@ var init_panel = __esmMin((() => {
18591
18941
  return answersIn(later) > answersIn(comment) ? later : comment;
18592
18942
  };
18593
18943
  lastVoice = (comment) => comment.turns?.at(-1)?.voice;
18594
- SECTION_OF = {
18595
- filed: "filed",
18596
- gone: "removed",
18597
- settled: "settled",
18598
- asked: "asked",
18599
- answered: "answered",
18600
- waiting: "with"
18601
- };
18602
- outsideOpen = (comment) => movedPast(comment) && comment.settled !== true && comment.removed !== true;
18603
- sectionOf = (comment) => outsideOpen(comment) ? "movedOn" : SECTION_OF[threadStand(comment)];
18944
+ sectionOf = (comment) => sectionOf$1(threadStand(comment), movedPast(comment));
18604
18945
  sentEntry = (state, comment) => {
18605
18946
  const newer = newerOf(state, comment);
18606
18947
  return {
@@ -18665,22 +19006,13 @@ var init_panel = __esmMin((() => {
18665
19006
  if (gap < 864e5) return `${Math.floor(gap / HOUR)}h ago`;
18666
19007
  return `${Math.floor(gap / DAY)}d ago`;
18667
19008
  };
18668
- threadStand = (thread) => {
18669
- if (thread.removed === true) return "gone";
18670
- if (thread.settled === true) return "settled";
18671
- if (thread.asks === true) return "asked";
18672
- if (lastVoice(thread) === "agent" && answersIn(thread) > 0) return "answered";
18673
- return thread.takenAt === void 0 ? "filed" : "waiting";
18674
- };
18675
- STAND_WEIGHT = {
18676
- gone: 0,
18677
- settled: 1,
18678
- filed: 2,
18679
- waiting: 2,
18680
- answered: 3,
18681
- asked: 4
18682
- };
18683
- louderOf = (one, other) => STAND_WEIGHT[one] > STAND_WEIGHT[other] ? one : other;
19009
+ threadStand = (thread) => standOf({
19010
+ removed: thread.removed === true,
19011
+ settled: thread.settled === true,
19012
+ asks: thread.asks === true,
19013
+ answeredLast: lastVoice(thread) === "agent" && answersIn(thread) > 0,
19014
+ taken: thread.takenAt !== void 0
19015
+ });
18684
19016
  }));
18685
19017
  //#endregion
18686
19018
  //#region src/tui/notes.ts
@@ -23747,7 +24079,7 @@ var init_branches = __esmMin((() => {
23747
24079
  app.reading = reading$1;
23748
24080
  yield* markOpened(reading$1.worktree, (/* @__PURE__ */ new Date()).toISOString());
23749
24081
  const [progress$2, layers, sent, remarks, drafts] = yield* all([
23750
- progress(reading$1),
24082
+ flatMap(spansIn(reading$1), (spans) => progress(reading$1, spans)),
23751
24083
  read(reading$1),
23752
24084
  listSent(reading$1),
23753
24085
  app.state.remarksOn ? list$2(reading$1) : succeed$1([]),
@@ -23919,7 +24251,7 @@ var init_branches = __esmMin((() => {
23919
24251
  const branch = selectedBranch(app.state);
23920
24252
  if (branch === void 0) return;
23921
24253
  const reading = yield* readingOf(app, branch.branch);
23922
- const [sent, progress$1] = yield* all([listSent(reading), progress(reading)]);
24254
+ const [sent, progress$1] = yield* all([listSent(reading), flatMap(spansIn(reading), (spans) => progress(reading, spans))]);
23923
24255
  if (sameSent(app.state.sent, sent) && sameMarks(app.state, progress$1)) return;
23924
24256
  app.commit(withVouched({
23925
24257
  ...app.state,
@@ -26021,13 +26353,25 @@ const baseClear = fn("Main.baseClear")(function* (options) {
26021
26353
  const report = yield* clearBase(yield* required(options, "repo"), yield* worktreeIn(options));
26022
26354
  yield* answer(options, { base: report });
26023
26355
  });
26024
- const commentSend = fn("Main.commentSend")(function* (options) {
26025
- const batch = yield* submit(yield* worktreeIn(options), {
26026
- file: yield* required(options, "file"),
26356
+ const rangeIn = fn("Main.rangeIn")(function* (options, worktree) {
26357
+ const file = yield* required(options, "file");
26358
+ if (options["from"] !== void 0 || options["to"] !== void 0) return yield* picked(worktree, {
26359
+ file,
26360
+ from: yield* spot(options, "from"),
26361
+ to: yield* spot(options, options["to"] === void 0 ? "from" : "to")
26362
+ });
26363
+ return {
26364
+ file,
26027
26365
  start: yield* numeric(options, "start"),
26028
26366
  end: yield* numeric(options, "end"),
26367
+ side: yield* oneOf(options, "side", ["old", "new"], "new")
26368
+ };
26369
+ });
26370
+ const commentSend = fn("Main.commentSend")(function* (options) {
26371
+ const worktree = yield* worktreeIn(options);
26372
+ const batch = yield* submit(worktree, {
26373
+ ...yield* rangeIn(options, worktree),
26029
26374
  body: yield* required(options, "body"),
26030
- side: yield* oneOf(options, "side", ["old", "new"], "new"),
26031
26375
  id: options["id"] ?? randomUUID(),
26032
26376
  at: stamp(options)
26033
26377
  });
@@ -26038,12 +26382,10 @@ const draftList = fn("Main.draftList")(function* (options) {
26038
26382
  yield* answer(options, { drafts });
26039
26383
  });
26040
26384
  const draftAdd = fn("Main.draftAdd")(function* (options) {
26041
- const draft = yield* add$1(yield* worktreeIn(options), {
26042
- file: yield* required(options, "file"),
26043
- start: yield* numeric(options, "start"),
26044
- end: yield* numeric(options, "end"),
26385
+ const worktree = yield* worktreeIn(options);
26386
+ const draft = yield* add$1(worktree, {
26387
+ ...yield* rangeIn(options, worktree),
26045
26388
  body: yield* required(options, "body"),
26046
- side: yield* oneOf(options, "side", ["old", "new"], "new"),
26047
26389
  id: options["id"] ?? randomUUID(),
26048
26390
  at: stamp(options),
26049
26391
  wroteBy: "agent"
@@ -26133,8 +26475,12 @@ const remarkRestore = fn("Main.remarkRestore")(function* (options) {
26133
26475
  yield* answer(options, { restored: report.restored });
26134
26476
  });
26135
26477
  const commentList = fn("Main.commentList")(function* (options) {
26136
- const comments = yield* list$3(yield* readingIn(options));
26137
- yield* answer(options, { comments });
26478
+ const reading = yield* readingIn(options);
26479
+ const comments = yield* placeThreads(reading, yield* list$3(reading));
26480
+ yield* answer(options, {
26481
+ comments,
26482
+ files: byFile$1(comments)
26483
+ });
26138
26484
  });
26139
26485
  const resolveRead = fn("Main.resolveRead")(function* (options) {
26140
26486
  const report = yield* settleRead(yield* worktreeIn(options), stamp(options));
@@ -26206,13 +26552,19 @@ const vouched = fn("Main.vouched")(function* (options) {
26206
26552
  });
26207
26553
  const fileReview = fn("Main.fileReview")(function* (options) {
26208
26554
  const report = yield* vouched(options);
26555
+ const layers = yield* view(yield* readingIn(options));
26209
26556
  yield* answer(options, {
26210
26557
  reviewed: report.vouched,
26211
- total: report.total
26558
+ total: report.total,
26559
+ ...match$3(layers, {
26560
+ onNone: () => ({}),
26561
+ onSome: (found) => ({ layers: found })
26562
+ })
26212
26563
  });
26213
26564
  });
26214
26565
  const reviewStatus = fn("Main.reviewStatus")(function* (options) {
26215
- const report = yield* progress(yield* readingIn(options));
26566
+ const reading = yield* readingIn(options);
26567
+ const report = yield* progress(reading, yield* spansIn(reading));
26216
26568
  yield* answer(options, {
26217
26569
  reviewed: report.vouched,
26218
26570
  changed: report.changed,
@@ -26237,15 +26589,17 @@ const layersShow = fn("Main.layersShow")(function* (options) {
26237
26589
  });
26238
26590
  const patchShow = fn("Main.patchShow")(function* (options) {
26239
26591
  const based = yield* basedAt(yield* required(options, "worktree"), options["base"]);
26240
- const patch = yield* show$3(based, {
26592
+ const shown = yield* show$3(based, {
26241
26593
  file: options["file"],
26242
26594
  context: yield* around$1(options, "context")
26243
26595
  });
26596
+ const patch = yield* tagRows(based.worktree, shown);
26244
26597
  yield* answer(options, { patch });
26245
26598
  });
26246
26599
  const patchSince = fn("Main.patchSince")(function* (options) {
26247
26600
  const based = yield* basedAt(yield* required(options, "worktree"), options["base"]);
26248
- const file = yield* since(based, yield* required(options, "file"), { context: yield* around$1(options, "context") });
26601
+ const shown = yield* since(based, yield* required(options, "file"), { context: yield* around$1(options, "context") });
26602
+ const file = yield* tagSince(based.worktree, shown);
26249
26603
  yield* answer(options, { file });
26250
26604
  });
26251
26605
  const configList = fn("Main.configList")(function* (options) {
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.197",
26
+ "version": "0.1.0-alpha.198",
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": {