@eliya-oss/agent-diff 0.1.0-alpha.170 → 0.1.0-alpha.172

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,36 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.172
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(diff): a comment is written in the diff, under the line it is about, instead of in a box over it.
8
+
9
+ <details><summary>What moved</summary>
10
+
11
+ The draft opens under the last line of the selection and the code below it moves down, the way a
12
+ thread already sits under its line; a reply opens under the thread it answers. The quoted snippet is
13
+ gone, because the code is on the screen above. `ctrl+s` sends and `escape` cancels, as before. On a
14
+ pane too short to hold the draft, and where the diff cannot show the line, the draft opens over the
15
+ diff as it did before.
16
+
17
+ </details>
18
+
19
+ ## 0.1.0-alpha.171
20
+
21
+ ### Patch Changes
22
+
23
+ - feat(comment delivery): a comment on code a layer explains tells the agent which layer it will have to rewrite.
24
+
25
+ <details><summary>Why the agent is told</summary>
26
+
27
+ The work a comment asks for moves the code its layer describes, so the layers go stale as soon as
28
+ the agent acts. `comment take` now carries `layer`, the title of the layer whose spans cover the
29
+ comment's lines, read from the reading order as it stands when the comment is handed over. Where two
30
+ layers claim the line the tighter span wins, and code no layer claims carries none.
31
+
32
+ </details>
33
+
3
34
  ## 0.1.0-alpha.170
4
35
 
5
36
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10500,9 +10500,169 @@ var init_review = __esmMin((() => {
10500
10500
  init_vouch();
10501
10501
  }));
10502
10502
  //#endregion
10503
+ //#region src/domain/layers/model.ts
10504
+ var REMAINDER_TITLE;
10505
+ var init_model$4 = __esmMin((() => {
10506
+ REMAINDER_TITLE = "not in any layer";
10507
+ }));
10508
+ //#endregion
10509
+ //#region src/domain/layers/coverage.ts
10510
+ var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
10511
+ var init_coverage = __esmMin((() => {
10512
+ init_dist();
10513
+ init_model$4();
10514
+ codeBlockOf$1 = (span) => ({
10515
+ kind: "code",
10516
+ path: span.path,
10517
+ start: span.start,
10518
+ end: span.end
10519
+ });
10520
+ codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
10521
+ noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
10522
+ spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
10523
+ path,
10524
+ start,
10525
+ end
10526
+ })));
10527
+ changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
10528
+ onNone: () => [],
10529
+ onSome: (line) => [line]
10530
+ }));
10531
+ holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
10532
+ claimsHunk = (spans, path, hunk) => changedLines(hunk).some((line) => spans.some((span) => holds(span, path, line)));
10533
+ runsOf = (path, lines) => {
10534
+ const runs = [];
10535
+ for (const line of lines.toSorted((a, b) => a - b)) {
10536
+ const open = runs.at(-1);
10537
+ if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
10538
+ else runs.push({
10539
+ path,
10540
+ start: line,
10541
+ end: line
10542
+ });
10543
+ }
10544
+ return runs;
10545
+ };
10546
+ tallyOf = (patch, hunk, claimed) => {
10547
+ const changed = changedLines(hunk);
10548
+ const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
10549
+ const whole = changed.length > 0 && loose.length === 0;
10550
+ const some = loose.length > 0 && loose.length < changed.length;
10551
+ return {
10552
+ covered: whole ? 1 : 0,
10553
+ partial: some ? 1 : 0,
10554
+ missing: runsOf(patch.path, loose)
10555
+ };
10556
+ };
10557
+ coverage = (patches, layers) => {
10558
+ const claimed = spansOf$1(layers);
10559
+ const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
10560
+ return {
10561
+ total: tallies.length,
10562
+ covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
10563
+ partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
10564
+ missing: tallies.flatMap((tally) => tally.missing)
10565
+ };
10566
+ };
10567
+ sharedHunks = (patches, layers) => {
10568
+ const claiming = (patch, hunk) => layers.filter((layer) => claimsHunk(spansOf$1([layer]), patch.path, hunk)).length;
10569
+ return patches.reduce((sum, patch) => sum + patch.hunks.filter((hunk) => changedLines(hunk).length > 0 && claiming(patch, hunk) > 1).length, 0);
10570
+ };
10571
+ runsSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
10572
+ filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
10573
+ leftSaid = (runs, files) => {
10574
+ if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
10575
+ if (runs > 0) return runsSaid(runs);
10576
+ return files > 0 ? filesSaid(files) : "";
10577
+ };
10578
+ unordered = (patches, layers, missing) => {
10579
+ const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
10580
+ return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
10581
+ path: patch.path,
10582
+ start: 1,
10583
+ end: 1
10584
+ }));
10585
+ };
10586
+ withFullCoverage = (patches, layers) => {
10587
+ const gap = coverage(patches, layers.layers);
10588
+ const left = unordered(patches, layers.layers, gap.missing);
10589
+ const spans = [...gap.missing, ...left];
10590
+ if (spans.length === 0) return layers;
10591
+ const said = leftSaid(gap.missing.length, left.length);
10592
+ const remainder = {
10593
+ title: REMAINDER_TITLE,
10594
+ blocks: [...said.length === 0 ? [] : [{
10595
+ kind: "prose",
10596
+ markdown: said
10597
+ }], ...spans.map((span) => codeBlockOf$1(span))]
10598
+ };
10599
+ return {
10600
+ ...layers,
10601
+ layers: [...layers.layers, remainder]
10602
+ };
10603
+ };
10604
+ proseAnchors = (layer) => {
10605
+ const anchors = [];
10606
+ let pending = [];
10607
+ let last;
10608
+ for (const block of layer.blocks) {
10609
+ if (block.kind === "prose") {
10610
+ const markdown = block.markdown.trim();
10611
+ if (markdown.length > 0) pending.push(markdown);
10612
+ continue;
10613
+ }
10614
+ for (const markdown of pending) anchors.push({
10615
+ path: block.path,
10616
+ line: block.start,
10617
+ markdown,
10618
+ after: false
10619
+ });
10620
+ pending = [];
10621
+ last = block;
10622
+ }
10623
+ if (last === void 0) return anchors;
10624
+ return [...anchors, ...pending.map((markdown) => ({
10625
+ path: last.path,
10626
+ line: last.end,
10627
+ markdown,
10628
+ after: true
10629
+ }))];
10630
+ };
10631
+ }));
10632
+ //#endregion
10633
+ //#region src/domain/layers/version.ts
10634
+ var statusOf$1;
10635
+ var init_version = __esmMin((() => {
10636
+ init_coverage();
10637
+ statusOf$1 = (patches, layers, branchHead) => {
10638
+ const gap = coverage(patches, layers.layers);
10639
+ const present = new Set(patches.map((patch) => patch.path));
10640
+ const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
10641
+ return {
10642
+ version: layers.version,
10643
+ parent: layers.parent,
10644
+ stale: layers.head !== branchHead,
10645
+ layersHead: layers.head,
10646
+ branchHead,
10647
+ uncovered: gap.missing,
10648
+ vanished: [...mentioned].filter((path) => !present.has(path)),
10649
+ covered: gap.covered,
10650
+ partial: gap.partial,
10651
+ total: gap.total
10652
+ };
10653
+ };
10654
+ }));
10655
+ //#endregion
10656
+ //#region src/domain/layers/index.ts
10657
+ var init_layers$1 = __esmMin((() => {
10658
+ init_coverage();
10659
+ init_version();
10660
+ init_model$4();
10661
+ }));
10662
+ //#endregion
10503
10663
  //#region src/domain/preferences/model.ts
