@eliya-oss/agent-diff 0.1.0-alpha.203 → 0.1.0-alpha.205

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,45 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.205
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(reading order): `layers show` reports the layers stale and names each span as `outdated` once the code under it changes, even before a commit.
8
+
9
+ <details><summary>What was wrong</summary>
10
+
11
+ A reading order went stale only when the commit moved. An agent that edited a file after writing its layers, without committing, was told the layers were current while their spans pointed at other code.
12
+
13
+ </details>
14
+
15
+ feat(reading order): `layers set` names each TypeScript or TSX function, method or function-valued constant whose changed lines two layers share, under `split`, with its lines and those layers.
16
+
17
+ <details><summary>What was wrong</summary>
18
+
19
+ Spans counted on one version of a file and set on another covered every line, so coverage came back complete while a function was read half in one layer and half in another.
20
+
21
+ </details>
22
+
23
+ ## 0.1.0-alpha.204
24
+
25
+ ### Patch Changes
26
+
27
+ - fix(agent commands): `--body -` reads the text from stdin, as `layers set --json -` already does, so an answer piped in from a heredoc reaches the reviewer whole. Blank text on stdin is refused.
28
+
29
+ <details><summary>What was wrong</summary>
30
+
31
+ An agent that answered with `--body -` and the text on stdin stored a lone `-` as its answer, which the reviewer saw as an empty reply, and the text it meant to send was lost. Every command that takes `--body` now reads stdin for `-`: comment send, reply, answer and doing, draft add and edit, remark accept and reply.
32
+
33
+ </details>
34
+
35
+ - fix(marks): a layer marked read stays read when the agent changes the file only in another layer's lines, and marking that layer again unmarks it.
36
+
37
+ <details><summary>What was wrong</summary>
38
+
39
+ A file two layers share was read one layer at a time. When the agent changed the file in one layer's lines, every layer of the file went back to unread, so a layer with nothing new in it asked to be read again and its Since review view had nothing to show. A file marked read whole already kept its untouched layers. And on a layer kept read that way, pressing mark recorded a new mark instead of taking the layer back out.
40
+
41
+ </details>
42
+
3
43
  ## 0.1.0-alpha.203
4
44
 
5
45
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/main.js CHANGED
@@ -8,6 +8,7 @@ import { createInterface } from "node:readline";
8
8
  import { join, resolve } from "node:path";
9
9
  import { promisify } from "node:util";
10
10
  import { homedir, hostname, platform } from "node:os";
11
+ import { Language, Parser } from "web-tree-sitter";
11
12
  import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, KeyEvent, LineNumberRenderable, RGBA, StyledText, SyntaxStyle, TextRenderable, TextareaRenderable, addDefaultParsers, bg, bold, createCliRenderer, defaultTextareaKeyBindings, fg, fonts, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
12
13
  //#region \0rolldown/runtime.js
13
14
  var __defProp = Object.defineProperty;
@@ -2686,7 +2687,7 @@ var init_references = __esmMin((() => {
2686
2687
  };
2687
2688
  };
2688
2689
  spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
2689
- })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService$1, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, tapCauseFilter, tapError$1, catchIf, catchFilter, catchTag$1, catchTags$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, filter$2, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2690
+ })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService$1, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, tapCauseFilter, tapError$1, catchIf, catchFilter, catchTag$1, catchTags$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, cachedInvalidateWithTTL, cachedWithTTL, cached$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, filter$2, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2690
2691
  init_Array();
2691
2692
  init_Context();
2692
2693
  init_Duration();
@@ -3729,6 +3730,35 @@ var init_references = __esmMin((() => {
3729
3730
  }));
3730
3731
  onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
3731
3732
  acquireUseRelease$1 = (acquire, use, release) => uninterruptibleMask$1((restore) => flatMap$1(acquire, (a) => onExitPrimitive(restore(use(a)), (exit) => release(a, exit), true)));
3733
+ cachedInvalidateWithTTL = /*#__PURE__*/ dual(2, (self, ttl) => sync$1(() => {
3734
+ const ttlMillis = toMillis(fromInputUnsafe(ttl));
3735
+ const isFinite = Number.isFinite(ttlMillis);
3736
+ const latch = makeLatchUnsafe(false);
3737
+ let expiresAt = 0;
3738
+ let running = false;
3739
+ let exit;
3740
+ const wait = flatMap$1(latch.await, () => exit);
3741
+ return [withFiber$1((fiber) => {
3742
+ const clock = fiber.getRef(ClockRef);
3743
+ const now = isFinite ? clock.currentTimeMillisUnsafe() : 0;
3744
+ if (running || now < expiresAt) return exit ?? wait;
3745
+ running = true;
3746
+ latch.closeUnsafe();
3747
+ exit = void 0;
3748
+ return onExit$1(self, (exit_) => sync$1(() => {
3749
+ running = false;
3750
+ expiresAt = clock.currentTimeMillisUnsafe() + ttlMillis;
3751
+ exit = exit_;
3752
+ latch.openUnsafe();
3753
+ }));
3754
+ }), sync$1(() => {
3755
+ expiresAt = 0;
3756
+ latch.closeUnsafe();
3757
+ exit = void 0;
3758
+ })];
3759
+ }));
3760
+ cachedWithTTL = /*#__PURE__*/ dual(2, (self, timeToLive) => map$3(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0]));
3761
+ cached$1 = (self) => cachedWithTTL(self, infinity);
3732
3762
  interrupt$1 = /*#__PURE__*/ withFiber$1((fiber) => failCause$3(causeInterrupt(fiber.id)));
3733
3763
  uninterruptible$1 = (self) => withFiber$1((fiber) => {
3734
3764
  if (!fiber.interruptible) return self;
@@ -4813,7 +4843,7 @@ var repeatOrElse, retryOrElse, repeat$1, retry$1, passthroughForever, buildFromO
4813
4843
  if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$5(attempt <= options.times));
4814
4844
  return schedule;
4815
4845
  };
