@eliya-oss/agent-diff 0.1.0-alpha.196 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
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
+
25
+ ## 0.1.0-alpha.197
26
+
27
+ ### Patch Changes
28
+
29
+ - feat(layers): `layers show` and `layers set` give every layer `added` and `removed`, the changed lines inside its own spans.
30
+
31
+ feat(layers rail): a folded layer's count line carries the lines it adds and removes, next to how many of its files are read.
32
+
33
+ feat(layers): `layers show` says which layer is `done` and which one is the `unclaimed` layer of lines no layer claims.
34
+
3
35
  ## 0.1.0-alpha.196
4
36
 
5
37
  ### 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.196";
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
  }));
@@ -13567,7 +13681,7 @@ var init_model$3 = __esmMin((() => {
13567
13681
  }));
13568
13682
  //#endregion
13569
13683
  //#region src/domain/layers/coverage.ts
13570
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
13684
+ var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, NOTHING, reachesOf, claimsOf, reaching, claimedBy, claimedRow, claimedRows, linesClaimed, runsOf, tallyOf, changedHunks, coverage, sharedIn, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
13571
13685
  var init_coverage = __esmMin((() => {
13572
13686
  init_dist();
13573
13687
  init_model$3();
@@ -13624,6 +13738,23 @@ var init_coverage = __esmMin((() => {
13624
13738
  return last !== void 0 && last.end >= line;
13625
13739
  };
13626
13740
  claimedBy = (reaches, changed) => changed.some((line) => reaching(reaches, line));
13741
+ claimedRow = (reaches, row) => row.kind !== "context" && match$3(orElse(row.newLine, () => row.oldLine), {
13742
+ onNone: () => false,
13743
+ onSome: (line) => reaching(reaches, line)
13744
+ });
13745
+ claimedRows = (claims, patch) => {
13746
+ const reaches = claims.get(patch.path) ?? NOTHING;
13747
+ if (reaches.length === 0) return [];
13748
+ return patch.hunks.flatMap((hunk) => hunk.rows).filter((row) => claimedRow(reaches, row));
13749
+ };
13750
+ linesClaimed = (patches, layer) => {
13751
+ const claims = claimsOf(spansOf$1([layer]));
13752
+ const rows = patches.flatMap((patch) => claimedRows(claims, patch));
13753
+ return {
13754
+ added: rows.filter((row) => row.kind === "added").length,
13755
+ removed: rows.filter((row) => row.kind === "removed").length
13756
+ };
13757
+ };
13627
13758
  runsOf = (path, lines) => {
13628
13759
  const runs = [];
13629
13760
  for (const line of lines.toSorted((a, b) => a - b)) {
@@ -14191,13 +14322,81 @@ var init_comments$1 = __esmMin((() => {
14191
14322
  });
14192
14323
  }));
14193
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
14194
14391
  //#region src/review/threads.ts
14195
- 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;
14196
14393
  var init_threads$1 = __esmMin((() => {
14197
14394
  init_dist();
14198
14395
  init_store();
14199
14396
  init_error$2();
14200
14397
  init_placing();
14398
+ init_review$1();
14399
+ ASK_LEAD = "About this branch, not about this line.";
14201
14400
  stateOf$2 = (turns, asked, isSettled, isRemoved) => {
14202
14401
  if (isRemoved) return "removed";
14203
14402
  if (isSettled) return "done";
@@ -14222,6 +14421,41 @@ var init_threads$1 = __esmMin((() => {
14222
14421
  at: entry.at,
14223
14422
  ...choicesOf(entry)
14224
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
+ };
14225
14459
  threadOf = (held, replies, conversation) => {
14226
14460
  const { comment, batch } = held;
14227
14461
  const ids = /* @__PURE__ */ new Set([comment.id, ...replies.map((one) => one.comment.id)]);
@@ -14236,6 +14470,15 @@ var init_threads$1 = __esmMin((() => {
14236
14470
  reworded: false
14237
14471
  };
14238
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);
14239
14482
  return {
14240
14483
  id: comment.id,
14241
14484
  file: comment.anchor.path,
@@ -14245,12 +14488,15 @@ var init_threads$1 = __esmMin((() => {
14245
14488
  snippet: comment.anchor.snippet,
14246
14489
  body: comment.body,
14247
14490
  at: batch.at,
14248
- state: stateOf$2(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(conversation.removed, comment.id)),
14491
+ state: facts.state,
14249
14492
  stale: batch.head !== conversation.head,
14250
- outdated: sits.placed && sits.outdated,
14251
- outside: !conversation.shown.has(comment.anchor.path) || !sits.placed,
14252
- unread: Math.max(0, mine.length - seen),
14253
- 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,
14254
14500
  answers: mine.map(answerOf),
14255
14501
  turns,
14256
14502
  settled,
@@ -14434,6 +14680,18 @@ var init_threads$1 = __esmMin((() => {
14434
14680
  }));
14435
14681
  return { settled: ripe.length };
14436
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
+ };
14437
14695
  }));
14438
14696
  //#endregion
14439
14697
  //#region src/service/forge/error.ts
@@ -15140,41 +15398,8 @@ var init_remarks$1 = __esmMin((() => {
15140
15398
  });
15141
15399
  }));
15142
15400
  //#endregion
15143
- //#region src/domain/review/vouch.ts
15144
- var SHORTEST_BLOB, sameBlob, isVouched, vouch$1, partOf, isPartVouched, vouchPart$1;
15145
- var init_vouch = __esmMin((() => {
15146
- SHORTEST_BLOB = 7;
15147
- sameBlob = (left, right) => {
15148
- if (left === void 0 || right === void 0) return false;
15149
- if (left === right) return true;
15150
- if (left.length < SHORTEST_BLOB || right.length < SHORTEST_BLOB) return false;
15151
- return left.startsWith(right) || right.startsWith(left);
15152
- };
15153
- isVouched = (vouches, path, blob) => sameBlob(vouches[path], blob);
15154
- vouch$1 = (vouches, path, blob) => {
15155
- if (isVouched(vouches, path, blob)) {
15156
- const { [path]: _cleared, ...rest } = vouches;
15157
- return rest;
15158
- }
15159
- return {
15160
- ...vouches,
15161
- [path]: blob
15162
- };
15163
- };
15164
- partOf = (path, runs) => {
15165
- return `${path}@${[...runs].toSorted((left, right) => left.start - right.start || left.end - right.end).map((run) => `${run.start}-${run.end}`).join(",")}`;
15166
- };
15167
- isPartVouched = (vouches, part, blob) => sameBlob(vouches[part], blob);
15168
- vouchPart$1 = (vouches, part, blob) => vouch$1(vouches, part, blob);
15169
- }));
15170
- //#endregion
15171
- //#region src/domain/review/index.ts
15172
- var init_review$1 = __esmMin((() => {
15173
- init_vouch();
15174
- }));
15175
- //#endregion
15176
15401
  //#region src/review/vouching.ts
15177
- 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;
15178
15403
  var init_vouching$1 = __esmMin((() => {
15179
15404
  init_dist();
15180
15405
  init_patch();
@@ -15298,7 +15523,39 @@ var init_vouching$1 = __esmMin((() => {
15298
15523
  places: placesIn(found)
15299
15524
  })
15300
15525
  });
15301
- 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) {
15302
15559
  const git = yield* Git;
15303
15560
  const { mark } = asked;
15304
15561
  const told = {
@@ -15313,13 +15570,15 @@ var init_vouching$1 = __esmMin((() => {
15313
15570
  added: 0,
15314
15571
  removed: 0,
15315
15572
  places: 0,
15316
- kept: false
15573
+ kept: false,
15574
+ layers: []
15317
15575
  };
15318
15576
  const patch = yield* diffSince(worktree, mark.path, kept.value, 3);
15319
15577
  return {
15320
15578
  ...told,
15321
15579
  ...counted$1(patch),
15322
- kept: true
15580
+ kept: true,
15581
+ layers: layersTouched(spans, mark.path, patch)
15323
15582
  };
15324
15583
  });
15325
15584
  isGone = fn("Review.Vouch.isGone")(function* (worktree, path) {
@@ -15335,16 +15594,16 @@ var init_vouching$1 = __esmMin((() => {
15335
15594
  mark,
15336
15595
  deleted: patch.status === "deleted"
15337
15596
  })));
15338
- sinceReview = fn("Review.Vouch.sinceReview")(function* (reading, state, changed) {
15597
+ sinceReview = fn("Review.Vouch.sinceReview")(function* (reading, state, changed, spans) {
15339
15598
  const marks = marksOf(state);
15340
15599
  const gone = yield* goneSince(reading.worktree, marks, reading.patches);
15341
15600
  const asked = [...lapsedIn(reading.patches, marks, changed), ...gone.map((mark) => ({
15342
15601
  mark,
15343
15602
  deleted: true
15344
15603
  }))];
15345
- return yield* forEach(asked, (one) => reportSince(reading.worktree, one), { concurrency: 8 });
15604
+ return yield* forEach(asked, (one) => reportSince(reading.worktree, one, spans), { concurrency: 8 });
15346
15605
  });
15347
- progress = fn("Review.Vouch.progress")(function* (reading) {
15606
+ progress = fn("Review.Vouch.progress")(function* (reading, spans = []) {
15348
15607
  const current = yield* (yield* Store).state(reading.worktree.path);
15349
15608
  const files = reading.patches.map((patch) => ({
15350
15609
  path: patch.path,
@@ -15353,9 +15612,9 @@ var init_vouching$1 = __esmMin((() => {
15353
15612
  const changed = changedSince([current.vouches, current.parts], files);
15354
15613
  return {
15355
15614
  vouched: files.filter((file) => isVouched(current.vouches, file.path, file.blob)).map((f) => f.path),
15356
- parts: readParts(current.parts, files),
15615
+ parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current.vouches, spans)],
15357
15616
  changed,
15358
- since: yield* sinceReview(reading, current, changed),
15617
+ since: yield* sinceReview(reading, current, changed, spans),
15359
15618
  total: reading.patches.length
15360
15619
  };
15361
15620
  });
@@ -15533,7 +15792,7 @@ var init_preferences = __esmMin((() => {
15533
15792
  }));
15534
15793
  //#endregion
15535
15794
  //#region src/review/layers.ts
15536
- 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;
15537
15796
  var init_layers = __esmMin((() => {
15538
15797
  init_dist();
15539
15798
  init_layers$1();
@@ -15541,6 +15800,7 @@ var init_layers = __esmMin((() => {
15541
15800
  init_review$1();
15542
15801
  init_error$2();
15543
15802
  init_comments$1();
15803
+ init_threads$1();
15544
15804
  init_branches$1();
15545
15805
  init_vouching$1();
15546
15806
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
@@ -15642,20 +15902,27 @@ var init_layers = __esmMin((() => {
15642
15902
  ...layers,
15643
15903
  parent: getOrUndefined$1(layers.parent)
15644
15904
  });
15905
+ partIn = (patches, layer, path) => Object.assign({ path }, linesClaimed(patches.filter((patch) => patch.path === path), layer));
15645
15906
  reportedLayers = (patches, layers) => {
15646
15907
  const present = new Set(patches.map((patch) => patch.path));
15647
- return withFullCoverage(patches, layers).layers.map((layer) => {
15908
+ return withFullCoverage(patches, layers).layers.map((layer, at) => {
15648
15909
  const named = unique(spansOfLayer(layer).map((span) => span.path));
15649
15910
  const gap = coverage(patches, [layer]);
15911
+ const lines = linesClaimed(patches, layer);
15912
+ const files = named.filter((path) => present.has(path));
15650
15913
  return {
15651
15914
  title: layer.title,
15652
15915
  note: noteOf(layer),
15653
- files: named.filter((path) => present.has(path)),
15916
+ files,
15654
15917
  spans: spansOfLayer(layer),
15655
15918
  prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path)),
15656
15919
  covered: gap.covered,
15657
15920
  partial: gap.partial,
15658
- vanished: named.filter((path) => !present.has(path))
15921
+ added: lines.added,
15922
+ removed: lines.removed,
15923
+ vanished: named.filter((path) => !present.has(path)),
15924
+ unclaimed: at >= layers.layers.length,
15925
+ parts: files.map((path) => partIn(patches, layer, path))
15659
15926
  };
15660
15927
  });
15661
15928
  };
@@ -15711,29 +15978,131 @@ var init_layers = __esmMin((() => {
15711
15978
  });
15712
15979
  withRead = (report, reading) => ({
15713
15980
  ...report,
15714
- layers: report.layers.map((layer) => ({
15715
- ...layer,
15716
- read: readInLayer(layer, reading)
15717
- }))
15981
+ layers: report.layers.map((layer) => {
15982
+ const read = readInLayer(layer, reading);
15983
+ return Object.assign({}, layer, {
15984
+ read,
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
+ }))
15990
+ });
15991
+ })
15718
15992
  });
15719
- show$1 = fn("Review.Layers.show")(function* (worktree) {
15720
- const store = yield* Store;
15721
- const patches$2 = yield* patches(worktree);
15722
- const found = yield* storedLayers(worktree);
15723
- const layers = yield* match$3(found, {
15724
- onNone: () => new NoLayers({ worktree: worktree.path }),
15725
- 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)
15726
16008
  });
15727
- const current = yield* store.state(worktree.path);
15728
- 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) => ({
15729
16033
  path: patch.path,
15730
16034
  blob: patch.blob
15731
16035
  }));
15732
- return withRead(reportOf(patches$2, layers, worktree.head), {
15733
- 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,
15734
16040
  vouches: current.vouches,
15735
- 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
16057
+ });
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)
15736
16100
  });
16101
+ if (spans.length === 0) return shown;
16102
+ return {
16103
+ ...shown,
16104
+ files: shown.files.map((file) => taggedFile(spans, file))
16105
+ };
15737
16106
  });
15738
16107
  read = fn("Review.Layers.read")(function* (reading) {
15739
16108
  const worktree = reading.worktree;
@@ -15788,7 +16157,6 @@ var init_layers = __esmMin((() => {
15788
16157
  total: reading.patches.length
15789
16158
  };
15790
16159
  });
15791
- ASK_LEAD = "About this branch, not about this line.";
15792
16160
  askingFor = (told) => {
15793
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.`;
15794
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\`.`;
@@ -17764,6 +18132,7 @@ var init_match = __esmMin((() => {
17764
18132
  var HOLDS$1, chosenNow, withChosen, EDITOR_ROW, editorRow, preferenceRows, nothingReviewed, nothingFound, initialState, selectedBranch, selectedPatch, pullHere, authorHere, theirPull, heldWhere, noteEditing, hasNoPull, onLayers, selectedLayer, movedPast;
17765
18133
  var init_state = __esmMin((() => {
17766
18134
  init_preferences$1();
18135
+ init_review$1();
17767
18136
  init_gaps();
17768
18137
  HOLDS$1 = {
17769
18138
  wrap: "wrap",
@@ -17909,7 +18278,11 @@ var init_state = __esmMin((() => {
17909
18278
  hasNoPull = (state) => state.forge === "answered" && pullHere(state).length === 0;
17910
18279
  onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
17911
18280
  selectedLayer = (state) => state.layers[state.layerIndex];
17912
- 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
+ });
17913
18286
  }));
17914
18287
  //#endregion
17915
18288
  //#region src/tui/cursor.ts
@@ -17996,6 +18369,7 @@ var init_cursor = __esmMin((() => {
17996
18369
  //#region src/tui/tree.ts
17997
18370
  var add, directoryOf, compare, buildTree, chain, visit, flattenTree, directFiles, filesUnder, crowdedDirectories;
17998
18371
  var init_tree = __esmMin((() => {
18372
+ init_patch();
17999
18373
  add = (tree, input) => {
18000
18374
  const id = tree.nodes.length;
18001
18375
  tree.nodes.push({
@@ -18035,8 +18409,7 @@ var init_tree = __esmMin((() => {
18035
18409
  const a = tree.nodes[left];
18036
18410
  const b = tree.nodes[right];
18037
18411
  if (a === void 0 || b === void 0) return 0;
18038
- if (a.kind !== b.kind) return a.kind === "directory" ? -1 : 1;
18039
- return a.name.localeCompare(b.name);
18412
+ return compareEntries(a, b);
18040
18413
  };
18041
18414
  buildTree = (paths) => {
18042
18415
  const tree = {
@@ -18359,7 +18732,7 @@ var init_words = __esmMin((() => {
18359
18732
  return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
18360
18733
  };
18361
18734
  clip = (label, room) => label.length > room ? `${label.slice(0, Math.max(0, room - 1))}…` : label;
18362
- })), proseFor, layerHolding, layerOpen, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, NOTHING_LEFT, textRows, emptyRows, layerBody, holdsCursor, layerCard, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
18735
+ })), proseFor, layerHolding, layerOpen, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, NOTHING_LEFT, textRows, linesSaid, countRow, emptyRows, layerBody, holdsCursor, layerCard, layerRows, nearFirst, layerFitted, restingAt, railTop, PANE_CHROME, layerRoomIn, railWindow, layerContext;
18363
18736
  var init_layerview = __esmMin((() => {
18364
18737
  init_files();
18365
18738
  init_layout();
@@ -18445,18 +18818,6 @@ var init_layerview = __esmMin((() => {
18445
18818
  const read = layerRead(state, layerIndex);
18446
18819
  return read.all > 0 && read.done === read.all;
18447
18820
  };
18448
- countRow = (state, index, room) => {
18449
- const read = layerRead(state, index);
18450
- if (read.all === 0) return [];
18451
- const one = read.all === 1 ? "file" : "files";
18452
- const said = `${read.done} of ${read.all} ${one} read`;
18453
- return [{
18454
- index,
18455
- kind: "count",
18456
- text: clip(said, room),
18457
- lead: false
18458
- }];
18459
- };
18460
18821
  NOTHING_LEFT = "nothing in this diff";
18461
18822
  textRows = (index, text, room, kind) => wrapped(text, room).map((line) => ({
18462
18823
  index,
@@ -18464,6 +18825,18 @@ var init_layerview = __esmMin((() => {
18464
18825
  text: line,
18465
18826
  lead: false
18466
18827
  }));
18828
+ linesSaid = (layer) => {
18829
+ if (layer === void 0) return "";
18830
+ const signs = [...layer.added > 0 ? [`+${layer.added}`] : [], ...layer.removed > 0 ? [`−${layer.removed}`] : []];
18831
+ return signs.length === 0 ? "" : ` · ${signs.join(" ")}`;
18832
+ };
18833
+ countRow = (state, index, room) => {
18834
+ const read = layerRead(state, index);
18835
+ if (read.all === 0) return [];
18836
+ const one = read.all === 1 ? "file" : "files";
18837
+ const said = `${read.done} of ${read.all} ${one} read${linesSaid(state.layers[index])}`;
18838
+ return textRows(index, said, room, "count");
18839
+ };
18467
18840
  emptyRows = (state, index, room) => {
18468
18841
  const layer = state.layers[index];
18469
18842
  if (layer === void 0) return [];
@@ -18544,9 +18917,10 @@ var init_layerview = __esmMin((() => {
18544
18917
  }));
18545
18918
  //#endregion
18546
18919
  //#region src/tui/panel.ts
18547
- 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;
18548
18921
  var init_panel = __esmMin((() => {
18549
18922
  init_state();
18923
+ init_review$1();
18550
18924
  PANEL_SECTIONS = [
18551
18925
  "remarks",
18552
18926
  "held",
@@ -18567,16 +18941,7 @@ var init_panel = __esmMin((() => {
18567
18941
  return answersIn(later) > answersIn(comment) ? later : comment;
18568
18942
  };
18569
18943
  lastVoice = (comment) => comment.turns?.at(-1)?.voice;
18570
- SECTION_OF = {
18571
- filed: "filed",
18572
- gone: "removed",
18573
- settled: "settled",
18574
- asked: "asked",
18575
- answered: "answered",
18576
- waiting: "with"
18577
- };
18578
- outsideOpen = (comment) => movedPast(comment) && comment.settled !== true && comment.removed !== true;
18579
- sectionOf = (comment) => outsideOpen(comment) ? "movedOn" : SECTION_OF[threadStand(comment)];
18944
+ sectionOf = (comment) => sectionOf$1(threadStand(comment), movedPast(comment));
18580
18945
  sentEntry = (state, comment) => {
18581
18946
  const newer = newerOf(state, comment);
18582
18947
  return {
@@ -18641,22 +19006,13 @@ var init_panel = __esmMin((() => {
18641
19006
  if (gap < 864e5) return `${Math.floor(gap / HOUR)}h ago`;
18642
19007
  return `${Math.floor(gap / DAY)}d ago`;
18643
19008
  };
18644
- threadStand = (thread) => {
18645
- if (thread.removed === true) return "gone";
18646
- if (thread.settled === true) return "settled";
18647
- if (thread.asks === true) return "asked";
18648
- if (lastVoice(thread) === "agent" && answersIn(thread) > 0) return "answered";
18649
- return thread.takenAt === void 0 ? "filed" : "waiting";
18650
- };
18651
- STAND_WEIGHT = {
18652
- gone: 0,
18653
- settled: 1,
18654
- filed: 2,
18655
- waiting: 2,
18656
- answered: 3,
18657
- asked: 4
18658
- };
18659
- 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
+ });
18660
19016
  }));
18661
19017
  //#endregion
18662
19018
  //#region src/tui/notes.ts
@@ -23723,7 +24079,7 @@ var init_branches = __esmMin((() => {
23723
24079
  app.reading = reading$1;
23724
24080
  yield* markOpened(reading$1.worktree, (/* @__PURE__ */ new Date()).toISOString());
23725
24081
  const [progress$2, layers, sent, remarks, drafts] = yield* all([
23726
- progress(reading$1),
24082
+ flatMap(spansIn(reading$1), (spans) => progress(reading$1, spans)),
23727
24083
  read(reading$1),
23728
24084
  listSent(reading$1),
23729
24085
  app.state.remarksOn ? list$2(reading$1) : succeed$1([]),
@@ -23895,7 +24251,7 @@ var init_branches = __esmMin((() => {
23895
24251
  const branch = selectedBranch(app.state);
23896
24252
  if (branch === void 0) return;
23897
24253
  const reading = yield* readingOf(app, branch.branch);
23898
- 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))]);
23899
24255
  if (sameSent(app.state.sent, sent) && sameMarks(app.state, progress$1)) return;
23900
24256
  app.commit(withVouched({
23901
24257
  ...app.state,
@@ -25997,13 +26353,25 @@ const baseClear = fn("Main.baseClear")(function* (options) {
25997
26353
  const report = yield* clearBase(yield* required(options, "repo"), yield* worktreeIn(options));
25998
26354
  yield* answer(options, { base: report });
25999
26355
  });
26000
- const commentSend = fn("Main.commentSend")(function* (options) {
26001
- const batch = yield* submit(yield* worktreeIn(options), {
26002
- 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,
26003
26365
  start: yield* numeric(options, "start"),
26004
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),
26005
26374
  body: yield* required(options, "body"),
26006
- side: yield* oneOf(options, "side", ["old", "new"], "new"),
26007
26375
  id: options["id"] ?? randomUUID(),
26008
26376
  at: stamp(options)
26009
26377
  });
@@ -26014,12 +26382,10 @@ const draftList = fn("Main.draftList")(function* (options) {
26014
26382
  yield* answer(options, { drafts });
26015
26383
  });
26016
26384
  const draftAdd = fn("Main.draftAdd")(function* (options) {
26017
- const draft = yield* add$1(yield* worktreeIn(options), {
26018
- file: yield* required(options, "file"),
26019
- start: yield* numeric(options, "start"),
26020
- end: yield* numeric(options, "end"),
26385
+ const worktree = yield* worktreeIn(options);
26386
+ const draft = yield* add$1(worktree, {
26387
+ ...yield* rangeIn(options, worktree),
26021
26388
  body: yield* required(options, "body"),
26022
- side: yield* oneOf(options, "side", ["old", "new"], "new"),
26023
26389
  id: options["id"] ?? randomUUID(),
26024
26390
  at: stamp(options),
26025
26391
  wroteBy: "agent"
@@ -26109,8 +26475,12 @@ const remarkRestore = fn("Main.remarkRestore")(function* (options) {
26109
26475
  yield* answer(options, { restored: report.restored });
26110
26476
  });
26111
26477
  const commentList = fn("Main.commentList")(function* (options) {
26112
- const comments = yield* list$3(yield* readingIn(options));
26113
- 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
+ });
26114
26484
  });
26115
26485
  const resolveRead = fn("Main.resolveRead")(function* (options) {
26116
26486
  const report = yield* settleRead(yield* worktreeIn(options), stamp(options));
@@ -26182,13 +26552,19 @@ const vouched = fn("Main.vouched")(function* (options) {
26182
26552
  });
26183
26553
  const fileReview = fn("Main.fileReview")(function* (options) {
26184
26554
  const report = yield* vouched(options);
26555
+ const layers = yield* view(yield* readingIn(options));
26185
26556
  yield* answer(options, {
26186
26557
  reviewed: report.vouched,
26187
- total: report.total
26558
+ total: report.total,
26559
+ ...match$3(layers, {
26560
+ onNone: () => ({}),
26561
+ onSome: (found) => ({ layers: found })
26562
+ })
26188
26563
  });
26189
26564
  });
26190
26565
  const reviewStatus = fn("Main.reviewStatus")(function* (options) {
26191
- const report = yield* progress(yield* readingIn(options));
26566
+ const reading = yield* readingIn(options);
26567
+ const report = yield* progress(reading, yield* spansIn(reading));
26192
26568
  yield* answer(options, {
26193
26569
  reviewed: report.vouched,
26194
26570
  changed: report.changed,
@@ -26213,15 +26589,17 @@ const layersShow = fn("Main.layersShow")(function* (options) {
26213
26589
  });
26214
26590
  const patchShow = fn("Main.patchShow")(function* (options) {
26215
26591
  const based = yield* basedAt(yield* required(options, "worktree"), options["base"]);
26216
- const patch = yield* show$3(based, {
26592
+ const shown = yield* show$3(based, {
26217
26593
  file: options["file"],
26218
26594
  context: yield* around$1(options, "context")
26219
26595
  });
26596
+ const patch = yield* tagRows(based.worktree, shown);
26220
26597
  yield* answer(options, { patch });
26221
26598
  });
26222
26599
  const patchSince = fn("Main.patchSince")(function* (options) {
26223
26600
  const based = yield* basedAt(yield* required(options, "worktree"), options["base"]);
26224
- 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);
26225
26603
  yield* answer(options, { file });
26226
26604
  });
26227
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.196",
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": {
@@ -301,12 +301,15 @@ Rules that make a layers worth reading:
301
301
  The answer to `layers set` is the honest report — check it before you claim to be done:
302
302
 
303
303
  ```json
304
- {"ok":true,"layers":{"version":1,"stale":false,"covered":7,"partial":1,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"layers":[{"title":"Add the invitation data model","files":["src/db/invites.ts"],"covered":1,"partial":0,"vanished":[]}]}}
304
+ {"ok":true,"layers":{"version":1,"stale":false,"covered":7,"partial":1,"total":9,"uncovered":[{"path":"src/api/router.ts","start":40,"end":52}],"vanished":[],"layers":[{"title":"Add the invitation data model","files":["src/db/invites.ts"],"covered":1,"partial":0,"added":42,"removed":3,"vanished":[]}]}}
305
305
 
306
306
  `covered`, `partial` and `vanished` appear per layer as well as for the document, so you can tell
307
307
  which of your own layers is the thin one. `vanished` on a layer names paths it claims that are not
308
308
  in the diff — usually a typo or a file that moved.
309
309
 
310
+ `added` and `removed` on a layer count the changed lines inside its own spans, a removed line by its
311
+ old line number. A line two layers both claim counts in each.
312
+
310
313
  `layers set` refuses a document it cannot use and says which layer is wrong and why: a span that
311
314
  ends before it starts, a span starting below line 1, a start or end that is not a whole number, a
312
315
  block with no `kind`, a layer with no title. It no longer drops a bad span quietly, so a layer that