10504
10664
  var preferences, preferenceNames, preferenceNamed, asFlag, heldValue, heldValues;
10505
- var init_model$4 = __esmMin((() => {
10665
+ var init_model$3 = __esmMin((() => {
10506
10666
  preferences = [
10507
10667
  {
10508
10668
  name: "wrap",
@@ -10562,7 +10722,7 @@ var init_model$4 = __esmMin((() => {
10562
10722
  //#endregion
10563
10723
  //#region src/domain/preferences/index.ts
10564
10724
  var init_preferences = __esmMin((() => {
10565
- init_model$4();
10725
+ init_model$3();
10566
10726
  })), UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownRemark, NothingSaid, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, UnknownField, UnknownOption, BadOption, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers;
10567
10727
  var init_error = __esmMin((() => {
10568
10728
  init_dist();
@@ -10592,12 +10752,13 @@ var init_error = __esmMin((() => {
10592
10752
  }));
10593
10753
  //#endregion
10594
10754
  //#region src/cli/commands.ts
10595
- var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, forOne, recentBases, setBase, clearBase, markRead;
10755
+ var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, layerOver, layersOn, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, forOne, recentBases, setBase, clearBase, markRead;
10596
10756
  var init_commands = __esmMin((() => {
10597
10757
  init_dist();
10598
10758
  init_patch();
10599
10759
  init_git();
10600
10760
  init_review();
10761
+ init_layers$1();
10601
10762
  init_store();
10602
10763
  init_preferences();
10603
10764
  init_error();
@@ -11041,17 +11202,36 @@ var init_commands = __esmMin((() => {
11041
11202
  body: turn.body
11042
11203
  }));
11043
11204
  };
11205
+ layerOver = (layers, comment) => {
11206
+ return layers.flatMap((layer) => codeBlocks(layer).filter((block) => block.path === comment.file && comment.start <= block.end && comment.end >= block.start).map((block) => ({
11207
+ title: layer.title,
11208
+ room: block.end - block.start
11209
+ }))).reduce((tightest, one) => tightest === void 0 || one.room < tightest.room ? one : tightest, void 0)?.title;
11210
+ };
11211
+ layersOn = fn("Cli.layersOn")(function* (worktree) {
11212
+ const found = yield* (yield* Store).layers(worktree);
11213
+ return match$3(found, {
11214
+ onNone: () => [],
11215
+ onSome: (held) => held.layers
11216
+ });
11217
+ });
11044
11218
  takeComments = fn("Cli.takeComments")(function* (worktree) {
11045
11219
  const store = yield* Store;
11046
11220
  const resolved = yield* realOf(worktree);
11047
11221
  const at = (/* @__PURE__ */ new Date()).toISOString();
11048
11222
  yield* ignore(store.noteWatching(resolved, at));
11049
11223
  const owed = flatten(yield* store.take(resolved, at));
11050
- if (owed.every((one) => one.replyTo === void 0)) return owed;
11224
+ if (owed.length === 0) return owed;
11225
+ const layers = yield* layersOn(resolved);
11226
+ const under = (one) => {
11227
+ const title = layerOver(layers, one);
11228
+ return title === void 0 ? one : Object.assign({}, one, { layer: title });
11229
+ };
11230
+ if (owed.every((one) => one.replyTo === void 0)) return owed.map(under);
11051
11231
  const held = flatten(yield* store.inbox(resolved));
11052
11232
  const spoken = yield* store.answers(resolved);
11053
11233
  const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
11054
- return owed.map(carried);
11234
+ return owed.map(carried).map(under);
11055
11235
  });
11056
11236
  repoOf$1 = fn("Cli.repoOf")(function* (worktree) {
11057
11237
  return yield* (yield* Git).repoOf(worktree);
@@ -11421,10 +11601,10 @@ var init_pane = __esmMin((() => {
11421
11601
  //#region package.json
11422
11602
  init_drafts();
11423
11603
  init_pane();
11424
- var version$1 = "0.1.0-alpha.170";
11604
+ var version$1 = "0.1.0-alpha.172";
11425
11605
  //#endregion
11426
11606
  //#region src/cli/upgrade.ts
11427
- var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
11607
+ var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
11428
11608
  var init_upgrade$1 = __esmMin((() => {
11429
11609
  init_dist();
11430
11610
  PACKAGE = "@eliya-oss/agent-diff";
@@ -11560,16 +11740,16 @@ var init_upgrade$1 = __esmMin((() => {
11560
11740
  "inherit"
11561
11741
  ]
11562
11742
  }, (code) => code === 0, false).pipe(withSpan("Cli.runUpgrade"));
11563
- statusOf$1 = (found) => {
11743
+ statusOf = (found) => {
11564
11744
  if (!found.checked) return `adiff ${found.version} is installed. The registry did not answer.`;
11565
11745
  if (found.current === true) return `adiff ${found.version} is the newest build.`;
11566
11746
  return `adiff ${found.version} is installed, ${found.latest} is out.`;
11567
11747
  };
11568
11748
  sayFound = (found, check) => {
11569
- if (found.current === true) return statusOf$1(found);
11570
- if (willUpgrade(found, check)) return found.checked ? `$ ${found.command}` : `${statusOf$1(found)}\n$ ${found.command}`;
11749
+ if (found.current === true) return statusOf(found);
11750
+ if (willUpgrade(found, check)) return found.checked ? `$ ${found.command}` : `${statusOf(found)}\n$ ${found.command}`;
11571
11751
  const offer = RUNNABLE.has(found.route) ? `Run \`adiff upgrade\`, or \`${found.command}\` yourself.` : `Run: ${found.command}`;
11572
- return `${statusOf$1(found)} ${NOTES[found.route]} ${offer}`;
11752
+ return `${statusOf(found)} ${NOTES[found.route]} ${offer}`;
11573
11753
  };
11574
11754
  sayDone = (found, ran) => {
11575
11755
  if (!ran) return `That did not work. Run \`${found.command}\` yourself to see what it said.`;
@@ -11583,7 +11763,7 @@ var init_upgrade$1 = __esmMin((() => {
11583
11763
  };
11584
11764
  SAY_SKILL_TOO = "Run `npx skills update adiff` to bring the skill up with it.";
11585
11765
  upgradeReport = (found, ran, check) => {
11586
- const note = found.current === true ? statusOf$1(found) : willUpgrade(found, check) ? `${statusOf$1(found)} ${attempted(found, ran)}` : `${statusOf$1(found)} ${NOTES[found.route]} Run \`${found.command}\` to upgrade.`;
11766
+ const note = found.current === true ? statusOf(found) : willUpgrade(found, check) ? `${statusOf(found)} ${attempted(found, ran)}` : `${statusOf(found)} ${NOTES[found.route]} Run \`${found.command}\` to upgrade.`;
11587
11767
  return {
11588
11768
  ...found,
11589
11769
  ran,
@@ -11591,7 +11771,7 @@ var init_upgrade$1 = __esmMin((() => {
11591
11771
  };
11592
11772
  };
11593
11773
  })), DATA_ENDS, DATA_NAMES, DATA_STARTS, DATA_PARTS, TEST_PARTS, TEST_ENDS, partsOf, nameOf$1, isData, isTest, tierOf, KEYWORDS, escaped, BORROWS, declaresIn, bandOf, TIERS, BANDS, rankOf, inFile, byRank, byFile, countedIn, ranked;
11594
- var init_model$3 = __esmMin((() => {
11774
+ var init_model$2 = __esmMin((() => {
11595
11775
  DATA_ENDS = [
11596
11776
  ".txt",
11597
11777
  ".csv",
@@ -11755,7 +11935,7 @@ var init_model$3 = __esmMin((() => {
11755
11935
  //#endregion
11756
11936
  //#region src/domain/search/index.ts
11757
11937
  var init_search$1 = __esmMin((() => {
11758
- init_model$3();
11938
+ init_model$2();
11759
11939
  }));
11760
11940
  //#endregion
11761
11941
  //#region src/cli/search.ts
@@ -11820,166 +12000,6 @@ var init_search = __esmMin((() => {
11820
12000
  });
11821
12001
  }));
11822
12002
  //#endregion
11823
- //#region src/domain/layers/model.ts
11824
- var REMAINDER_TITLE;
11825
- var init_model$2 = __esmMin((() => {
11826
- REMAINDER_TITLE = "not in any layer";
11827
- }));
11828
- //#endregion
11829
- //#region src/domain/layers/coverage.ts
11830
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
11831
- var init_coverage = __esmMin((() => {
11832
- init_dist();
11833
- init_model$2();
11834
- codeBlockOf$1 = (span) => ({
11835
- kind: "code",
11836
- path: span.path,
11837
- start: span.start,
11838
- end: span.end
11839
- });
11840
- codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
11841
- noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
11842
- spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
11843
- path,
11844
- start,
11845
- end
11846
- })));
11847
- changedLines = (hunk) => hunk.rows.filter((row) => row.kind !== "context").flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
11848
- onNone: () => [],
11849
- onSome: (line) => [line]
11850
- }));
11851
- holds = (span, path, line) => span.path === path && span.start <= line && span.end >= line;
11852
- claimsHunk = (spans, path, hunk) => changedLines(hunk).some((line) => spans.some((span) => holds(span, path, line)));
11853
- runsOf = (path, lines) => {
11854
- const runs = [];
11855
- for (const line of lines.toSorted((a, b) => a - b)) {
11856
- const open = runs.at(-1);
11857
- if (open !== void 0 && line <= open.end + 1) open.end = Math.max(open.end, line);
11858
- else runs.push({
11859
- path,
11860
- start: line,
11861
- end: line
11862
- });
11863
- }
11864
- return runs;
11865
- };
11866
- tallyOf = (patch, hunk, claimed) => {
11867
- const changed = changedLines(hunk);
11868
- const loose = changed.filter((line) => !claimed.some((span) => holds(span, patch.path, line)));
11869
- const whole = changed.length > 0 && loose.length === 0;
11870
- const some = loose.length > 0 && loose.length < changed.length;
11871
- return {
11872
- covered: whole ? 1 : 0,
11873
- partial: some ? 1 : 0,
11874
- missing: runsOf(patch.path, loose)
11875
- };
11876
- };
11877
- coverage = (patches, layers) => {
11878
- const claimed = spansOf$1(layers);
11879
- const tallies = patches.flatMap((patch) => patch.hunks.filter((hunk) => changedLines(hunk).length > 0).map((hunk) => tallyOf(patch, hunk, claimed)));
11880
- return {
11881
- total: tallies.length,
11882
- covered: tallies.reduce((sum, tally) => sum + tally.covered, 0),
11883
- partial: tallies.reduce((sum, tally) => sum + tally.partial, 0),
11884
- missing: tallies.flatMap((tally) => tally.missing)
11885
- };
11886
- };
11887
- sharedHunks = (patches, layers) => {
11888
- const claiming = (patch, hunk) => layers.filter((layer) => claimsHunk(spansOf$1([layer]), patch.path, hunk)).length;
11889
- return patches.reduce((sum, patch) => sum + patch.hunks.filter((hunk) => changedLines(hunk).length > 0 && claiming(patch, hunk) > 1).length, 0);
11890
- };
11891
- runsSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
11892
- filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
11893
- leftSaid = (runs, files) => {
11894
- if (runs > 0 && files > 0) return `${runsSaid(runs)} ${filesSaid(files)}`;
11895
- if (runs > 0) return runsSaid(runs);
11896
- return files > 0 ? filesSaid(files) : "";
11897
- };
11898
- unordered = (patches, layers, missing) => {
11899
- const named = /* @__PURE__ */ new Set([...spansOf$1(layers).map((span) => span.path), ...missing.map((span) => span.path)]);
11900
- return patches.filter((patch) => !named.has(patch.path)).map((patch) => ({
11901
- path: patch.path,
11902
- start: 1,
11903
- end: 1
11904
- }));
11905
- };
11906
- withFullCoverage = (patches, layers) => {
11907
- const gap = coverage(patches, layers.layers);
11908
- const left = unordered(patches, layers.layers, gap.missing);
11909
- const spans = [...gap.missing, ...left];
11910
- if (spans.length === 0) return layers;
11911
- const said = leftSaid(gap.missing.length, left.length);
11912
- const remainder = {
11913
- title: REMAINDER_TITLE,
11914
- blocks: [...said.length === 0 ? [] : [{
11915
- kind: "prose",
11916
- markdown: said
11917
- }], ...spans.map((span) => codeBlockOf$1(span))]
11918
- };
11919
- return {
11920
- ...layers,
11921
- layers: [...layers.layers, remainder]
11922
- };
11923
- };
11924
- proseAnchors = (layer) => {
11925
- const anchors = [];
11926
- let pending = [];
11927
- let last;
11928
- for (const block of layer.blocks) {
11929
- if (block.kind === "prose") {
11930
- const markdown = block.markdown.trim();
11931
- if (markdown.length > 0) pending.push(markdown);
11932
- continue;
11933
- }
11934
- for (const markdown of pending) anchors.push({
11935
- path: block.path,
11936
- line: block.start,
11937
- markdown,
11938
- after: false
11939
- });
11940
- pending = [];
11941
- last = block;
11942
- }
11943
- if (last === void 0) return anchors;
11944
- return [...anchors, ...pending.map((markdown) => ({
11945
- path: last.path,
11946
- line: last.end,
11947
- markdown,
11948
- after: true
11949
- }))];
11950
- };
11951
- }));
11952
- //#endregion
11953
- //#region src/domain/layers/version.ts
11954
- var statusOf;
11955
- var init_version = __esmMin((() => {
11956
- init_coverage();
11957
- statusOf = (patches, layers, branchHead) => {
11958
- const gap = coverage(patches, layers.layers);
11959
- const present = new Set(patches.map((patch) => patch.path));
11960
- const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
11961
- return {
11962
- version: layers.version,
11963
- parent: layers.parent,
11964
- stale: layers.head !== branchHead,
11965
- layersHead: layers.head,
11966
- branchHead,
11967
- uncovered: gap.missing,
11968
- vanished: [...mentioned].filter((path) => !present.has(path)),
11969
- covered: gap.covered,
11970
- partial: gap.partial,
11971
- total: gap.total
11972
- };
11973
- };
11974
- }));
11975
- //#endregion
11976
- //#region src/domain/layers/index.ts
11977
- var init_layers$1 = __esmMin((() => {
11978
- init_coverage();
11979
- init_version();
11980
- init_model$2();
11981
- }));
11982
- //#endregion
11983
12003
  //#region src/cli/layers.ts
11984
12004
  var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, layersIn, partsOfFile, vouchPartIn;
11985
12005
  var init_layers = __esmMin((() => {
@@ -12107,7 +12127,7 @@ var init_layers = __esmMin((() => {
12107
12127
  });
12108
12128
  };
12109
12129
  reportOf = (patches, layers, branchHead) => {
12110
- const status = statusOf(patches, layers, branchHead);
12130
+ const status = statusOf$1(patches, layers, branchHead);
12111
12131
  return {
12112
12132
  version: status.version,
12113
12133
  parent: getOrUndefined$1(status.parent),
@@ -14085,7 +14105,7 @@ var init_tree = __esmMin((() => {
14085
14105
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
14086
14106
  };
14087
14107
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
14088
- })), HOLDS, chosenNow, withChosen, preferenceRows, nothingReviewed, nothingFound, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, tooSmall, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, kept, layerHolds, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip, 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$1, layerRoomIn, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, treeOf, reviewedCountIn, CROWDED, treeRows, crowdedOf, foldersOfFile, isReviewed, partHere, layersHolding, readIn, treeStart, treeWindow, MINUTE, HOUR, DAY, sinceThen, threadStand, STAND_WEIGHT, louder, threadsOn, coveredBy, lastLayerOf, threadsInLayer, threadsOpenOn, askedRows, withAsking, asksAbout, hiddenLines, rowsUnder, markedStands, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, remarkAnswering, answerTarget, replyTarget, threadReplying, VOICES, remarkQuote, threadQuote, pickedText, takenRows, selectedLines, shownMatches, refSaidOf, refsShown, picking, refHere, matchHere, selectionReadout, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, needingRowsIn, commentRowsIn, threadsAtRow, remarkShown, remarksAtRow, remarkRowsIn, stopsIn, stopsAtRow, remarkAtStop, remarkAtRow, remarkInPanel, remarkInDiff, remarkUnderCursor, remarkToTakeOn, remarkHere, threadHere, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, PANEL_SECTIONS, answersIn, newerOf, spokeLast, SECTION_OF, movedPast, sectionOf, sentEntry, remarkRows, panelHolds, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
14108
+ })), HOLDS, chosenNow, withChosen, preferenceRows, nothingReviewed, nothingFound, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, tooSmall, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, kept, layerHolds, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip, 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$1, layerRoomIn, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, treeOf, reviewedCountIn, CROWDED, treeRows, crowdedOf, foldersOfFile, isReviewed, partHere, layersHolding, readIn, treeStart, treeWindow, MINUTE, HOUR, DAY, sinceThen, threadStand, STAND_WEIGHT, louder, threadsOn, coveredBy, lastLayerOf, threadsInLayer, threadsOpenOn, askedRows, withAsking, asksAbout, hiddenLines, rowsUnder, markedStands, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, remarkAnswering, answerTarget, replyTarget, threadReplying, VOICES, remarkQuote, threadQuote, pickedText, takenRows, selectedLines, shownMatches, refSaidOf, refsShown, picking, refHere, matchHere, selectionReadout, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, needingRowsIn, commentRowsIn, draftPlace, notesShown, threadsAtRow, remarkShown, remarksAtRow, remarkRowsIn, stopsIn, stopsAtRow, remarkAtStop, remarkAtRow, remarkInPanel, remarkInDiff, remarkUnderCursor, remarkToTakeOn, remarkHere, threadHere, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, PANEL_SECTIONS, answersIn, newerOf, spokeLast, SECTION_OF, movedPast, sectionOf, sentEntry, remarkRows, panelHolds, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
14089
14109
  var init_model$1 = __esmMin((() => {
14090
14110
  init_dist();
14091
14111
  init_patch();
@@ -14770,6 +14790,34 @@ var init_model$1 = __esmMin((() => {
14770
14790
  const notes = state.sent.filter((entry) => entry.file === patch.path && entry.outside !== true);
14771
14791
  return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
14772
14792
  };
14793
+ draftPlace = (state) => {
14794
+ const patch = selectedPatch(state);
14795
+ if (patch === void 0) return void 0;
14796
+ const to = state.replyTo ?? state.answerTo;
14797
+ if (to === void 0) return {
14798
+ row: selectionRange(state)[1],
14799
+ stop: void 0
14800
+ };
14801
+ const drawn = notesShown(state, patch.path);
14802
+ const at = drawn.findIndex((note) => note.id === to);
14803
+ const note = drawn[at];
14804
+ if (note === void 0) return void 0;
14805
+ const row = patch.rows.find((one) => lineOnSide(one, note.side) === note.end)?.index;
14806
+ if (row === void 0) return void 0;
14807
+ return {
14808
+ row,
14809
+ stop: drawn.filter((one) => one.side === note.side && one.end === note.end && drawn.indexOf(one) <= at).length
14810
+ };
14811
+ };
14812
+ notesShown = (state, path) => [...state.sent.filter((one) => one.file === path && one.removed !== true && one.outside !== true).map((one) => ({
14813
+ id: one.id,
14814
+ side: one.side,
14815
+ end: one.end
14816
+ })), ...state.remarks.filter((one) => one.file === path && remarkShown(one)).map((one) => ({
14817
+ id: one.id,
14818
+ side: one.side,
14819
+ end: one.end
14820
+ }))];
14773
14821
  threadsAtRow = (state, row) => {
14774
14822
  const patch = selectedPatch(state);
14775
14823
  const here = patch?.rows[row];
@@ -17344,7 +17392,7 @@ var init_theme = __esmMin((() => {
17344
17392
  "note.label": { fg: "#7aa2f7" },
17345
17393
  default: { fg: ink }
17346
17394
  };
17347
- })), WASH, NOTE_MIN, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, takenOver, wheelTo, SIGNS, numberFor, DiffView, startsOf, numbered, bareOf, noteKey, keyOf, groupOf, isChrome, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, firstOfEach, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, REMARK_MARK$1, remarkHead, commentHead, headOf, spokenLines, heardFrom, answerLines, REMARK_LINES, capped, bodyLines, saidLines, noteLines, REMARK_RULE, noteRows, proseRows, freshLines, proseAt, apart, notesAt, TRAILING, shownText, codeRow, rowsFor, replacedBy, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
17395
+ })), WASH, NOTE_MIN, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, notchesIn, takenOver, wheelTo, SIGNS, numberFor, DiffView, startsOf, numbered, bareOf, noteKey, keyOf, groupOf, isChrome, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, firstOfEach, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, SAID_INDENT, REMARK_MARK$1, remarkHead, commentHead, headOf, spokenLines, heardFrom, answerLines, REMARK_LINES, capped, bodyLines, saidLines, noteLines, REMARK_RULE, noteRows, proseRows, freshLines, proseAt, apart, notesAt, TRAILING, shownText, codeRow, DRAFT_STOP, draftText, draftRows, rowsFor, replacedBy, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
17348
17396
  var init_diffview = __esmMin((() => {
17349
17397
  init_dist();
17350
17398
  init_patch();
@@ -17433,6 +17481,7 @@ var init_diffview = __esmMin((() => {
17433
17481
  wrapped = false;
17434
17482
  held = 0;
17435
17483
  picked;
17484
+ draftLine;
17436
17485
  constructor(renderer) {
17437
17486
  this.code = new CodeRenderable(renderer, {
17438
17487
  id: "diff-code",
@@ -17487,6 +17536,15 @@ var init_diffview = __esmMin((() => {
17487
17536
  room() {
17488
17537
  return this.noteRoom();
17489
17538
  }
17539
+ noteLeft() {
17540
+ return this.numbers.x + this.gutterWidth();
17541
+ }
17542
+ saidLeft() {
17543
+ return this.noteLeft() + SAID_INDENT;
17544
+ }
17545
+ noteWidth() {
17546
+ return Math.max(NOTE_MIN, this.code.width - this.gutterWidth());
17547
+ }
17490
17548
  paneWidth() {
17491
17549
  return this.numbers.width;
17492
17550
  }
@@ -17530,6 +17588,19 @@ var init_diffview = __esmMin((() => {
17530
17588
  screenTop() {
17531
17589
  return this.code.y;
17532
17590
  }
17591
+ screenLeft() {
17592
+ return this.numbers.x;
17593
+ }
17594
+ showDraft(top, rows) {
17595
+ const at = this.draftTop();
17596
+ if (at === void 0) return top;
17597
+ const highest = Math.max(0, this.tallest() - this.rows());
17598
+ const below = at + rows - this.rows();
17599
+ const above = Math.max(0, at - 1);
17600
+ const settled = Math.max(0, Math.min(highest, above < top ? above : below > top ? below : top));
17601
+ if (this.code.scrollY !== settled) this.code.scrollY = settled;
17602
+ return settled;
17603
+ }
17533
17604
  fit(height) {
17534
17605
  const rows = Math.max(1, height);
17535
17606
  if (rows !== this.fitted) {
@@ -17543,9 +17614,13 @@ var init_diffview = __esmMin((() => {
17543
17614
  rows() {
17544
17615
  return this.fitted;
17545
17616
  }
17546
- show(patch, notes, gaps, prose = []) {
17617
+ show(patch, notes, gaps, under = {
17618
+ prose: [],
17619
+ draft: void 0
17620
+ }) {
17621
+ const { prose, draft } = under;
17547
17622
  const room = notes.length === 0 && prose.length === 0 ? NOTE_MIN : this.noteRoom();
17548
- const key = keyOf(room, notes, prose);
17623
+ const key = keyOf(room, notes, prose, draft);
17549
17624
  if (patch === this.shown && key === this.noted) return;
17550
17625
  this.unpin();
17551
17626
  this.shown = patch;
@@ -17556,8 +17631,11 @@ var init_diffview = __esmMin((() => {
17556
17631
  room,
17557
17632
  gaps,
17558
17633
  prose,
17559
- fresh: freshLines(patch)
17634
+ fresh: freshLines(patch),
17635
+ draft
17560
17636
  });
17637
+ const at = this.display.findIndex((entry) => entry.draft === true);
17638
+ this.draftLine = at === -1 ? void 0 : at;
17561
17639
  this.starts = startsOf(this.display);
17562
17640
  this.code.filetype = pathToFiletype(patch.path) ?? "text";
17563
17641
  this.feed();
@@ -17708,7 +17786,7 @@ var init_diffview = __esmMin((() => {
17708
17786
  carries(visual) {
17709
17787
  const entry = this.display[this.lineAt(visual)];
17710
17788
  if (entry === void 0) return false;
17711
- if (entry.prose) return false;
17789
+ if (entry.prose || entry.draft === true) return false;
17712
17790
  return true;
17713
17791
  }
17714
17792
  isComment(visual) {
@@ -17738,6 +17816,9 @@ var init_diffview = __esmMin((() => {
17738
17816
  screenRowOf(row) {
17739
17817
  return this.visualOfRow(row);
17740
17818
  }
17819
+ draftTop() {
17820
+ return this.draftLine === void 0 ? void 0 : this.visualOf(this.draftLine);
17821
+ }
17741
17822
  pick(picked) {
17742
17823
  if (alike(this.picked, picked)) return;
17743
17824
  this.picked = picked;
@@ -17808,8 +17889,9 @@ var init_diffview = __esmMin((() => {
17808
17889
  note.settled ? "settled" : note.asks ? "asked" : "open",
17809
17890
  ...note.turns.length > 0 ? note.turns.map((turn) => `${turn.voice[0] ?? ""}:${turn.body}`) : note.answers.map((body) => `a:${body}`)
17810
17891
  ].join("");
17811
- keyOf = (room, notes, prose) => [
17892
+ keyOf = (room, notes, prose, draft) => [
17812
17893
  room,
17894
+ draft === void 0 ? "d-" : `d${draft.row}:${draft.stop ?? 0}:${draft.rows}:${draft.head}`,
17813
17895
  ...notes.map(noteKey),
17814
17896
  ...prose.map((entry) => `p${entry.line}${entry.after ? ">" : "<"}:${entry.markdown}`)
17815
17897
  ].join("\0");
@@ -17924,6 +18006,7 @@ var init_diffview = __esmMin((() => {
17924
18006
  }
17925
18007
  return lines;
17926
18008
  };
18009
+ SAID_INDENT = 2;
17927
18010
  REMARK_MARK$1 = "◇";
17928
18011
  remarkHead = (note, from) => `${REMARK_MARK$1} @${from}${note.stale ? " · outdated" : ""}`;
17929
18012
  commentHead = (note) => {
@@ -17995,7 +18078,10 @@ var init_diffview = __esmMin((() => {
17995
18078
  gap: false,
17996
18079
  prose: false
17997
18080
  });
17998
- notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note, at) => at === 0 ? noteRows(note, row.index, plan.room, at + 1) : [apart(row.index, at + 1)].concat(noteRows(note, row.index, plan.room, at + 1)));
18081
+ notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note, at) => {
18082
+ const drawn = at === 0 ? noteRows(note, row.index, plan.room, at + 1) : [apart(row.index, at + 1)].concat(noteRows(note, row.index, plan.room, at + 1));
18083
+ return plan.draft?.stop === at + 1 ? drawn.concat(draftRows(plan, row)) : drawn;
18084
+ });
17999
18085
  TRAILING = /[ \t]+$/;
18000
18086
  shownText = (row) => {
18001
18087
  if (row.kind === "context") return row.text;
@@ -18014,11 +18100,29 @@ var init_diffview = __esmMin((() => {
18014
18100
  gap: plan.gaps.has(row.index),
18015
18101
  prose: false
18016
18102
  });
18103
+ DRAFT_STOP = -1;
18104
+ draftText = (draft, at) => {
18105
+ if (at === 0) return `${marks().rule} ${draft.head}`;
18106
+ if (at === 1) return `${marks().rule} » `;
18107
+ return marks().rule;
18108
+ };
18109
+ draftRows = (plan, row) => plan.draft === void 0 || plan.draft.row !== row.index ? [] : Array.from({ length: plan.draft.rows }, (_, at) => ({
18110
+ text: draftText(plan.draft, at),
18111
+ row: row.index,
18112
+ stop: DRAFT_STOP,
18113
+ draft: true,
18114
+ comment: true,
18115
+ sent: false,
18116
+ label: false,
18117
+ gap: false,
18118
+ prose: false
18119
+ }));
18017
18120
  rowsFor = (plan, row, around) => [
18018
18121
  ...around.lead.flatMap((entry) => proseRows(entry, row.index, plan.room)),
18019
18122
  ...(around.own ? proseAt(plan, row, false) : []).flatMap((entry) => proseRows(entry, row.index, plan.room)),
18020
18123
  codeRow(plan, row),
18021
18124
  ...notesAt(plan, row),
18125
+ ...plan.draft?.stop === void 0 ? draftRows(plan, row) : [],
18022
18126
  ...proseAt(plan, row, true).flatMap((entry) => proseRows(entry, row.index, plan.room))
18023
18127
  ];
18024
18128
  replacedBy = (rows, at) => {
@@ -18069,7 +18173,7 @@ var init_diffview = __esmMin((() => {
18069
18173
  }));
18070
18174
  //#endregion
18071
18175
  //#region src/tui/render.ts
18072
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, SENDS, REPLIES, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, LEGEND_ROWS, LEGEND, legendText, keysTitle, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, COMPOSE_EDGE, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, keysOf, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, askText, SETTING_LEAD, settingsText, stack, makeBody, makeHome, makeModals, makeBaseParts, makeAskParts, makeReaderParts, makeSettingsParts, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, stillThere, quotedFor, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, remarksOf, notesFor, paired, chipWidth, WAYS_OUT, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, fileMark, fileLook, layerLook, layerGutter, layerText, standingOnThread, standingOnRemark, standingOnDismissed, offeredIn, readerTitle, voicesOf, readerText, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, counting, foundBlocks, JOIN, foundTitle, CHANGED_MARK, DECLARED, fileRow, leftRow, placeRow, blockOf, aroundRow, windowedBlocks, pickingTitle, YOURS, YOUR_REF, pickedTail, REMARK_MARK, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelPicked, panelText, Screen;
18176
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, MODAL_ROOM, COMPOSE_CHROME, DRAFT_PAD, NOTE_ROOM_MIN, DRAFT_ROOM, DRAFT_HEAD, COMPOSE_ACTION_ROWS, reportActions, SENDS, REPLIES, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, LEGEND_ROWS, LEGEND, legendText, keysTitle, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, COMPOSE_EDGE, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, keysOf, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, SHEET_GAP, sheetRow, groupedBy, sheetBlock, splitInTwo, sheetPaint, sheetDeep, sheetText, askText, SETTING_LEAD, settingsText, stack, makeBody, makeHome, makeModals, makeBaseParts, makeAskParts, makeReaderParts, makeSettingsParts, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, stillThere, quotedFor, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, remarksOf, notesFor, paired, chipWidth, WAYS_OUT, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, panLabel, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_ASKING, STALE_LONG, STALE_MIDDLE, STALE_SHORT, staleSaid, staleBanner, litRow, leftOver, titlePaint, titleMark, titleLook, fileMark, fileLook, layerLook, layerGutter, layerText, standingOnThread, standingOnRemark, standingOnDismissed, offeredIn, readerTitle, voicesOf, readerText, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, counting, foundBlocks, JOIN, foundTitle, CHANGED_MARK, DECLARED, fileRow, leftRow, placeRow, blockOf, aroundRow, windowedBlocks, pickingTitle, YOURS, YOUR_REF, pickedTail, REMARK_MARK, remarkWhere, wherePart, panelFile, panelWhere, panelBody, panelMark, lostCode, lostEntry, writtenOn, foldLine, panelPair, panelSection, PULL_HINT, panelWindow, moreLine, panelPicked, panelText, Screen;
18073
18177
  var init_render = __esmMin((() => {
18074
18178
  init_dist();
18075
18179
  init_command();
@@ -18087,6 +18191,10 @@ var init_render = __esmMin((() => {
18087
18191
  CHIP_GAP = 4;
18088
18192
  MODAL_ROOM = 8;
18089
18193
  COMPOSE_CHROME = 3;
18194
+ DRAFT_PAD = 2;
18195
+ NOTE_ROOM_MIN = 24;
18196
+ DRAFT_ROOM = 6;
18197
+ DRAFT_HEAD = 1;
18090
18198
  COMPOSE_ACTION_ROWS = 2;
18091
18199
  reportActions = (full) => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^t")} ${fg(palette.muted)(full ? "sending everything" : "sending the least")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
18092
18200
  SENDS = "send it";
@@ -18721,6 +18829,7 @@ var init_render = __esmMin((() => {
18721
18829
  if (answering.length > 0) return answering.slice(0, shownLines * 2).map((line) => clip(line, room));
18722
18830
  const said = threadQuote(state, room);
18723
18831
  if (said.length > 0) return said.slice(0, shownLines * 2).map((line) => clip(line, room));
18832
+ if (state.replyTo !== void 0) return [];
18724
18833
  const snippet = snippetOf(state, shownLines);
18725
18834
  const more = selectedLineCount(state) - snippet.length;
18726
18835
  const tail = more > 0 ? [` … ${more} more lines`] : [];
@@ -19393,6 +19502,8 @@ var init_render = __esmMin((() => {
19393
19502
  panelPicks = [];
19394
19503
  dragFrom;
19395
19504
  lastTop = 0;
19505
+ drafted;
19506
+ drafting;
19396
19507
  constructor(renderer, repo = "") {
19397
19508
  this.renderer = renderer;
19398
19509
  this.repo = repo;
@@ -19809,14 +19920,25 @@ var init_render = __esmMin((() => {
19809
19920
  const patch = shown.patch;
19810
19921
  this.view.setWrap(state.wrap, this.diffRoom());
19811
19922
  this.view.setPan(state.pan);
19812
- this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
19923
+ const draft = this.draftFor(state);
19924
+ this.drafted = draft;
19925
+ this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), {
19926
+ prose: proseFor(state, patch.path),
19927
+ draft
19928
+ });
19813
19929
  this.view.pick(state.picked);
19814
19930
  if (!takesText(state.screen)) {
19815
19931
  this.view.fit(this.diffRows());
19816
19932
  this.lastTop = this.view.scrollTo(state.top, state.cursor, state.scroll);
19817
19933
  if (state.sticky) this.paintSticky(state, this.view.rowAt(this.lastTop));
19818
19934
  else this.view.pin([]);
19935
+ } else if (draft !== void 0) {
19936
+ this.view.fit(this.diffRows());
19937
+ const held = state.scroll >= 0 && this.drafting === draft.row ? state.scroll : this.lastTop;
19938
+ this.lastTop = this.view.showDraft(held, draft.rows);
19939
+ this.drafting = draft.row;
19819
19940
  }
19941
+ if (draft === void 0) this.drafting = void 0;
19820
19942
  const top = this.lastTop;
19821
19943
  this.view.paint(this.linePaint(state), top, this.view.rows());
19822
19944
  this.paintGutter(state, top, this.view.rows());
@@ -19989,6 +20111,7 @@ var init_render = __esmMin((() => {
19989
20111
  paintReport(state) {
19990
20112
  this.compose.visible = state.screen === "compose" || state.screen === "report";
19991
20113
  if (state.screen !== "report") return;
20114
+ this.asBox();
19992
20115
  const room = composeRoom(this.renderer.width);
19993
20116
  const asked = state.reportFull ? "What went wrong? Everything on screen is attached for you." : "What went wrong? Only what you type is sent.";
19994
20117
  const lead = laidOut$1([asked], room.text);
@@ -20040,6 +20163,66 @@ var init_render = __esmMin((() => {
20040
20163
  });
20041
20164
  };
20042
20165
  }
20166
+ draftFor(state) {
20167
+ if (state.screen !== "compose") return void 0;
20168
+ if (this.diffRows() < DRAFT_ROOM) return void 0;
20169
+ const place = draftPlace(state);
20170
+ if (place === void 0 || this.view.screenRowOf(place.row) === void 0) return void 0;
20171
+ const body = this.draftBody(state);
20172
+ return {
20173
+ row: place.row,
20174
+ stop: place.stop,
20175
+ rows: DRAFT_HEAD + body + COMPOSE_ACTION_ROWS,
20176
+ head: clip(composeTarget(state), this.draftRoom())
20177
+ };
20178
+ }
20179
+ draftRoom() {
20180
+ return Math.max(NOTE_ROOM_MIN, this.view.noteWidth() - DRAFT_PAD);
20181
+ }
20182
+ draftBody(state) {
20183
+ const most = Math.max(1, this.diffRows() - DRAFT_HEAD - COMPOSE_ACTION_ROWS - 1);
20184
+ return Math.max(1, Math.min(most, laidDraft(state.draft, this.draftRoom()).length));
20185
+ }
20186
+ paintInline(state, draft) {
20187
+ const at = this.view.draftTop();
20188
+ if (at === void 0) return;
20189
+ this.asNote();
20190
+ this.composeTitle.content = "";
20191
+ this.composeTitle.height = 0;
20192
+ this.composeQuoted.content = "";
20193
+ this.composeQuoted.height = 0;
20194
+ this.fitBody(state, this.draftRoom(), draft.rows - DRAFT_HEAD - COMPOSE_ACTION_ROWS);
20195
+ this.composeActions.content = actionsText(state.answerTo === void 0 ? SENDS : REPLIES);
20196
+ this.compose.height = draft.rows - DRAFT_HEAD;
20197
+ this.compose.width = this.draftRoom();
20198
+ this.compose.left = this.view.saidLeft();
20199
+ const top = this.view.screenTop();
20200
+ const lowest = top + Math.max(0, this.view.rows() - draft.rows + DRAFT_HEAD);
20201
+ this.compose.top = Math.max(top, Math.min(lowest, top + at + DRAFT_HEAD - this.lastTop));
20202
+ }
20203
+ asNote() {
20204
+ if (this.compose.border !== false) {
20205
+ this.compose.border = false;
20206
+ this.compose.paddingLeft = 0;
20207
+ this.compose.paddingRight = 0;
20208
+ this.compose.paddingTop = 0;
20209
+ this.compose.backgroundColor = "transparent";
20210
+ this.composeBody.backgroundColor = "transparent";
20211
+ this.composeBody.focusedBackgroundColor = "transparent";
20212
+ }
20213
+ }
20214
+ asBox() {
20215
+ if (this.compose.border === false) {
20216
+ this.compose.border = ["left"];
20217
+ this.compose.paddingLeft = GUTTER_X;
20218
+ this.compose.paddingRight = GUTTER_X;
20219
+ this.compose.paddingTop = 1;
20220
+ this.compose.backgroundColor = palette.panel;
20221
+ this.composeBody.backgroundColor = palette.panel;
20222
+ this.composeBody.focusedBackgroundColor = palette.panel;
20223
+ this.composeTitle.height = 1;
20224
+ }
20225
+ }
20043
20226
  fitBody(state, room, most) {
20044
20227
  if (this.composeBody.width !== room) this.composeBody.width = room;
20045
20228
  const wanted = Math.max(1, laidDraft(state.draft, room).length);
@@ -20050,6 +20233,12 @@ var init_render = __esmMin((() => {
20050
20233
  paintCompose(state) {
20051
20234
  this.compose.visible = state.screen === "compose";
20052
20235
  if (state.screen !== "compose") return;
20236
+ const inline = this.drafted;
20237
+ if (inline !== void 0) {
20238
+ this.paintInline(state, inline);
20239
+ return;
20240
+ }
20241
+ this.asBox();
20053
20242
  const room = composeRoom(this.renderer.width);
20054
20243
  const shownLines = Math.max(1, Math.min(SNIPPET_LINES, Math.floor(this.renderer.height / 6)));
20055
20244
  const quoted = quotedFor(state, shownLines, room.text);
@@ -20771,7 +20960,8 @@ var init_app = __esmMin((() => {
20771
20960
  return Date.now() - this.began;
20772
20961
  }
20773
20962
  commit(given) {
20774
- const next = given.patchIndex === this.state.patchIndex ? given : turnedOver(given);
20963
+ const kept = this.keptScroll(given);
20964
+ const next = kept.patchIndex === this.state.patchIndex ? kept : turnedOver(kept);
20775
20965
  this.turnWriting(next);
20776
20966
  const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
20777
20967
  if (appeared) this.recordNotice(next.notice);
@@ -20780,6 +20970,14 @@ var init_app = __esmMin((() => {
20780
20970
  this.write(next);
20781
20971
  if (appeared) this.fade();
20782
20972
  }
20973
+ keptScroll(given) {
20974
+ if (this.state.screen !== "compose" || given.screen === "compose") return given;
20975
+ if (given.patchIndex !== this.state.patchIndex) return given;
20976
+ return {
20977
+ ...given,
20978
+ scroll: runSync(this.display.at)
20979
+ };
20980
+ }
20783
20981
  recordNotice(notice) {
20784
20982
  this.trail.push(noticeOf(notice, this.since()));
20785
20983
  if (this.trail.length > TRAIL_HISTORY) this.trail.shift();
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.170",
26
+ "version": "0.1.0-alpha.172",
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": {
@@ -24,6 +24,11 @@ Each comment carries the code it is about. `snippet` is the exact text the revie
24
24
  `side` says whether the line numbers are in the new file (`new`) or the version being replaced
25
25
  (`old`), and `head` is the commit the diff was read at.
26
26
 
27
+ A comment on code one of your layers explains carries `layer`, that layer's title as your latest
28
+ revision has it. The code the layer describes is about to change under your hands, so the layers go
29
+ stale the moment you act on the comment: write a new revision with `adiff layers set` before you
30
+ answer, and say in the answer that you did.
31
+
27
32
  A comment keeps coming back until it is answered. A second `take` returns it again, so answer what
28
33
  you take. Settling or removing it also retires it: those are the reviewer saying they no longer
29
34
  need one.