4816
- })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchTags, catchCause, catchDefect, mapError, orDie, tapError, retry, ignore, orElseSucceed, sleep, raceFirst, filter$1, when, context, contextWith, provide, provideService, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4846
+ })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchTags, catchCause, catchDefect, mapError, orDie, tapError, retry, ignore, orElseSucceed, sleep, raceFirst, filter$1, when, context, contextWith, provide, provideService, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, cached, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4817
4847
  var init_Effect = __esmMin((() => {
4818
4848
  init_Context();
4819
4849
  init_core();
@@ -4873,6 +4903,7 @@ var init_Effect = __esmMin((() => {
4873
4903
  ensuring = ensuring$1;
4874
4904
  onError = onError$1;
4875
4905
  onExit = onExit$1;
4906
+ cached = cached$1;
4876
4907
  interrupt = interrupt$1;
4877
4908
  onInterrupt = onInterrupt$1;
4878
4909
  uninterruptible = uninterruptible$1;
@@ -10083,11 +10114,11 @@ var init_config = __esmMin((() => {
10083
10114
  //#region package.json
10084
10115
  init_pane();
10085
10116
  init_config();
10086
- var version$1 = "0.1.0-alpha.203";
10117
+ var version$1 = "0.1.0-alpha.205";
10087
10118
  //#endregion
10088
10119
  //#region src/cli/error.ts
10089
10120
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10090
- var init_error$5 = __esmMin((() => {
10121
+ var init_error$6 = __esmMin((() => {
10091
10122
  init_dist();
10092
10123
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
10093
10124
  MissingOption = class extends TaggedError("MissingOption") {};
@@ -10103,7 +10134,7 @@ var init_error$5 = __esmMin((() => {
10103
10134
  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$2, newer, DistTags, readTags, unanswered, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
10104
10135
  var init_upgrade$1 = __esmMin((() => {
10105
10136
  init_dist();
10106
- init_error$5();
10137
+ init_error$6();
10107
10138
  PACKAGE = "@eliya-oss/agent-diff";
10108
10139
  TAG = "alpha";
10109
10140
  RELEASES = "https://github.com/Newbie012/agent-diff/releases/latest";
@@ -10378,7 +10409,7 @@ var init_catalog = __esmMin((() => {
10378
10409
  name: "body",
10379
10410
  required: true,
10380
10411
  value: "text",
10381
- about: "What to tell the agent"
10412
+ about: "What to tell the agent, or - to read it from stdin"
10382
10413
  },
10383
10414
  {
10384
10415
  name: "side",
@@ -10602,7 +10633,7 @@ var init_catalog = __esmMin((() => {
10602
10633
  name: "body",
10603
10634
  required: true,
10604
10635
  value: "text",
10605
- about: "What to tell the agent"
10636
+ about: "What to tell the agent, or - to read it from stdin"
10606
10637
  }
10607
10638
  ],
10608
10639
  dataKey: "batch",
@@ -10650,7 +10681,7 @@ var init_catalog = __esmMin((() => {
10650
10681
  name: "body",
10651
10682
  required: true,
10652
10683
  value: "text",
10653
- about: "What was done, or what is being asked"
10684
+ about: "What was done, or what is being asked, or - to read it from stdin"
10654
10685
  },
10655
10686
  {
10656
10687
  name: "question",
@@ -10765,7 +10796,7 @@ var init_catalog = __esmMin((() => {
10765
10796
  name: "body",
10766
10797
  required: true,
10767
10798
  value: "text",
10768
- about: "What it should say instead"
10799
+ about: "What it should say instead, or - to read it from stdin"
10769
10800
  }
10770
10801
  ],
10771
10802
  dataKey: "draft",
@@ -10834,7 +10865,7 @@ var init_catalog = __esmMin((() => {
10834
10865
  name: "body",
10835
10866
  required: false,
10836
10867
  value: "text",
10837
- about: "What to tell the agent, instead of the remark's own words"
10868
+ about: "What to tell the agent, instead of the remark's own words, or - to read it from stdin"
10838
10869
  }
10839
10870
  ],
10840
10871
  dataKey: "accepted",
@@ -10858,7 +10889,7 @@ var init_catalog = __esmMin((() => {
10858
10889
  name: "body",
10859
10890
  required: true,
10860
10891
  value: "text",
10861
- about: "What to say in the thread"
10892
+ about: "What to say in the thread, or - to read it from stdin"
10862
10893
  }
10863
10894
  ],
10864
10895
  dataKey: "answered",
@@ -11138,11 +11169,11 @@ var init_catalog = __esmMin((() => {
11138
11169
  }));
11139
11170
  //#endregion
11140
11171
  //#region src/cli/parse.ts
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;
11172
+ var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, STDIN, text$1, numeric, SPOT, spot, WHOLE, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11142
11173
  var init_parse$1 = __esmMin((() => {
11143
11174
  init_dist();
11144
11175
  init_catalog();
11145
- init_error$5();
11176
+ init_error$6();
11146
11177
  FLAG = /^--(?<name>[^=]+)(?:=(?<value>[\s\S]*))?$/;
11147
11178
  REPEATED = /* @__PURE__ */ new Set(["choice"]);
11148
11179
  MANY = "\n";
@@ -11216,6 +11247,16 @@ var init_parse$1 = __esmMin((() => {
11216
11247
  onSome: succeed$1
11217
11248
  });
11218
11249
  });
11250
+ STDIN = "-";
11251
+ text$1 = fn("Cli.text")(function* (options, name) {
11252
+ const given = yield* required(options, name);
11253
+ const said = given === STDIN ? yield* promise(() => text(process.stdin)) : given;
11254
+ return yield* said.trim().length > 0 ? succeed$1(given === STDIN ? said.trimEnd() : said) : new BadOption({
11255
+ option: name,
11256
+ given,
11257
+ allowed: ["text, or - with the text on stdin"]
11258
+ });
11259
+ });
11219
11260
  numeric = fn("Cli.numeric")(function* (options, name) {
11220
11261
  const raw = yield* required(options, name);
11221
11262
  const parsed = Number(raw);
@@ -11277,8 +11318,8 @@ var init_parse$1 = __esmMin((() => {
11277
11318
  });
11278
11319
  });
11279
11320
  oneLine = fn("Cli.oneLine")(function* (options, name) {
11280
- const said = (yield* required(options, name)).trim();
11281
- return yield* said.length > 0 && !said.includes("\n") ? succeed$1(said) : new BadOption({
11321
+ const said = (yield* text$1(options, name)).trim();
11322
+ return yield* !said.includes("\n") ? succeed$1(said) : new BadOption({
11282
11323
  option: name,
11283
11324
  given: said,
11284
11325
  allowed: ["one line of text, not empty"]
@@ -11533,7 +11574,7 @@ var init_report$1 = __esmMin((() => {
11533
11574
  var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11534
11575
  var init_serve = __esmMin((() => {
11535
11576
  init_dist();
11536
- init_error$5();
11577
+ init_error$6();
11537
11578
  init_report$1();
11538
11579
  init_parse$1();
11539
11580
  init_catalog();
@@ -11672,7 +11713,7 @@ var init_cli = __esmMin((() => {
11672
11713
  init_parse$1();
11673
11714
  init_catalog();
11674
11715
  init_report$1();
11675
- init_error$5();
11716
+ init_error$6();
11676
11717
  init_serve();
11677
11718
  }));
11678
11719
  //#endregion
@@ -12262,7 +12303,7 @@ var init_patch = __esmMin((() => {
12262
12303
  //#endregion
12263
12304
  //#region src/service/git/error.ts
12264
12305
  var GitCommandFailed, NotARepository, FileUnreadable;
12265
- var init_error$4 = __esmMin((() => {
12306
+ var init_error$5 = __esmMin((() => {
12266
12307
  init_dist();
12267
12308
  GitCommandFailed = class extends TaggedError("GitCommandFailed") {};
12268
12309
  NotARepository = class extends TaggedError("NotARepository") {};
@@ -12273,7 +12314,7 @@ var init_error$4 = __esmMin((() => {
12273
12314
  var exec, MAX_OUTPUT, git, gitOrEmpty;
12274
12315
  var init_run = __esmMin((() => {
12275
12316
  init_dist();
12276
- init_error$4();
12317
+ init_error$5();
12277
12318
  exec = promisify(execFile);
12278
12319
  MAX_OUTPUT = 67108864;
12279
12320
  git = fn("Git.run")(function* (cwd, args) {
@@ -12295,9 +12336,9 @@ var init_run = __esmMin((() => {
12295
12336
  return yield* git(cwd, args).pipe(catchTag("GitCommandFailed", () => succeed$1("")));
12296
12337
  });
12297
12338
  })), CACHE_SIZE, NAME_TTL, FRESH_TTL, SPLIT$1, DEFAULT_BRANCH_CANDIDATES, PLAIN_PATHS, STAT, Git, parseStat, readEntries, verifiedIn, findDefaultBranch, partsOf$1, findMergeBase, toWorktree, branchTips, findParent, splitLines, absent, readText, settled, seenAs, listWorktrees, readDiff, readStat, readSource, readBlob, NO_CONTENT, keepContent, findKept, readBetween, readGrep, GENERATED_SAID, markedGenerated, readGenerated, askRepo, LINKED_GIT_DIR, HEAD_REF, gitDirOf, findCommonDir, readHead, REFS_MOST, readCommits, readRefs, refResolves, sharedCommit, makeCaches, shapeWith, makeGit, GitLive;
12298
- var init_service$2 = __esmMin((() => {
12339
+ var init_service$3 = __esmMin((() => {
12299
12340
  init_dist();
12300
- init_error$4();
12341
+ init_error$5();
12301
12342
  init_run();
12302
12343
  CACHE_SIZE = 256;
12303
12344
  NAME_TTL = "5 minutes";
@@ -12644,13 +12685,13 @@ var init_service$2 = __esmMin((() => {
12644
12685
  //#endregion
12645
12686
  //#region src/service/git/index.ts
12646
12687
  var init_git = __esmMin((() => {
12647
- init_service$2();
12648
- init_error$4();
12688
+ init_service$3();
12689
+ init_error$5();
12649
12690
  }));
12650
12691
  //#endregion
12651
12692
  //#region src/service/store/error.ts
12652
12693
  var StoreUnwritable, StoreUnreadable;
12653
- var init_error$3 = __esmMin((() => {
12694
+ var init_error$4 = __esmMin((() => {
12654
12695
  init_dist();
12655
12696
  StoreUnwritable = class extends TaggedError("StoreUnwritable") {};
12656
12697
  StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
@@ -12677,7 +12718,7 @@ var init_model$4 = __esmMin((() => {
12677
12718
  }));
12678
12719
  //#endregion
12679
12720
  //#region src/service/store/schema.ts
12680
- var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, UpgradeCheck, Prose, Code$1, StoredLayer, StoredLayers;
12721
+ var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredLayers;
12681
12722
  var init_schema = __esmMin((() => {
12682
12723
  init_dist();
12683
12724
  Side = Literals(["old", "new"]);
@@ -12797,7 +12838,15 @@ var init_schema = __esmMin((() => {
12797
12838
  kind: Literal("code"),
12798
12839
  path: String$1,
12799
12840
  start: Int,
12800
- end: Int
12841
+ end: Int,
12842
+ text: optionalKey(String$1)
12843
+ });
12844
+ Split = Struct({
12845
+ path: String$1,
12846
+ name: String$1,
12847
+ start: Int,
12848
+ end: Int,
12849
+ layers: ArraySchema(Int)
12801
12850
  });
12802
12851
  StoredLayer = Struct({
12803
12852
  title: String$1,
@@ -12810,7 +12859,9 @@ var init_schema = __esmMin((() => {
12810
12859
  parent: optionalKey(UndefinedOr(Int)),
12811
12860
  written: String$1,
12812
12861
  summary: String$1,
12813
- layers: ArraySchema(StoredLayer)
12862
+ layers: ArraySchema(StoredLayer),
12863
+ blobs: optionalKey(Record(String$1, String$1)),
12864
+ split: optionalKey(ArraySchema(Split))
12814
12865
  });
12815
12866
  }));
12816
12867
  //#endregion
@@ -12836,10 +12887,10 @@ var init_paths = __esmMin((() => {
12836
12887
  //#endregion
12837
12888
  //#region src/service/store/service.ts
12838
12889
  var Store, ensureDir, readOptional, missing$2, damaged, jsonOf$2, decoded, unwritable, besideOf$1, wrote, added$1, INDENT, DRAFTS_VERSION, encoded, writes, appends, writeSettings, writeUpgradeCheck, writeState, writeLayers, writeRemarks, writeDrafts, writeBatch, writeAnswer, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asRemarks, asDrafts, asWatching, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, parseRemarks, idsIn$1, takes, cursorOps, settingsOps, upgradeOps, reportOps, branchKeyIn, branchKeyOf, wasKeyOf, there, moved, adopt, SPLIT, ADOPT_SIZE, adopting, keyIn, answerOps, layersOps, remarksOps, inboxOps, STATE_LOCK, DRAFTS_LOCK, held$2, stale$1, stolen, taken, freed, alone, watchOps, draftsOps, stateOps, makeStore, madeStore, storeAt;
12839
- var init_service$1 = __esmMin((() => {
12890
+ var init_service$2 = __esmMin((() => {
12840
12891
  init_dist();
12841
12892
  init_git();
12842
- init_error$3();
12893
+ init_error$4();
12843
12894
  init_model$4();
12844
12895
  init_schema();
12845
12896
  init_paths();
@@ -13276,15 +13327,15 @@ var init_service$1 = __esmMin((() => {
13276
13327
  //#endregion
13277
13328
  //#region src/service/store/index.ts
13278
13329
  var init_store = __esmMin((() => {
13279
- init_service$1();
13280
- init_error$3();
13330
+ init_service$2();
13331
+ init_error$4();
13281
13332
  init_paths();
13282
13333
  init_model$4();
13283
13334
  }));
13284
13335
  //#endregion
13285
13336
  //#region src/review/error.ts
13286
13337
  var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13287
- var init_error$2 = __esmMin((() => {
13338
+ var init_error$3 = __esmMin((() => {
13288
13339
  init_dist();
13289
13340
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
13290
13341
  BranchMoved = class extends TaggedError("BranchMoved") {};
@@ -13315,7 +13366,7 @@ var init_branches$1 = __esmMin((() => {
13315
13366
  init_patch();
13316
13367
  init_git();
13317
13368
  init_store();
13318
- init_error$2();
13369
+ init_error$3();
13319
13370
  realOf = (worktree) => tryPromise({
13320
13371
  try: () => realpath(worktree),
13321
13372
  catch: () => new UnknownWorktree({
@@ -13545,12 +13596,12 @@ var init_branches$1 = __esmMin((() => {
13545
13596
  }));
13546
13597
  //#endregion
13547
13598
  //#region src/review/patches.ts
13548
- var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$3, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$1, show$3;
13599
+ var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$3, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$2, show$3;
13549
13600
  var init_patches = __esmMin((() => {
13550
13601
  init_dist();
13551
13602
  init_patch();
13552
13603
  init_git();
13553
- init_error$2();
13604
+ init_error$3();
13554
13605
  init_branches$1();
13555
13606
  findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
13556
13607
  blobOf = (patches, file) => map$5(findPatch(patches, file), (patch) => patch.blob);
@@ -13661,12 +13712,12 @@ var init_patches = __esmMin((() => {
13661
13712
  });
13662
13713
  fileShown$1 = (worktree, generated) => (patch) => map$1(sourceShown(worktree, patch), (lines) => shownFile(patch, generated, lines));
13663
13714
  shownAs = (patch, lines) => shownFile(patch, /* @__PURE__ */ new Set(), lines);
13664
- onDisk$1 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13715
+ onDisk$2 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13665
13716
  show$3 = fn("Review.Diff.show")(function* (based, showing) {
13666
13717
  const git = yield* Git;
13667
13718
  const { worktree } = based;
13668
13719
  const patches$3 = yield* patches(worktree, linesAround(showing.context), showing.file);
13669
- const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$1(patches$3))], { concurrency: 2 });
13720
+ const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$2(patches$3))], { concurrency: 2 });
13670
13721
  return {
13671
13722
  branch: worktree.branch,
13672
13723
  base: based.base,
@@ -13926,21 +13977,79 @@ var init_quiet = __esmMin((() => {
13926
13977
  };
13927
13978
  }));
13928
13979
  //#endregion
13980
+ //#region src/domain/layers/text.ts
13981
+ var OFFSET, PRIME, hashOf, textOf, stamped, outdatedSpans;
13982
+ var init_text = __esmMin((() => {
13983
+ OFFSET = 2166136261;
13984
+ PRIME = 16777619;
13985
+ hashOf = (text) => {
13986
+ let hash = OFFSET;
13987
+ for (const unit of text) hash = Math.imul(hash ^ (unit.codePointAt(0) ?? 0), PRIME);
13988
+ return (hash >>> 0).toString(16).padStart(8, "0");
13989
+ };
13990
+ textOf = (lines, start, end) => hashOf(lines.slice(start - 1, end).join("\n"));
13991
+ stamped = (layers, sources) => layers.map((layer) => ({
13992
+ ...layer,
13993
+ blocks: layer.blocks.map((block) => block.kind === "code" ? {
13994
+ ...block,
13995
+ text: textOf(sources.get(block.path) ?? [], block.start, block.end)
13996
+ } : block)
13997
+ }));
13998
+ outdatedSpans = (layers, sources) => layers.flatMap((layer, at) => layer.blocks.flatMap((block) => {
13999
+ if (block.kind !== "code" || block.text === void 0) return [];
14000
+ const lines = sources.get(block.path);
14001
+ if (lines === void 0 || textOf(lines, block.start, block.end) === block.text) return [];
14002
+ return [{
14003
+ layer: at + 1,
14004
+ path: block.path,
14005
+ start: block.start,
14006
+ end: block.end
14007
+ }];
14008
+ }));
14009
+ }));
14010
+ //#endregion
14011
+ //#region src/domain/layers/split.ts
14012
+ var addedLines, claimsAny, sharedPaths, splitsIn;
14013
+ var init_split = __esmMin((() => {
14014
+ init_dist();
14015
+ init_coverage();
14016
+ addedLines = (patch) => patch.rows.filter((row) => row.kind === "added").flatMap((row) => toArray(row.newLine));
14017
+ claimsAny = (layer, path, lines) => codeBlocks(layer).some((block) => block.path === path && lines.some((line) => line >= block.start && line <= block.end));
14018
+ sharedPaths = (layers) => {
14019
+ const claimed = layers.flatMap((layer) => [...new Set(codeBlocks(layer).map((block) => block.path))]);
14020
+ return [...new Set(claimed.filter((path, at) => claimed.indexOf(path) !== at))];
14021
+ };
14022
+ splitsIn = (layers, patch, declarations) => {
14023
+ const added = addedLines(patch);
14024
+ return declarations.flatMap((declaration) => {
14025
+ const inside = added.filter((line) => line >= declaration.start && line <= declaration.end);
14026
+ const holding = layers.flatMap((layer, at) => claimsAny(layer, patch.path, inside) ? [at + 1] : []);
14027
+ return holding.length > 1 ? [{
14028
+ path: patch.path,
14029
+ ...declaration,
14030
+ layers: holding
14031
+ }] : [];
14032
+ });
14033
+ };
14034
+ }));
14035
+ //#endregion
13929
14036
  //#region src/domain/layers/index.ts
13930
14037
  var init_layers$1 = __esmMin((() => {
13931
14038
  init_coverage();
13932
14039
  init_version();
13933
14040
  init_quiet();
13934
14041
  init_model$3();
14042
+ init_text();
14043
+ init_split();
13935
14044
  }));
13936
14045
  //#endregion
13937
14046
  //#region src/review/placing.ts
13938
- var keptOf, baseOf, nowOnNew, nowOnOld, writtenName, unplaced, rewordedAt, standing, searched, keyOf$3, pairOf, unique$1, nowFor, placedWithout, placedThrough, placedFrom, placeOne, nowsOf, writtenOf, pairsOf, diffsOf, placedAll, versionOf;
14047
+ var keptOf$1, baseOf, nowOnNew, nowOnOld, writtenName, unplaced, rewordedAt, standing, searched, keyOf$3, pairOf, unique$1, nowFor, placedWithout, placedThrough, placedFrom, placeOne, nowsOf, writtenOf, pairsOf, diffsOf, placedAll, versionOf;
13939
14048
  var init_placing = __esmMin((() => {
13940
14049
  init_dist();
13941
14050
  init_patch();
13942
14051
  init_git();
13943
- keptOf = (found) => getOrElse(found, () => []);
14052
+ keptOf$1 = (found) => getOrElse(found, () => []);
13944
14053
  baseOf = (worktree) => worktree.base.length > 0 ? worktree.base : "HEAD";
13945
14054
  nowOnNew = fn("Review.Placing.nowOnNew")(function* (worktree, patch) {
13946
14055
  const git = yield* Git;
@@ -13948,7 +14057,7 @@ var init_placing = __esmMin((() => {
13948
14057
  version: none(),
13949
14058
  lines: []
13950
14059
  };
13951
- const lines = keptOf(yield* git.source(worktree, patch.path));
14060
+ const lines = keptOf$1(yield* git.source(worktree, patch.path));
13952
14061
  const [version] = yield* git.keep(worktree, [patch.path]);
13953
14062
  return {
13954
14063
  version: fromNullishOr(version),
@@ -13965,7 +14074,7 @@ var init_placing = __esmMin((() => {
13965
14074
  const version = yield* git.kept(worktree, named);
13966
14075
  return {
13967
14076
  version,
13968
- lines: isNone(version) ? [] : keptOf(yield* git.blob(worktree, patch.previousPath))
14077
+ lines: isNone(version) ? [] : keptOf$1(yield* git.blob(worktree, patch.previousPath))
13969
14078
  };
13970
14079
  });
13971
14080
  writtenName = (anchor) => anchor.version ?? (anchor.side === "new" ? anchor.blob : "");
@@ -14084,7 +14193,7 @@ var init_comments$1 = __esmMin((() => {
14084
14193
  init_git();
14085
14194
  init_layers$1();
14086
14195
  init_store();
14087
- init_error$2();
14196
+ init_error$3();
14088
14197
  init_branches$1();
14089
14198
  init_patches();
14090
14199
  init_placing();
@@ -14431,7 +14540,7 @@ var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf
14431
14540
  var init_threads$1 = __esmMin((() => {
14432
14541
  init_dist();
14433
14542
  init_store();
14434
- init_error$2();
14543
+ init_error$3();
14435
14544
  init_placing();
14436
14545
  init_review$1();
14437
14546
  ASK_LEAD = "About this branch, not about this line.";
@@ -14763,16 +14872,16 @@ var init_threads$1 = __esmMin((() => {
14763
14872
  //#endregion
14764
14873
  //#region src/service/forge/error.ts
14765
14874
  var ForgeUnavailable;
14766
- var init_error$1 = __esmMin((() => {
14875
+ var init_error$2 = __esmMin((() => {
14767
14876
  init_dist();
14768
14877
  ForgeUnavailable = class extends TaggedError("ForgeUnavailable") {};
14769
14878
  }));
14770
14879
  //#endregion
14771
14880
  //#region src/service/forge/service.ts
14772
14881
  var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask$1, show$2, whoseOf, pullOf, read$2, viewerOf, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$2, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked$1, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, address, ForgeLive;
14773
- var init_service = __esmMin((() => {
14882
+ var init_service$1 = __esmMin((() => {
14774
14883
  init_dist();
14775
- init_error$1();
14884
+ init_error$2();
14776
14885
  Forge = class extends Service()("adiff/Forge") {};
14777
14886
  LIMIT = "200";
14778
14887
  TIMEOUT_MS = 4e3;
@@ -15218,15 +15327,15 @@ var init_service = __esmMin((() => {
15218
15327
  //#endregion
15219
15328
  //#region src/service/forge/index.ts
15220
15329
  var init_forge = __esmMin((() => {
15221
- init_service();
15222
- init_error$1();
15330
+ init_service$1();
15331
+ init_error$2();
15223
15332
  })), VERSION, OPENING, CLOSING, heldOf$1, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
15224
15333
  var init_remarks$1 = __esmMin((() => {
15225
15334
  init_dist();
15226
15335
  init_patch();
15227
15336
  init_forge();
15228
15337
  init_store();
15229
- init_error$2();
15338
+ init_error$3();
15230
15339
  VERSION = 1;
15231
15340
  OPENING = /^```suggestion[^\n]*\n?/gm;
15232
15341
  CLOSING = /^```[ \t]*$/gm;
@@ -15466,14 +15575,14 @@ var init_remarks$1 = __esmMin((() => {
15466
15575
  }));
15467
15576
  //#endregion
15468
15577
  //#region src/review/vouching.ts
15469
- 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;
15578
+ 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, lapsedMarks, keptOf, stillRead, reportSince, isGone, goneSince, lapsedIn, sinceReview, progress, unchanged, markOf, since;
15470
15579
  var init_vouching$1 = __esmMin((() => {
15471
15580
  init_dist();
15472
15581
  init_patch();
15473
15582
  init_review$1();
15474
15583
  init_git();
15475
15584
  init_store();
15476
- init_error$2();
15585
+ init_error$3();
15477
15586
  init_branches$1();
15478
15587
  init_patches();
15479
15588
  pathOfMark = (mark) => mark.split("@")[0] ?? "";
@@ -15617,10 +15726,30 @@ var init_vouching$1 = __esmMin((() => {
15617
15726
  const since = yield* diffSince(worktree, patch.path, kept.value, 3);
15618
15727
  return untouchedParts(spans, patch.path, layersTouched(spans, patch.path, since));
15619
15728
  });
15620
- stillRead = fn("Review.Vouch.stillRead")(function* (reading, vouches, spans) {
15729
+ lapsedMarks = (patches, marks) => {
15730
+ const grouped = /* @__PURE__ */ new Map();
15731
+ for (const [key, blob] of Object.entries(marks)) {
15732
+ const patch = patches.find((one) => one.path === pathOfMark(key));
15733
+ if (patch === void 0 || sameBlob(blob, patch.blob)) continue;
15734
+ const held = grouped.get(`${patch.path}|${blob}`);
15735
+ grouped.set(`${patch.path}|${blob}`, {
15736
+ patch,
15737
+ blob,
15738
+ keys: [...held?.keys ?? [], key]
15739
+ });
15740
+ }
15741
+ return [...grouped.values()];
15742
+ };
15743
+ keptOf = (lapsed, untouched) => lapsed.keys.includes(lapsed.patch.path) ? untouched : untouched.filter((part) => lapsed.keys.includes(part));
15744
+ stillRead = fn("Review.Vouch.stillRead")(function* (reading, marks, spans) {
15621
15745
  if (spans.length === 0) return [];
15622
- const lapsed = reading.patches.filter((patch) => Object.hasOwn(vouches, patch.path) && !isVouched(vouches, patch.path, patch.blob));
15623
- return (yield* forEach(lapsed, (patch) => partsStillRead(reading.worktree, patch, vouches[patch.path] ?? "", spans), { concurrency: 8 })).flat();
15746
+ const lapsed = lapsedMarks(reading.patches, {
15747
+ ...marks.vouches,
15748
+ ...marks.parts
15749
+ });
15750
+ const keptIn = (one) => map$1(partsStillRead(reading.worktree, one.patch, one.blob, spans), (untouched) => keptOf(one, untouched));
15751
+ const found = yield* forEach(lapsed, keptIn, { concurrency: 8 });
15752
+ return [...new Set(found.flat())];
15624
15753
  });
15625
15754
  reportSince = fn("Review.Vouch.reportSince")(function* (worktree, asked, spans) {
15626
15755
  const git = yield* Git;
@@ -15679,7 +15808,7 @@ var init_vouching$1 = __esmMin((() => {
15679
15808
  const changed = changedSince([current.vouches, current.parts], files);
15680
15809
  return {
15681
15810
  vouched: files.filter((file) => isVouched(current.vouches, file.path, file.blob)).map((f) => f.path),
15682
- parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current.vouches, spans)],
15811
+ parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current, spans)],
15683
15812
  changed,
15684
15813
  since: yield* sinceReview(reading, current, changed, spans),
15685
15814
  total: reading.patches.length
@@ -15801,7 +15930,7 @@ var init_preferences = __esmMin((() => {
15801
15930
  init_dist();
15802
15931
  init_store();
15803
15932
  init_preferences$1();
15804
- init_error$2();
15933
+ init_error$3();
15805
15934
  list$1 = fn("Review.Preference.list")(function* () {
15806
15935
  const kept = yield* (yield* Store).settings;
15807
15936
  return preferences.map((one) => ({
@@ -15858,19 +15987,124 @@ var init_preferences = __esmMin((() => {
15858
15987
  });
15859
15988
  }));
15860
15989
  //#endregion
15990
+ //#region src/service/syntax/error.ts
15991
+ var GrammarUnreadable;
15992
+ var init_error$1 = __esmMin((() => {
15993
+ init_dist();
15994
+ GrammarUnreadable = class extends TaggedError("GrammarUnreadable") {};
15995
+ }));
15996
+ //#endregion
15997
+ //#region src/service/syntax/service.ts
15998
+ var Syntax, TYPESCRIPT, TSX, NAMED_FUNCTIONS, HOLDING_A_FUNCTION, FUNCTION_VALUES, besideThis$1, onDisk$1, embedded$1, compiled$1, started$1, readFrom, loaded, grammarsLoaded, grammarOf, holdsFunction, declared, declarationsUnder, parsed$1, functionsWith, makeSyntax, SyntaxLive;
15999
+ var init_service = __esmMin((() => {
16000
+ init_dist();
16001
+ init_error$1();
16002
+ Syntax = class extends Service()("adiff/Syntax") {};
16003
+ TYPESCRIPT = /\.[mc]?ts$/;
16004
+ TSX = /\.tsx$/;
16005
+ NAMED_FUNCTIONS = /* @__PURE__ */ new Set([
16006
+ "function_declaration",
16007
+ "generator_function_declaration",
16008
+ "method_definition"
16009
+ ]);
16010
+ HOLDING_A_FUNCTION = /* @__PURE__ */ new Set(["variable_declarator", "public_field_definition"]);
16011
+ FUNCTION_VALUES = /* @__PURE__ */ new Set([
16012
+ "arrow_function",
16013
+ "function_expression",
16014
+ "generator_function"
16015
+ ]);
16016
+ besideThis$1 = (path) => fileURLToPath(new URL(`./grammars/${path}`, import.meta.url));
16017
+ onDisk$1 = sync(() => ({
16018
+ runtime: void 0,
16019
+ typescript: besideThis$1("typescript/tree-sitter-typescript.wasm"),
16020
+ tsx: besideThis$1("tsx/tree-sitter-tsx.wasm")
16021
+ }));
16022
+ embedded$1 = all({
16023
+ runtime: promise(() => import("web-tree-sitter/tree-sitter.wasm", { with: { type: "file" } })),
16024
+ typescript: promise(() => import("./grammars/typescript/tree-sitter-typescript.wasm", { with: { type: "file" } })),
16025
+ tsx: promise(() => import("./grammars/tsx/tree-sitter-tsx.wasm", { with: { type: "file" } }))
16026
+ }).pipe(map$1((loaded) => ({
16027
+ runtime: loaded.runtime.default,
16028
+ typescript: loaded.typescript.default,
16029
+ tsx: loaded.tsx.default
16030
+ })));
16031
+ compiled$1 = () => process.versions["bun"] !== void 0;
16032
+ started$1 = (found) => found.runtime === void 0 ? Parser.init() : Parser.init({ locateFile: () => found.runtime ?? "" });
16033
+ readFrom = (path, load) => tryPromise({
16034
+ try: load,
16035
+ catch: (cause) => new GrammarUnreadable({
16036
+ path,
16037
+ reason: String(cause)
16038
+ })
16039
+ });
16040
+ loaded = fn("Syntax.loaded")(function* (found) {
16041
+ yield* readFrom(found.runtime ?? "web-tree-sitter", () => started$1(found));
16042
+ return yield* all({
16043
+ typescript: readFrom(found.typescript, () => Language.load(found.typescript)),
16044
+ tsx: readFrom(found.tsx, () => Language.load(found.tsx))
16045
+ }, { concurrency: "unbounded" });
16046
+ });
16047
+ grammarsLoaded = suspend(() => compiled$1() ? embedded$1 : onDisk$1).pipe(flatMap(loaded), option$2);
16048
+ grammarOf = (grammars, path) => {
16049
+ if (TSX.test(path)) return some(grammars.tsx);
16050
+ if (TYPESCRIPT.test(path)) return some(grammars.typescript);
16051
+ return none();
16052
+ };
16053
+ holdsFunction = (node) => {
16054
+ const value = node.childForFieldName("value");
16055
+ return value !== null && FUNCTION_VALUES.has(value.type);
16056
+ };
16057
+ declared = (node) => {
16058
+ const name = NAMED_FUNCTIONS.has(node.type) || HOLDING_A_FUNCTION.has(node.type) && holdsFunction(node) ? node.childForFieldName("name")?.text : void 0;
16059
+ if (name === void 0) return none();
16060
+ return some({
16061
+ name,
16062
+ start: node.startPosition.row + 1,
16063
+ end: node.endPosition.row + 1
16064
+ });
16065
+ };
16066
+ declarationsUnder = (node) => [...toArray(declared(node)), ...node.namedChildren.flatMap((child) => child === null ? [] : declarationsUnder(child))];
16067
+ parsed$1 = (language, lines) => {
16068
+ const parser = new Parser();
16069
+ parser.setLanguage(language);
16070
+ const tree = parser.parse(lines.join("\n"));
16071
+ const found = tree === null ? [] : declarationsUnder(tree.rootNode);
16072
+ tree?.delete();
16073
+ parser.delete();
16074
+ return found;
16075
+ };
16076
+ functionsWith = (grammars) => (path, lines) => map$1(grammars, (ready) => match$3(flatMap$2(ready, (loadedGrammars) => grammarOf(loadedGrammars, path)), {
16077
+ onNone: () => [],
16078
+ onSome: (language) => parsed$1(language, lines)
16079
+ }));
16080
+ makeSyntax = fn("Syntax.make")(function* () {
16081
+ const grammars = yield* cached(grammarsLoaded);
16082
+ return { functions: functionsWith(grammars) };
16083
+ });
16084
+ SyntaxLive = effect(Syntax)(makeSyntax());
16085
+ }));
16086
+ //#endregion
16087
+ //#region src/service/syntax/index.ts
16088
+ var init_syntax = __esmMin((() => {
16089
+ init_service();
16090
+ }));
16091
+ //#endregion
15861
16092
  //#region src/review/layers.ts
15862
- 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, quietRow, quietFile, tagRows, read, partsOfFile, vouchPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn;
16093
+ var STALE_ADVICE, OUTDATED_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, partIn, reportedLayers, adviceOf, reportOf, pathsOfLayer, sourcesOf, changedSinceWritten, outdatedIn, splitsFound, 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, quietRow, quietFile, tagRows, read, partsOfFile, vouchPart, carriedStamps, unmarkedPart, markedPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn;
15863
16094
  var init_layers = __esmMin((() => {
15864
16095
  init_dist();
15865
16096
  init_layers$1();
16097
+ init_git();
16098
+ init_syntax();
15866
16099
  init_store();
15867
16100
  init_review$1();
15868
- init_error$2();
16101
+ init_error$3();
15869
16102
  init_comments$1();
15870
16103
  init_threads$1();
15871
16104
  init_branches$1();
15872
16105
  init_vouching$1();
15873
16106
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
16107
+ OUTDATED_ADVICE = "The code under the outdated spans changed after these layers were written. Read those lines again and write a new revision with layers set.";
15874
16108
  unique = (paths) => [...new Set(paths)];
15875
16109
  spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
15876
16110
  path,
@@ -15993,15 +16227,19 @@ var init_layers = __esmMin((() => {
15993
16227
  };
15994
16228
  });
15995
16229
  };
15996
- reportOf = (patches, layers, branchHead) => {
16230
+ adviceOf = (moved, outdated) => {
16231
+ if (moved) return { advice: STALE_ADVICE };
16232
+ return outdated.length > 0 ? { advice: OUTDATED_ADVICE } : {};
16233
+ };
16234
+ reportOf = (patches, layers, branchHead, outdated = []) => {
15997
16235
  const status = statusOf(patches, layers, branchHead);
15998
16236
  return {
15999
16237
  version: status.version,
16000
16238
  parent: getOrUndefined$1(status.parent),
16001
16239
  head: status.layersHead,
16002
16240
  branchHead: status.branchHead,
16003
- stale: status.stale,
16004
- ...status.stale ? { advice: STALE_ADVICE } : {},
16241
+ stale: status.stale || outdated.length > 0,
16242
+ ...adviceOf(status.stale, outdated),
16005
16243
  written: layers.written,
16006
16244
  summary: layers.summary,
16007
16245
  covered: status.covered,
@@ -16009,10 +16247,36 @@ var init_layers = __esmMin((() => {
16009
16247
  total: status.total,
16010
16248
  uncovered: status.uncovered,
16011
16249
  shared: sharedHunks(patches, layers.layers),
16250
+ split: layers.split ?? [],
16012
16251
  vanished: status.vanished,
16252
+ outdated,
16013
16253
  layers: reportedLayers(patches, layers)
16014
16254
  };
16015
16255
  };
16256
+ pathsOfLayer = (layer) => codeBlocks(layer).map((block) => block.path);
16257
+ sourcesOf = fn("Review.Layers.sourcesOf")(function* (worktree, paths) {
16258
+ const git = yield* Git;
16259
+ const read = fn("Review.Layers.sourceOf")(function* (path) {
16260
+ const lines = yield* git.source(worktree, path);
16261
+ return [path, getOrUndefined$1(lines) ?? []];
16262
+ });
16263
+ return new Map(yield* forEach(paths, read, { concurrency: 8 }));
16264
+ });
16265
+ changedSinceWritten = (patches, layers) => Object.entries(layers.blobs ?? {}).filter(([path, blob]) => {
16266
+ const now = patches.find((patch) => patch.path === path);
16267
+ return now !== void 0 && !sameBlob(now.blob, blob);
16268
+ }).map(([path]) => path);
16269
+ outdatedIn = fn("Review.Layers.outdatedIn")(function* (worktree, patches, layers) {
16270
+ const changed = changedSinceWritten(patches, layers);
16271
+ if (changed.length === 0) return [];
16272
+ return outdatedSpans(layers.layers, yield* sourcesOf(worktree, changed));
16273
+ });
16274
+ splitsFound = fn("Review.Layers.splitsFound")(function* (patches, layers, sources) {
16275
+ const syntax = yield* Syntax;
16276
+ const shared = new Set(sharedPaths(layers));
16277
+ const splitIn = (patch) => map$1(syntax.functions(patch.path, sources.get(patch.path) ?? []), (found) => splitsIn(layers, patch, found));
16278
+ return (yield* forEach(patches.filter((patch) => shared.has(patch.path)), splitIn)).flat();
16279
+ });
16016
16280
  storedLayers = fn("Review.Layers.storedLayers")(function* (worktree) {
16017
16281
  const store = yield* Store;
16018
16282
  return map$5(yield* store.layers(worktree.path), fromStored);
@@ -16022,6 +16286,8 @@ var init_layers = __esmMin((() => {
16022
16286
  const input = yield* readLayers(text);
16023
16287
  const patches$1 = yield* patches(worktree);
16024
16288
  const previous = yield* storedLayers(worktree);
16289
+ const paths = unique(input.layers.flatMap(pathsOfLayer));
16290
+ const sources = yield* sourcesOf(worktree, paths);
16025
16291
  const layers = {
16026
16292
  version: match$3(previous, {
16027
16293
  onNone: () => 1,
@@ -16032,7 +16298,9 @@ var init_layers = __esmMin((() => {
16032
16298
  base: worktree.base,
16033
16299
  written,
16034
16300
  summary: input.summary,
16035
- layers: input.layers
16301
+ layers: stamped(input.layers, sources),
16302
+ blobs: Object.fromEntries(patches$1.filter((patch) => sources.has(patch.path)).map((patch) => [patch.path, patch.blob])),
16303
+ split: yield* splitsFound(patches$1, input.layers, sources)
16036
16304
  };
16037
16305
  yield* store.saveLayers(worktree.path, toStored(layers));
16038
16306
  return reportOf(patches$1, layers, worktree.head);
@@ -16100,12 +16368,13 @@ var init_layers = __esmMin((() => {
16100
16368
  path: patch.path,
16101
16369
  blob: patch.blob
16102
16370
  }));
16103
- const report = reportOf(reading.patches, found.value, reading.worktree.head);
16371
+ const outdated = yield* outdatedIn(reading.worktree, reading.patches, found.value);
16372
+ const report = reportOf(reading.patches, found.value, reading.worktree.head, outdated);
16104
16373
  const spans = report.layers.map((layer) => layer.spans);
16105
16374
  return some(withRead(report, {
16106
16375
  patches: reading.patches,
16107
16376
  vouches: current.vouches,
16108
- parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current.vouches, spans)]
16377
+ parts: [...readParts(current.parts, files), ...yield* stillRead(reading, current, spans)]
16109
16378
  }));
16110
16379
  });
16111
16380
  view = fn("Review.Layers.view")(function* (reading) {
@@ -16195,9 +16464,10 @@ var init_layers = __esmMin((() => {
16195
16464
  stale: false,
16196
16465
  summary: ""
16197
16466
  };
16467
+ const outdated = yield* outdatedIn(worktree, reading.patches, found.value);
16198
16468
  return {
16199
16469
  layers: reportedLayers(reading.patches, found.value),
16200
- stale: found.value.head !== worktree.head,
16470
+ stale: found.value.head !== worktree.head || outdated.length > 0,
16201
16471
  rebased: found.value.base !== worktree.base,
16202
16472
  summary: found.value.summary
16203
16473
  };
@@ -16214,32 +16484,75 @@ var init_layers = __esmMin((() => {
16214
16484
  });
16215
16485
  const blob = yield* fullBlob(reading.worktree, asked);
16216
16486
  const held = yield* read(reading);
16217
- const wanted = partsOfFile(held.layers, file);
16487
+ const spans = held.layers.map((layer) => layer.spans);
16218
16488
  const current = yield* store.state(reading.worktree.path);
16219
- const parts = vouchPart$1(current.parts, part, blob);
16220
- const vouches = (wanted.length > 0 && wanted.every((one) => isPartVouched(parts, one, blob))) === isVouched(current.vouches, file, blob) ? current.vouches : vouch$1(current.vouches, file, blob);
16489
+ const readBefore = yield* stillRead(reading, current, spans);
16490
+ const next = readBefore.includes(part) && !isPartVouched(current.parts, part, blob) ? unmarkedPart(current, file, part, readBefore) : yield* markedPart(reading, current, {
16491
+ file,
16492
+ part,
16493
+ blob,
16494
+ wanted: partsOfFile(held.layers, file),
16495
+ spans
16496
+ });
16221
16497
  yield* store.changeState(reading.worktree.path, (was) => ({
16222
16498
  ...was,
16223
- parts,
16224
- vouches,
16225
- vouchedAt: restamped(was.vouchedAt, {
16226
- ...was.vouches,
16227
- ...was.parts
16228
- }, {
16229
- ...vouches,
16230
- ...parts
16231
- }, at)
16499
+ parts: next.parts,
16500
+ vouches: next.vouches,
16501
+ vouchedAt: {
16502
+ ...restamped(was.vouchedAt, {
16503
+ ...was.vouches,
16504
+ ...was.parts
16505
+ }, {
16506
+ ...next.vouches,
16507
+ ...next.parts
16508
+ }, at),
16509
+ ...carriedStamps(next.carried, was.vouchedAt[file] ?? at)
16510
+ }
16232
16511
  }));
16233
16512
  const files = reading.patches.map((one) => ({
16234
16513
  path: one.path,
16235
16514
  blob: one.blob
16236
16515
  }));
16516
+ const readAfter = yield* stillRead(reading, next, spans);
16237
16517
  return {
16238
- vouched: files.filter((one) => isVouched(vouches, one.path, one.blob)).map((one) => one.path),
16239
- parts: readParts(parts, files),
16518
+ vouched: files.filter((one) => isVouched(next.vouches, one.path, one.blob)).map((one) => one.path),
16519
+ parts: [.../* @__PURE__ */ new Set([...readParts(next.parts, files), ...readAfter])],
16240
16520
  total: reading.patches.length
16241
16521
  };
16242
16522
  });
16523
+ carriedStamps = (carried, at) => Object.fromEntries(carried.map((key) => [key, at]));
16524
+ unmarkedPart = (current, file, part, readBefore) => {
16525
+ const { [part]: _unmarked, ...parts } = current.parts;
16526
+ const lapsed = current.vouches[file];
16527
+ if (lapsed === void 0) return {
16528
+ vouches: current.vouches,
16529
+ parts,
16530
+ carried: []
16531
+ };
16532
+ const { [file]: _whole, ...vouches } = current.vouches;
16533
+ const carried = readBefore.filter((one) => one !== part && one.startsWith(`${file}@`) && !Object.hasOwn(parts, one));
16534
+ return {
16535
+ vouches,
16536
+ parts: {
16537
+ ...parts,
16538
+ ...Object.fromEntries(carried.map((one) => [one, lapsed]))
16539
+ },
16540
+ carried
16541
+ };
16542
+ };
16543
+ markedPart = fn("Review.Layers.markedPart")(function* (reading, current, pressed) {
16544
+ const { file, blob } = pressed;
16545
+ const parts = vouchPart$1(current.parts, pressed.part, blob);
16546
+ const kept = yield* stillRead(reading, {
16547
+ vouches: current.vouches,
16548
+ parts
16549
+ }, pressed.spans);
16550
+ return {
16551
+ vouches: (pressed.wanted.length > 0 && pressed.wanted.every((one) => isPartVouched(parts, one, blob) || kept.includes(one))) === isVouched(current.vouches, file, blob) ? current.vouches : vouch$1(current.vouches, file, blob),
16552
+ parts,
16553
+ carried: []
16554
+ };
16555
+ });
16243
16556
  askingFor = (told) => {
16244
16557
  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.`;
16245
16558
  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\`.`;
@@ -16311,7 +16624,7 @@ var init_drafts$1 = __esmMin((() => {
16311
16624
  init_dist();
16312
16625
  init_forge();
16313
16626
  init_store();
16314
- init_error$2();
16627
+ init_error$3();
16315
16628
  init_patches();
16316
16629
  unreadIn = (draft, seen) => {
16317
16630
  if (draft.wroteBy !== "agent") return false;
@@ -16659,7 +16972,7 @@ var show;
16659
16972
  var init_pulls = __esmMin((() => {
16660
16973
  init_dist();
16661
16974
  init_forge();
16662
- init_error$2();
16975
+ init_error$3();
16663
16976
  show = fn("Review.Pull.show")(function* (repo, branch) {
16664
16977
  const forge = yield* Forge;
16665
16978
  const found = (yield* forge.pulls(repo)).find((pull) => pull.branch === branch);
@@ -16690,7 +17003,7 @@ var init_review = __esmMin((() => {
16690
17003
  init_drafts$1();
16691
17004
  init_search$1();
16692
17005
  init_pulls();
16693
- init_error$2();
17006
+ init_error$3();
16694
17007
  }));
16695
17008
  //#endregion
16696
17009
  //#region src/cli/help.ts
@@ -26472,6 +26785,7 @@ init_dist();
26472
26785
  init_cli();
26473
26786
  init_review();
26474
26787
  init_git();
26788
+ init_syntax();
26475
26789
  init_forge();
26476
26790
  init_store();
26477
26791
  const WAIT_UNIT = 1e3;
@@ -26525,7 +26839,7 @@ const commentSend = fn("Main.commentSend")(function* (options) {
26525
26839
  const worktree = yield* worktreeIn(options);
26526
26840
  const batch = yield* submit(worktree, {
26527
26841
  ...yield* rangeIn(options, worktree),
26528
- body: yield* required(options, "body"),
26842
+ body: yield* text$1(options, "body"),
26529
26843
  id: options["id"] ?? randomUUID(),
26530
26844
  at: stamp(options)
26531
26845
  });
@@ -26539,7 +26853,7 @@ const draftAdd = fn("Main.draftAdd")(function* (options) {
26539
26853
  const worktree = yield* worktreeIn(options);
26540
26854
  const draft = yield* add$1(worktree, {
26541
26855
  ...yield* rangeIn(options, worktree),
26542
- body: yield* required(options, "body"),
26856
+ body: yield* text$1(options, "body"),
26543
26857
  id: options["id"] ?? randomUUID(),
26544
26858
  at: stamp(options),
26545
26859
  wroteBy: "agent"
@@ -26549,7 +26863,7 @@ const draftAdd = fn("Main.draftAdd")(function* (options) {
26549
26863
  const draftEdit = fn("Main.draftEdit")(function* (options) {
26550
26864
  const draft = yield* edit(yield* worktreeIn(options), {
26551
26865
  id: yield* required(options, "id"),
26552
- body: yield* required(options, "body"),
26866
+ body: yield* text$1(options, "body"),
26553
26867
  at: stamp(options),
26554
26868
  by: "agent"
26555
26869
  });
@@ -26566,7 +26880,7 @@ const draftSend = fn("Main.draftSend")(function* (options) {
26566
26880
  const commentReply = fn("Main.commentReply")(function* (options) {
26567
26881
  const batch = yield* reply(yield* worktreeIn(options), {
26568
26882
  to: yield* required(options, "to"),
26569
- body: yield* required(options, "body"),
26883
+ body: yield* text$1(options, "body"),
26570
26884
  id: options["id"] ?? randomUUID(),
26571
26885
  at: stamp(options)
26572
26886
  });
@@ -26588,7 +26902,7 @@ const commentTake = fn("Main.commentTake")(function* (options) {
26588
26902
  const commentAnswer = fn("Main.commentAnswer")(function* (options) {
26589
26903
  const report = yield* answer$3(yield* worktreeNamed(options), {
26590
26904
  id: yield* required(options, "id"),
26591
- body: yield* required(options, "body"),
26905
+ body: yield* text$1(options, "body"),
26592
26906
  asks: options["question"] !== void 0,
26593
26907
  at: stamp(options),
26594
26908
  choices: yield* choices(options, "choice")
@@ -26610,14 +26924,14 @@ const remarkList = fn("Main.remarkList")(function* (options) {
26610
26924
  const remarkAccept = fn("Main.remarkAccept")(function* (options) {
26611
26925
  const report = yield* accept(yield* readingIn(options), {
26612
26926
  id: yield* required(options, "id"),
26613
- body: options["body"],
26927
+ body: options["body"] === void 0 ? void 0 : yield* text$1(options, "body"),
26614
26928
  at: stamp(options),
26615
26929
  commentId: options["comment"] ?? randomUUID()
26616
26930
  });
26617
26931
  yield* answer(options, report);
26618
26932
  });
26619
26933
  const remarkReply = fn("Main.remarkReply")(function* (options) {
26620
- const report = yield* answer$1(yield* required(options, "repo"), yield* worktreeIn(options), yield* required(options, "id"), yield* required(options, "body"));
26934
+ const report = yield* answer$1(yield* required(options, "repo"), yield* worktreeIn(options), yield* required(options, "id"), yield* text$1(options, "body"));
26621
26935
  yield* answer(options, { answered: report.answered });
26622
26936
  });
26623
26937
  const remarkDismiss = fn("Main.remarkDismiss")(function* (options) {
@@ -26971,7 +27285,7 @@ if (said !== void 0) {
26971
27285
  process.stdout.write(`${said}\n`);
26972
27286
  process.exit(0);
26973
27287
  }
26974
- const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot())).pipe(provideMerge(GitLive));
27288
+ const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot()), SyntaxLive).pipe(provideMerge(GitLive));
26975
27289
  const reportFailure = (cause) => sync(() => {
26976
27290
  const reported = failure(squash(cause));
26977
27291
  process.stderr.write(`${reported.line}\n`);
package/package.json CHANGED
@@ -15,7 +15,8 @@
15
15
  "typescript": "^7.0.2"
16
16
  },
17
17
  "dependencies": {
18
- "@opentui/core": "^0.4.5"
18
+ "@opentui/core": "^0.4.5",
19
+ "web-tree-sitter": "0.25.10"
19
20
  },
20
21
  "engines": {
21
22
  "node": ">=22"
@@ -23,7 +24,7 @@
23
24
  "bin": {
24
25
  "adiff": "./bin/adiff.js"
25
26
  },
26
- "version": "0.1.0-alpha.203",
27
+ "version": "0.1.0-alpha.205",
27
28
  "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
29
  "license": "MIT",
29
30
  "repository": {
@@ -343,8 +343,15 @@ reviewer asks for another.
343
343
  reading order whose layers each claim the whole diff reports the same `covered` as one whose layers
344
344
  each claim their own run. Done means `uncovered` is empty **and** `shared` is zero.
345
345
 
346
+ `split` in the answer names each TypeScript or TSX function, method or function-valued constant
347
+ whose changed lines your layers cut between two or more layers, with its lines and those layers. A
348
+ reviewer reads half of it in one layer and the rest in another, so move the boundary until `split`
349
+ is empty. Count spans on the file as it is on disk now, never on a committed copy you have since
350
+ edited: spans counted on other text cover the right number of lines and still cut the wrong code.
351
+
346
352
  Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
347
- was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
353
+ was written for and the text each span held, and adiff reports it as `stale` once the branch moves
354
+ past that commit or the code under a span changes. `outdated` names each span whose lines changed. Once a
348
355
  reviewer has a reading order, keep it true, as the next section says.
349
356
 
350
357
  When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
@@ -358,13 +365,14 @@ Once a branch has layers, check them after each change you make (a commit, an an
358
365
  rebase) and before you say the work is ready:
359
366
 
360
367
  ```bash
361
- adiff layers show --worktree . --fields stale,uncovered,shared,vanished
368
+ adiff layers show --worktree . --fields stale,uncovered,shared,vanished,outdated,split
362
369
  ```
363
370
 
364
- If `uncovered` is not empty, `stale` is true or `vanished` names a path, write a new revision with
371
+ If `uncovered` is not empty, `stale` is true, `vanished` names a path, `outdated` names a span or
372
+ `split` names a function, write a new revision with
365
373
  `adiff layers set` right away. Put new runs into the layer whose claim they serve, and add a final
366
374
  layer only for lines that serve none. When the base moved, read the diff again rather than patching
367
- line numbers. Done means `uncovered` is empty and `shared` is zero.
375
+ line numbers. Done means `uncovered` is empty, `shared` is zero and `split` is empty.
368
376
 
369
377
  Do it silently: it is upkeep, not news, so do not ask first and do not report it unless the reviewer
370
378
  asks. `NoLayers` (exit 3) means the branch has no reading order, and then you write one only when