@eliya-oss/agent-diff 0.1.0-alpha.204 → 0.1.0-alpha.206

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/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,16 +10114,17 @@ 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.204";
10117
+ var version$1 = "0.1.0-alpha.206";
10087
10118
  //#endregion
10088
10119
  //#region src/cli/error.ts
10089
- var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10090
- var init_error$5 = __esmMin((() => {
10120
+ var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10121
+ var init_error$6 = __esmMin((() => {
10091
10122
  init_dist();
10092
10123
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
10093
10124
  MissingOption = class extends TaggedError("MissingOption") {};
10094
10125
  UnknownField = class extends TaggedError("UnknownField") {};
10095
10126
  UnknownOption = class extends TaggedError("UnknownOption") {};
10127
+ RemovedOption = class extends TaggedError("RemovedOption") {};
10096
10128
  BadOption = class extends TaggedError("BadOption") {};
10097
10129
  RegistryUnanswered = class extends TaggedError("RegistryUnanswered") {};
10098
10130
  NotServed = class extends TaggedError("NotServed") {};
@@ -10103,7 +10135,7 @@ var init_error$5 = __esmMin((() => {
10103
10135
  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
10136
  var init_upgrade$1 = __esmMin((() => {
10105
10137
  init_dist();
10106
- init_error$5();
10138
+ init_error$6();
10107
10139
  PACKAGE = "@eliya-oss/agent-diff";
10108
10140
  TAG = "alpha";
10109
10141
  RELEASES = "https://github.com/Newbie012/agent-diff/releases/latest";
@@ -10291,7 +10323,7 @@ var init_upgrade$1 = __esmMin((() => {
10291
10323
  }));
10292
10324
  //#endregion
10293
10325
  //#region src/cli/catalog.ts
10294
- var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, picking, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10326
+ var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, picking, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, RETIRED, retiredOf, removedIn, retiredIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10295
10327
  var init_catalog = __esmMin((() => {
10296
10328
  WAIT_MOST = 86400;
10297
10329
  worktreeOf$1 = {
@@ -10614,23 +10646,14 @@ var init_catalog = __esmMin((() => {
10614
10646
  group: ANSWER_COMMENTS,
10615
10647
  addresses: "review",
10616
10648
  safety: "read",
10617
- options: [
10618
- ...addressing,
10619
- {
10620
- name: "wait",
10621
- required: false,
10622
- value: "seconds",
10623
- about: `Block until a comment arrives or the timeout elapses. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10624
- },
10625
- {
10626
- name: "new",
10627
- required: false,
10628
- value: "flag",
10629
- about: "Hand over only comments this review has not handed over before, so a wait ends on something new"
10630
- }
10631
- ],
10649
+ options: [...addressing, {
10650
+ name: "wait",
10651
+ required: false,
10652
+ value: "seconds",
10653
+ about: `Block until a comment this review has not handed over before arrives, or the timeout elapses. One wait listens per worktree: a newer wait ends this one, which then answers with replaced. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10654
+ }],
10632
10655
  dataKey: "comments",
10633
- example: "adiff comment take --worktree . --new --wait 6900"
10656
+ example: "adiff comment take --worktree . --wait 6900"
10634
10657
  },
10635
10658
  {
10636
10659
  name: "comment answer",
@@ -11105,6 +11128,20 @@ var init_catalog = __esmMin((() => {
11105
11128
  "quiet"
11106
11129
  ];
11107
11130
  valuedIn = (name) => /* @__PURE__ */ new Set([...VALUED_ANYWHERE, ...(findCommand(name)?.options ?? []).filter((option) => option.value !== "flag").map((option) => option.name)]);
11131
+ RETIRED = { "comment take": { new: {
11132
+ reason: "A take with no --wait hands over every comment still owed an answer. To hand over only new comments, give --wait: every wait does that now.",
11133
+ meantWith: "wait"
11134
+ } } };
11135
+ retiredOf = (name) => RETIRED[name] ?? {};
11136
+ removedIn = (name, given) => {
11137
+ const retired = retiredOf(name);
11138
+ const option = given.find((one) => Object.hasOwn(retired, one) && !given.includes(retired[one]?.meantWith ?? ""));
11139
+ return option === void 0 ? void 0 : {
11140
+ option,
11141
+ reason: retired[option]?.reason ?? ""
11142
+ };
11143
+ };
11144
+ retiredIn = (name, given) => given.filter((one) => Object.hasOwn(retiredOf(name), one));
11108
11145
  knownIn = (name) => /* @__PURE__ */ new Set([...KNOWN_ANYWHERE, ...(findCommand(name)?.options ?? []).map((option) => option.name)]);
11109
11146
  verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
11110
11147
  groups = [...new Set(catalog.map((command) => command.group))];
@@ -11142,7 +11179,7 @@ var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, on
11142
11179
  var init_parse$1 = __esmMin((() => {
11143
11180
  init_dist();
11144
11181
  init_catalog();
11145
- init_error$5();
11182
+ init_error$6();
11146
11183
  FLAG = /^--(?<name>[^=]+)(?:=(?<value>[\s\S]*))?$/;
11147
11184
  REPEATED = /* @__PURE__ */ new Set(["choice"]);
11148
11185
  MANY = "\n";
@@ -11402,6 +11439,11 @@ var init_report$1 = __esmMin((() => {
11402
11439
  suggestion: "That option is not one this command takes. `adiff <command> --help` lists the options it does.",
11403
11440
  retriable: false
11404
11441
  },
11442
+ RemovedOption: {
11443
+ exit: 2,
11444
+ suggestion: "This command no longer takes that option. Run it again without the option; the reason is named above.",
11445
+ retriable: false
11446
+ },
11405
11447
  BadOption: {
11406
11448
  exit: 2,
11407
11449
  suggestion: "That value is not one the option allows. The allowed ones are named above.",
@@ -11540,10 +11582,10 @@ var init_report$1 = __esmMin((() => {
11540
11582
  }));
11541
11583
  //#endregion
11542
11584
  //#region src/cli/serve.ts
11543
- var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11585
+ var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, heldOpen, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11544
11586
  var init_serve = __esmMin((() => {
11545
11587
  init_dist();
11546
- init_error$5();
11588
+ init_error$6();
11547
11589
  init_report$1();
11548
11590
  init_parse$1();
11549
11591
  init_catalog();
@@ -11581,8 +11623,10 @@ var init_serve = __esmMin((() => {
11581
11623
  "outbox.jsonl": "comments",
11582
11624
  "state.json": "state",
11583
11625
  "layers.json": "layers",
11584
- "watch.json": "watch"
11626
+ "watch.json": "watch",
11627
+ "wait.json": "watch"
11585
11628
  };
11629
+ heldOpen = (name) => name !== null && name.endsWith(".lock");
11586
11630
  kindOf = (name) => {
11587
11631
  if (name === null) return "other";
11588
11632
  const file = Object.keys(KIND_OF).find((known) => name === known || name.startsWith(`${known}.`));
@@ -11598,6 +11642,7 @@ var init_serve = __esmMin((() => {
11598
11642
  tell(what);
11599
11643
  };
11600
11644
  const watcher = watch(folder, (_event, name) => {
11645
+ if (heldOpen(name)) return;
11601
11646
  seen.add(kindOf(name));
11602
11647
  if (timer !== void 0) clearTimeout(timer);
11603
11648
  timer = setTimeout(told, SETTLE_MS$1);
@@ -11682,7 +11727,7 @@ var init_cli = __esmMin((() => {
11682
11727
  init_parse$1();
11683
11728
  init_catalog();
11684
11729
  init_report$1();
11685
- init_error$5();
11730
+ init_error$6();
11686
11731
  init_serve();
11687
11732
  }));
11688
11733
  //#endregion
@@ -12272,7 +12317,7 @@ var init_patch = __esmMin((() => {
12272
12317
  //#endregion
12273
12318
  //#region src/service/git/error.ts
12274
12319
  var GitCommandFailed, NotARepository, FileUnreadable;
12275
- var init_error$4 = __esmMin((() => {
12320
+ var init_error$5 = __esmMin((() => {
12276
12321
  init_dist();
12277
12322
  GitCommandFailed = class extends TaggedError("GitCommandFailed") {};
12278
12323
  NotARepository = class extends TaggedError("NotARepository") {};
@@ -12283,7 +12328,7 @@ var init_error$4 = __esmMin((() => {
12283
12328
  var exec, MAX_OUTPUT, git, gitOrEmpty;
12284
12329
  var init_run = __esmMin((() => {
12285
12330
  init_dist();
12286
- init_error$4();
12331
+ init_error$5();
12287
12332
  exec = promisify(execFile);
12288
12333
  MAX_OUTPUT = 67108864;
12289
12334
  git = fn("Git.run")(function* (cwd, args) {
@@ -12305,9 +12350,9 @@ var init_run = __esmMin((() => {
12305
12350
  return yield* git(cwd, args).pipe(catchTag("GitCommandFailed", () => succeed$1("")));
12306
12351
  });
12307
12352
  })), 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;
12308
- var init_service$2 = __esmMin((() => {
12353
+ var init_service$3 = __esmMin((() => {
12309
12354
  init_dist();
12310
- init_error$4();
12355
+ init_error$5();
12311
12356
  init_run();
12312
12357
  CACHE_SIZE = 256;
12313
12358
  NAME_TTL = "5 minutes";
@@ -12654,13 +12699,13 @@ var init_service$2 = __esmMin((() => {
12654
12699
  //#endregion
12655
12700
  //#region src/service/git/index.ts
12656
12701
  var init_git = __esmMin((() => {
12657
- init_service$2();
12658
- init_error$4();
12702
+ init_service$3();
12703
+ init_error$5();
12659
12704
  }));
12660
12705
  //#endregion
12661
12706
  //#region src/service/store/error.ts
12662
12707
  var StoreUnwritable, StoreUnreadable;
12663
- var init_error$3 = __esmMin((() => {
12708
+ var init_error$4 = __esmMin((() => {
12664
12709
  init_dist();
12665
12710
  StoreUnwritable = class extends TaggedError("StoreUnwritable") {};
12666
12711
  StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
@@ -12687,7 +12732,7 @@ var init_model$4 = __esmMin((() => {
12687
12732
  }));
12688
12733
  //#endregion
12689
12734
  //#region src/service/store/schema.ts
12690
- var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, UpgradeCheck, Prose, Code$1, StoredLayer, StoredLayers;
12735
+ var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, Listening, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredLayers;
12691
12736
  var init_schema = __esmMin((() => {
12692
12737
  init_dist();
12693
12738
  Side = Literals(["old", "new"]);
@@ -12793,6 +12838,10 @@ var init_schema = __esmMin((() => {
12793
12838
  editor: optionalKey(String$1)
12794
12839
  });
12795
12840
  Watching = Struct({ lookedAt: String$1 });
12841
+ Listening = Struct({
12842
+ wait: String$1,
12843
+ since: String$1
12844
+ });
12796
12845
  UpgradeCheck = Struct({
12797
12846
  note: optionalKey(String$1),
12798
12847
  checkedAt: optionalKey(String$1),
@@ -12807,7 +12856,15 @@ var init_schema = __esmMin((() => {
12807
12856
  kind: Literal("code"),
12808
12857
  path: String$1,
12809
12858
  start: Int,
12810
- end: Int
12859
+ end: Int,
12860
+ text: optionalKey(String$1)
12861
+ });
12862
+ Split = Struct({
12863
+ path: String$1,
12864
+ name: String$1,
12865
+ start: Int,
12866
+ end: Int,
12867
+ layers: ArraySchema(Int)
12811
12868
  });
12812
12869
  StoredLayer = Struct({
12813
12870
  title: String$1,
@@ -12820,12 +12877,14 @@ var init_schema = __esmMin((() => {
12820
12877
  parent: optionalKey(UndefinedOr(Int)),
12821
12878
  written: String$1,
12822
12879
  summary: String$1,
12823
- layers: ArraySchema(StoredLayer)
12880
+ layers: ArraySchema(StoredLayer),
12881
+ blobs: optionalKey(Record(String$1, String$1)),
12882
+ split: optionalKey(ArraySchema(Split))
12824
12883
  });
12825
12884
  }));
12826
12885
  //#endregion
12827
12886
  //#region src/service/store/paths.ts
12828
- var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, watchPath, draftsPath, layersPath, remarksPath, settingsPath, upgradePath, reportsDir, reportPath;
12887
+ var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, watchPath, waitPath, draftsPath, layersPath, remarksPath, settingsPath, upgradePath, reportsDir, reportPath;
12829
12888
  var init_paths = __esmMin((() => {
12830
12889
  NON_SLUG = /[^a-zA-Z0-9]+/g;
12831
12890
  slugOf = (worktreePath) => worktreePath.replace(NON_SLUG, "-");
@@ -12835,6 +12894,7 @@ var init_paths = __esmMin((() => {
12835
12894
  outboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "outbox.jsonl");
12836
12895
  statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
12837
12896
  watchPath = (root, worktreePath) => join(branchDir(root, worktreePath), "watch.json");
12897
+ waitPath = (root, worktreePath) => join(branchDir(root, worktreePath), "wait.json");
12838
12898
  draftsPath = (root, worktreePath) => join(branchDir(root, worktreePath), "drafts.json");
12839
12899
  layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
12840
12900
  remarksPath = (root, worktreePath) => join(branchDir(root, worktreePath), "remarks.json");
@@ -12845,11 +12905,11 @@ var init_paths = __esmMin((() => {
12845
12905
  }));
12846
12906
  //#endregion
12847
12907
  //#region src/service/store/service.ts
12848
- 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;
12849
- var init_service$1 = __esmMin((() => {
12908
+ 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, asListening, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, parseRemarks, idsIn$1, takes, handedOps, cursorOps, waitOps, 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;
12909
+ var init_service$2 = __esmMin((() => {
12850
12910
  init_dist();
12851
12911
  init_git();
12852
- init_error$3();
12912
+ init_error$4();
12853
12913
  init_model$4();
12854
12914
  init_schema();
12855
12915
  init_paths();
@@ -12935,6 +12995,7 @@ var init_service$1 = __esmMin((() => {
12935
12995
  asRemarks = decoded(StoredRemarks);
12936
12996
  asDrafts = decoded(Drafts);
12937
12997
  asWatching = decoded(Watching);
12998
+ asListening = decoded(Listening);
12938
12999
  linesOf = (raw) => raw.split("\n").filter((line) => line.trim().length > 0);
12939
13000
  readLines = (path, raw, as) => forEach(linesOf(raw), (line) => jsonOf$2(path, line).pipe(flatMap((value) => as(path, value))));
12940
13001
  parseSettings = fn("Store.parseSettings")(function* (path, raw) {
@@ -12962,34 +13023,52 @@ var init_service$1 = __esmMin((() => {
12962
13023
  ...was.taken
12963
13024
  }
12964
13025
  });
12965
- cursorOps = (state, inbox, spoken, changeState) => {
12966
- const handedIn = fn("Store.handedIn")(function* (worktreePath, handing) {
12967
- const batches = yield* inbox(worktreePath);
12968
- const current = yield* state(worktreePath);
12969
- const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
12970
- const taken = current.taken ?? {};
12971
- const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id) && (handing === "owed" || !Object.hasOwn(taken, comment.id));
12972
- return batches.flatMap((batch) => {
12973
- const comments = batch.comments.filter(owed);
12974
- return comments.length === 0 ? [] : [{
12975
- id: batch.id,
12976
- at: batch.at,
12977
- head: batch.head,
12978
- comments
12979
- }];
12980
- });
13026
+ handedOps = (state, inbox, spoken) => fn("Store.handedIn")(function* (worktreePath, handing) {
13027
+ const batches = yield* inbox(worktreePath);
13028
+ const current = yield* state(worktreePath);
13029
+ const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
13030
+ const taken = current.taken ?? {};
13031
+ const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id) && (handing === "owed" || !Object.hasOwn(taken, comment.id));
13032
+ return batches.flatMap((batch) => {
13033
+ const comments = batch.comments.filter(owed);
13034
+ return comments.length === 0 ? [] : [{
13035
+ id: batch.id,
13036
+ at: batch.at,
13037
+ head: batch.head,
13038
+ comments
13039
+ }];
12981
13040
  });
13041
+ });
13042
+ cursorOps = (handedIn, state, saveState, holdingState) => {
12982
13043
  const owedIn = (worktreePath) => handedIn(worktreePath, "owed");
13044
+ const marked = fn("Store.marked")(function* (worktreePath, at, handing) {
13045
+ const batches = yield* handedIn(worktreePath, handing);
13046
+ const ids = idsIn$1(batches);
13047
+ if (ids.length > 0) yield* saveState(worktreePath, takes(ids, at)(yield* state(worktreePath)));
13048
+ return batches;
13049
+ });
12983
13050
  return {
12984
- take: fn("Store.take")(function* (worktreePath, at, handing = "owed") {
12985
- const batches = yield* handedIn(worktreePath, handing);
12986
- const ids = idsIn$1(batches);
12987
- if (ids.length > 0) yield* changeState(worktreePath, takes(ids, at));
12988
- return batches;
13051
+ take: fn("Store.take")(function* (worktreePath, at) {
13052
+ const seen = yield* handedIn(worktreePath, "owed");
13053
+ return seen.length === 0 ? seen : yield* holdingState(worktreePath, marked(worktreePath, at, "owed"));
12989
13054
  }),
13055
+ marked,
12990
13056
  owed: owedIn
12991
13057
  };
12992
13058
  };
13059
+ waitOps = (handedIn, marked, holdingState, listening) => {
13060
+ const heldBy = (worktreePath, wait) => map$1(listening(worktreePath), (found) => isSome(found) && found.value.wait === wait);
13061
+ const markedFor = fn("Store.markedFor")(function* (worktreePath, at, wait) {
13062
+ if (!(yield* heldBy(worktreePath, wait))) return none();
13063
+ return some(yield* marked(worktreePath, at, "new"));
13064
+ });
13065
+ return { takeListening: fn("Store.takeListening")(function* (worktreePath, at, wait) {
13066
+ if (!(yield* heldBy(worktreePath, wait))) return none();
13067
+ const seen = yield* handedIn(worktreePath, "new");
13068
+ if (seen.length === 0) return some(seen);
13069
+ return yield* holdingState(worktreePath, markedFor(worktreePath, at, wait));
13070
+ }) };
13071
+ };
12993
13072
  settingsOps = (root) => {
12994
13073
  return {
12995
13074
  settings: gen(function* () {
@@ -13187,6 +13266,14 @@ var init_service$1 = __esmMin((() => {
13187
13266
  const path = watchPath(root, key);
13188
13267
  yield* ensureDir(branchDir(root, key));
13189
13268
  yield* wrote(path, JSON.stringify({ lookedAt: at }));
13269
+ }),
13270
+ listening: fn("Store.listening")(function* (worktreePath) {
13271
+ const key = yield* keyOf(worktreePath);
13272
+ const path = waitPath(root, key);
13273
+ const raw = yield* readOptional(path);
13274
+ if (isNone(raw)) return none();
13275
+ const value = yield* jsonOf$2(path, raw.value);
13276
+ return some(yield* asListening(path, value));
13190
13277
  })
13191
13278
  };
13192
13279
  };
@@ -13235,10 +13322,13 @@ var init_service$1 = __esmMin((() => {
13235
13322
  yield* ensureDir(branchDir(root, key));
13236
13323
  yield* writeState(path, next);
13237
13324
  });
13238
- const changeState = fn("Store.changeState")(function* (worktreePath, change) {
13325
+ const holdingState = (worktreePath, work) => gen(function* () {
13239
13326
  const key = yield* keyOf(worktreePath);
13240
13327
  yield* ensureDir(branchDir(root, key));
13241
- yield* alone(`${statePath(root, key)}.lock`, STATE_LOCK, under(worktreePath, change));
13328
+ return yield* alone(`${statePath(root, key)}.lock`, STATE_LOCK, work);
13329
+ }).pipe(withSpan("Store.holdingState"));
13330
+ const changeState = fn("Store.changeState")(function* (worktreePath, change) {
13331
+ yield* holdingState(worktreePath, under(worktreePath, change));
13242
13332
  });
13243
13333
  const under = fn("Store.under")(function* (worktreePath, change) {
13244
13334
  yield* saveState(worktreePath, change(yield* state(worktreePath)));
@@ -13246,14 +13336,25 @@ var init_service$1 = __esmMin((() => {
13246
13336
  return {
13247
13337
  state,
13248
13338
  saveState,
13249
- changeState
13339
+ changeState,
13340
+ holdingState
13250
13341
  };
13251
13342
  };
13252
13343
  makeStore = (root, git, keyOf) => {
13253
13344
  const { submit, inbox } = inboxOps(root, keyOf);
13254
- const { state, saveState, changeState } = stateOps(root, keyOf);
13345
+ const { state, saveState, changeState, holdingState } = stateOps(root, keyOf);
13255
13346
  const talk = answerOps(root, keyOf);
13256
- const cursors = cursorOps(state, inbox, talk.answers, changeState);
13347
+ const watch = watchOps(root, keyOf);
13348
+ const handedIn = handedOps(state, inbox, talk.answers);
13349
+ const { marked, ...cursors } = cursorOps(handedIn, state, saveState, holdingState);
13350
+ const waits = waitOps(handedIn, marked, holdingState, watch.listening);
13351
+ const listen = fn("Store.listen")(function* (worktreePath, wait, since) {
13352
+ const key = yield* keyOf(worktreePath);
13353
+ yield* holdingState(worktreePath, wrote(waitPath(root, key), JSON.stringify({
13354
+ wait,
13355
+ since
13356
+ })));
13357
+ });
13257
13358
  return {
13258
13359
  root,
13259
13360
  branchAt: git.headOf,
@@ -13268,9 +13369,11 @@ var init_service$1 = __esmMin((() => {
13268
13369
  ...talk,
13269
13370
  ...layersOps(root, keyOf),
13270
13371
  ...remarksOps(root, keyOf),
13271
- ...watchOps(root, keyOf),
13372
+ ...watch,
13373
+ listen,
13272
13374
  ...draftsOps(root, keyOf),
13273
- ...cursors
13375
+ ...cursors,
13376
+ ...waits
13274
13377
  };
13275
13378
  };
13276
13379
  madeStore = fn("Store.make")(function* (root) {
@@ -13286,15 +13389,15 @@ var init_service$1 = __esmMin((() => {
13286
13389
  //#endregion
13287
13390
  //#region src/service/store/index.ts
13288
13391
  var init_store = __esmMin((() => {
13289
- init_service$1();
13290
- init_error$3();
13392
+ init_service$2();
13393
+ init_error$4();
13291
13394
  init_paths();
13292
13395
  init_model$4();
13293
13396
  }));
13294
13397
  //#endregion
13295
13398
  //#region src/review/error.ts
13296
13399
  var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13297
- var init_error$2 = __esmMin((() => {
13400
+ var init_error$3 = __esmMin((() => {
13298
13401
  init_dist();
13299
13402
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
13300
13403
  BranchMoved = class extends TaggedError("BranchMoved") {};
@@ -13325,7 +13428,7 @@ var init_branches$1 = __esmMin((() => {
13325
13428
  init_patch();
13326
13429
  init_git();
13327
13430
  init_store();
13328
- init_error$2();
13431
+ init_error$3();
13329
13432
  realOf = (worktree) => tryPromise({
13330
13433
  try: () => realpath(worktree),
13331
13434
  catch: () => new UnknownWorktree({
@@ -13555,12 +13658,12 @@ var init_branches$1 = __esmMin((() => {
13555
13658
  }));
13556
13659
  //#endregion
13557
13660
  //#region src/review/patches.ts
13558
- 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;
13661
+ 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;
13559
13662
  var init_patches = __esmMin((() => {
13560
13663
  init_dist();
13561
13664
  init_patch();
13562
13665
  init_git();
13563
- init_error$2();
13666
+ init_error$3();
13564
13667
  init_branches$1();
13565
13668
  findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
13566
13669
  blobOf = (patches, file) => map$5(findPatch(patches, file), (patch) => patch.blob);
@@ -13671,12 +13774,12 @@ var init_patches = __esmMin((() => {
13671
13774
  });
13672
13775
  fileShown$1 = (worktree, generated) => (patch) => map$1(sourceShown(worktree, patch), (lines) => shownFile(patch, generated, lines));
13673
13776
  shownAs = (patch, lines) => shownFile(patch, /* @__PURE__ */ new Set(), lines);
13674
- onDisk$1 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13777
+ onDisk$2 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13675
13778
  show$3 = fn("Review.Diff.show")(function* (based, showing) {
13676
13779
  const git = yield* Git;
13677
13780
  const { worktree } = based;
13678
13781
  const patches$3 = yield* patches(worktree, linesAround(showing.context), showing.file);
13679
- const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$1(patches$3))], { concurrency: 2 });
13782
+ const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$2(patches$3))], { concurrency: 2 });
13680
13783
  return {
13681
13784
  branch: worktree.branch,
13682
13785
  base: based.base,
@@ -13936,12 +14039,70 @@ var init_quiet = __esmMin((() => {
13936
14039
  };
13937
14040
  }));
13938
14041
  //#endregion
14042
+ //#region src/domain/layers/text.ts
14043
+ var OFFSET, PRIME, hashOf, textOf, stamped, outdatedSpans;
14044
+ var init_text = __esmMin((() => {
14045
+ OFFSET = 2166136261;
14046
+ PRIME = 16777619;
14047
+ hashOf = (text) => {
14048
+ let hash = OFFSET;
14049
+ for (const unit of text) hash = Math.imul(hash ^ (unit.codePointAt(0) ?? 0), PRIME);
14050
+ return (hash >>> 0).toString(16).padStart(8, "0");
14051
+ };
14052
+ textOf = (lines, start, end) => hashOf(lines.slice(start - 1, end).join("\n"));
14053
+ stamped = (layers, sources) => layers.map((layer) => ({
14054
+ ...layer,
14055
+ blocks: layer.blocks.map((block) => block.kind === "code" ? {
14056
+ ...block,
14057
+ text: textOf(sources.get(block.path) ?? [], block.start, block.end)
14058
+ } : block)
14059
+ }));
14060
+ outdatedSpans = (layers, sources) => layers.flatMap((layer, at) => layer.blocks.flatMap((block) => {
14061
+ if (block.kind !== "code" || block.text === void 0) return [];
14062
+ const lines = sources.get(block.path);
14063
+ if (lines === void 0 || textOf(lines, block.start, block.end) === block.text) return [];
14064
+ return [{
14065
+ layer: at + 1,
14066
+ path: block.path,
14067
+ start: block.start,
14068
+ end: block.end
14069
+ }];
14070
+ }));
14071
+ }));
14072
+ //#endregion
14073
+ //#region src/domain/layers/split.ts
14074
+ var addedLines, claimsAny, sharedPaths, splitsIn;
14075
+ var init_split = __esmMin((() => {
14076
+ init_dist();
14077
+ init_coverage();
14078
+ addedLines = (patch) => patch.rows.filter((row) => row.kind === "added").flatMap((row) => toArray(row.newLine));
14079
+ claimsAny = (layer, path, lines) => codeBlocks(layer).some((block) => block.path === path && lines.some((line) => line >= block.start && line <= block.end));
14080
+ sharedPaths = (layers) => {
14081
+ const claimed = layers.flatMap((layer) => [...new Set(codeBlocks(layer).map((block) => block.path))]);
14082
+ return [...new Set(claimed.filter((path, at) => claimed.indexOf(path) !== at))];
14083
+ };
14084
+ splitsIn = (layers, patch, declarations) => {
14085
+ const added = addedLines(patch);
14086
+ return declarations.flatMap((declaration) => {
14087
+ const inside = added.filter((line) => line >= declaration.start && line <= declaration.end);
14088
+ const holding = layers.flatMap((layer, at) => claimsAny(layer, patch.path, inside) ? [at + 1] : []);
14089
+ return holding.length > 1 ? [{
14090
+ path: patch.path,
14091
+ ...declaration,
14092
+ layers: holding
14093
+ }] : [];
14094
+ });
14095
+ };
14096
+ }));
14097
+ //#endregion
13939
14098
  //#region src/domain/layers/index.ts
13940
14099
  var init_layers$1 = __esmMin((() => {
13941
14100
  init_coverage();
13942
14101
  init_version();
13943
14102
  init_quiet();
13944
14103
  init_model$3();
14104
+ init_text();
14105
+ init_split();
13945
14106
  }));
13946
14107
  //#endregion
13947
14108
  //#region src/review/placing.ts
@@ -14087,14 +14248,14 @@ var init_placing = __esmMin((() => {
14087
14248
  }));
14088
14249
  //#endregion
14089
14250
  //#region src/review/comments.ts
14090
- var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, take, awaitTaken, markRead;
14251
+ var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, dressed, take, REPLACED, listened, awaitTaken, markRead;
14091
14252
  var init_comments$1 = __esmMin((() => {
14092
14253
  init_dist();
14093
14254
  init_patch();
14094
14255
  init_git();
14095
14256
  init_layers$1();
14096
14257
  init_store();
14097
- init_error$2();
14258
+ init_error$3();
14098
14259
  init_branches$1();
14099
14260
  init_patches();
14100
14261
  init_placing();
@@ -14325,12 +14486,9 @@ var init_comments$1 = __esmMin((() => {
14325
14486
  onSome: (held) => held.layers
14326
14487
  });
14327
14488
  });
14328
- take = fn("Review.Comment.take")(function* (worktreePath, handing = "owed") {
14489
+ dressed = fn("Review.Comment.dressed")(function* (resolved, batches) {
14329
14490
  const store = yield* Store;
14330
- const resolved = yield* realOf(worktreePath);
14331
- const at = (/* @__PURE__ */ new Date()).toISOString();
14332
- yield* ignore(store.noteWatching(resolved, at));
14333
- const owed = flatten(yield* store.take(resolved, at, handing));
14491
+ const owed = flatten(batches);
14334
14492
  if (owed.length === 0) return owed;
14335
14493
  const layers = yield* layersOn(resolved);
14336
14494
  const under = (one) => {
@@ -14343,7 +14501,40 @@ var init_comments$1 = __esmMin((() => {
14343
14501
  const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
14344
14502
  return owed.map(carried).map(under);
14345
14503
  });
14346
- awaitTaken = (worktreePath, deadline, handing = "owed") => take(worktreePath, handing).pipe(flatMap((comments) => comments.length > 0 || Date.now() >= deadline ? succeed$1(comments) : sleep(POLL).pipe(flatMap(() => awaitTaken(worktreePath, deadline, handing)))));
14504
+ take = fn("Review.Comment.take")(function* (worktreePath) {
14505
+ const store = yield* Store;
14506
+ const resolved = yield* realOf(worktreePath);
14507
+ const at = (/* @__PURE__ */ new Date()).toISOString();
14508
+ yield* ignore(store.noteWatching(resolved, at));
14509
+ return yield* dressed(resolved, yield* store.take(resolved, at));
14510
+ });
14511
+ REPLACED = {
14512
+ comments: [],
14513
+ replaced: true
14514
+ };
14515
+ listened = (listen) => gen(function* () {
14516
+ const store = yield* Store;
14517
+ const at = (/* @__PURE__ */ new Date()).toISOString();
14518
+ yield* ignore(store.noteWatching(listen.resolved, at));
14519
+ const taken = yield* store.takeListening(listen.resolved, at, listen.wait);
14520
+ if (isNone(taken)) return REPLACED;
14521
+ const comments = yield* dressed(listen.resolved, taken.value);
14522
+ if (comments.length > 0 || Date.now() >= listen.deadline) return {
14523
+ comments,
14524
+ replaced: false
14525
+ };
14526
+ return yield* sleep(POLL).pipe(flatMap(() => listened(listen)));
14527
+ });
14528
+ awaitTaken = fn("Review.Comment.awaitTaken")(function* (worktreePath, deadline, wait) {
14529
+ const store = yield* Store;
14530
+ const resolved = yield* realOf(worktreePath);
14531
+ yield* store.listen(resolved, wait, (/* @__PURE__ */ new Date()).toISOString());
14532
+ return yield* listened({
14533
+ resolved,
14534
+ deadline,
14535
+ wait
14536
+ });
14537
+ });
14347
14538
  markRead = fn("Review.Comment.markRead")(function* (worktree, id) {
14348
14539
  const store = yield* Store;
14349
14540
  const spoken = yield* store.answers(worktree.path);
@@ -14441,7 +14632,7 @@ var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf
14441
14632
  var init_threads$1 = __esmMin((() => {
14442
14633
  init_dist();
14443
14634
  init_store();
14444
- init_error$2();
14635
+ init_error$3();
14445
14636
  init_placing();
14446
14637
  init_review$1();
14447
14638
  ASK_LEAD = "About this branch, not about this line.";
@@ -14773,16 +14964,16 @@ var init_threads$1 = __esmMin((() => {
14773
14964
  //#endregion
14774
14965
  //#region src/service/forge/error.ts
14775
14966
  var ForgeUnavailable;
14776
- var init_error$1 = __esmMin((() => {
14967
+ var init_error$2 = __esmMin((() => {
14777
14968
  init_dist();
14778
14969
  ForgeUnavailable = class extends TaggedError("ForgeUnavailable") {};
14779
14970
  }));
14780
14971
  //#endregion
14781
14972
  //#region src/service/forge/service.ts
14782
14973
  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;
14783
- var init_service = __esmMin((() => {
14974
+ var init_service$1 = __esmMin((() => {
14784
14975
  init_dist();
14785
- init_error$1();
14976
+ init_error$2();
14786
14977
  Forge = class extends Service()("adiff/Forge") {};
14787
14978
  LIMIT = "200";
14788
14979
  TIMEOUT_MS = 4e3;
@@ -15228,15 +15419,15 @@ var init_service = __esmMin((() => {
15228
15419
  //#endregion
15229
15420
  //#region src/service/forge/index.ts
15230
15421
  var init_forge = __esmMin((() => {
15231
- init_service();
15232
- init_error$1();
15422
+ init_service$1();
15423
+ init_error$2();
15233
15424
  })), 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;
15234
15425
  var init_remarks$1 = __esmMin((() => {
15235
15426
  init_dist();
15236
15427
  init_patch();
15237
15428
  init_forge();
15238
15429
  init_store();
15239
- init_error$2();
15430
+ init_error$3();
15240
15431
  VERSION = 1;
15241
15432
  OPENING = /^```suggestion[^\n]*\n?/gm;
15242
15433
  CLOSING = /^```[ \t]*$/gm;
@@ -15483,7 +15674,7 @@ var init_vouching$1 = __esmMin((() => {
15483
15674
  init_review$1();
15484
15675
  init_git();
15485
15676
  init_store();
15486
- init_error$2();
15677
+ init_error$3();
15487
15678
  init_branches$1();
15488
15679
  init_patches();
15489
15680
  pathOfMark = (mark) => mark.split("@")[0] ?? "";
@@ -15831,7 +16022,7 @@ var init_preferences = __esmMin((() => {
15831
16022
  init_dist();
15832
16023
  init_store();
15833
16024
  init_preferences$1();
15834
- init_error$2();
16025
+ init_error$3();
15835
16026
  list$1 = fn("Review.Preference.list")(function* () {
15836
16027
  const kept = yield* (yield* Store).settings;
15837
16028
  return preferences.map((one) => ({
@@ -15888,19 +16079,124 @@ var init_preferences = __esmMin((() => {
15888
16079
  });
15889
16080
  }));
15890
16081
  //#endregion
16082
+ //#region src/service/syntax/error.ts
16083
+ var GrammarUnreadable;
16084
+ var init_error$1 = __esmMin((() => {
16085
+ init_dist();
16086
+ GrammarUnreadable = class extends TaggedError("GrammarUnreadable") {};
16087
+ }));
16088
+ //#endregion
16089
+ //#region src/service/syntax/service.ts
16090
+ 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;
16091
+ var init_service = __esmMin((() => {
16092
+ init_dist();
16093
+ init_error$1();
16094
+ Syntax = class extends Service()("adiff/Syntax") {};
16095
+ TYPESCRIPT = /\.[mc]?ts$/;
16096
+ TSX = /\.tsx$/;
16097
+ NAMED_FUNCTIONS = /* @__PURE__ */ new Set([
16098
+ "function_declaration",
16099
+ "generator_function_declaration",
16100
+ "method_definition"
16101
+ ]);
16102
+ HOLDING_A_FUNCTION = /* @__PURE__ */ new Set(["variable_declarator", "public_field_definition"]);
16103
+ FUNCTION_VALUES = /* @__PURE__ */ new Set([
16104
+ "arrow_function",
16105
+ "function_expression",
16106
+ "generator_function"
16107
+ ]);
16108
+ besideThis$1 = (path) => fileURLToPath(new URL(`./grammars/${path}`, import.meta.url));
16109
+ onDisk$1 = sync(() => ({
16110
+ runtime: void 0,
16111
+ typescript: besideThis$1("typescript/tree-sitter-typescript.wasm"),
16112
+ tsx: besideThis$1("tsx/tree-sitter-tsx.wasm")
16113
+ }));
16114
+ embedded$1 = all({
16115
+ runtime: promise(() => import("web-tree-sitter/tree-sitter.wasm", { with: { type: "file" } })),
16116
+ typescript: promise(() => import("./grammars/typescript/tree-sitter-typescript.wasm", { with: { type: "file" } })),
16117
+ tsx: promise(() => import("./grammars/tsx/tree-sitter-tsx.wasm", { with: { type: "file" } }))
16118
+ }).pipe(map$1((loaded) => ({
16119
+ runtime: loaded.runtime.default,
16120
+ typescript: loaded.typescript.default,
16121
+ tsx: loaded.tsx.default
16122
+ })));
16123
+ compiled$1 = () => process.versions["bun"] !== void 0;
16124
+ started$1 = (found) => found.runtime === void 0 ? Parser.init() : Parser.init({ locateFile: () => found.runtime ?? "" });
16125
+ readFrom = (path, load) => tryPromise({
16126
+ try: load,
16127
+ catch: (cause) => new GrammarUnreadable({
16128
+ path,
16129
+ reason: String(cause)
16130
+ })
16131
+ });
16132
+ loaded = fn("Syntax.loaded")(function* (found) {
16133
+ yield* readFrom(found.runtime ?? "web-tree-sitter", () => started$1(found));
16134
+ return yield* all({
16135
+ typescript: readFrom(found.typescript, () => Language.load(found.typescript)),
16136
+ tsx: readFrom(found.tsx, () => Language.load(found.tsx))
16137
+ }, { concurrency: "unbounded" });
16138
+ });
16139
+ grammarsLoaded = suspend(() => compiled$1() ? embedded$1 : onDisk$1).pipe(flatMap(loaded), option$2);
16140
+ grammarOf = (grammars, path) => {
16141
+ if (TSX.test(path)) return some(grammars.tsx);
16142
+ if (TYPESCRIPT.test(path)) return some(grammars.typescript);
16143
+ return none();
16144
+ };
16145
+ holdsFunction = (node) => {
16146
+ const value = node.childForFieldName("value");
16147
+ return value !== null && FUNCTION_VALUES.has(value.type);
16148
+ };
16149
+ declared = (node) => {
16150
+ const name = NAMED_FUNCTIONS.has(node.type) || HOLDING_A_FUNCTION.has(node.type) && holdsFunction(node) ? node.childForFieldName("name")?.text : void 0;
16151
+ if (name === void 0) return none();
16152
+ return some({
16153
+ name,
16154
+ start: node.startPosition.row + 1,
16155
+ end: node.endPosition.row + 1
16156
+ });
16157
+ };
16158
+ declarationsUnder = (node) => [...toArray(declared(node)), ...node.namedChildren.flatMap((child) => child === null ? [] : declarationsUnder(child))];
16159
+ parsed$1 = (language, lines) => {
16160
+ const parser = new Parser();
16161
+ parser.setLanguage(language);
16162
+ const tree = parser.parse(lines.join("\n"));
16163
+ const found = tree === null ? [] : declarationsUnder(tree.rootNode);
16164
+ tree?.delete();
16165
+ parser.delete();
16166
+ return found;
16167
+ };
16168
+ functionsWith = (grammars) => (path, lines) => map$1(grammars, (ready) => match$3(flatMap$2(ready, (loadedGrammars) => grammarOf(loadedGrammars, path)), {
16169
+ onNone: () => [],
16170
+ onSome: (language) => parsed$1(language, lines)
16171
+ }));
16172
+ makeSyntax = fn("Syntax.make")(function* () {
16173
+ const grammars = yield* cached(grammarsLoaded);
16174
+ return { functions: functionsWith(grammars) };
16175
+ });
16176
+ SyntaxLive = effect(Syntax)(makeSyntax());
16177
+ }));
16178
+ //#endregion
16179
+ //#region src/service/syntax/index.ts
16180
+ var init_syntax = __esmMin((() => {
16181
+ init_service();
16182
+ }));
16183
+ //#endregion
15891
16184
  //#region src/review/layers.ts
15892
- 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, carriedStamps, unmarkedPart, markedPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn;
16185
+ 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;
15893
16186
  var init_layers = __esmMin((() => {
15894
16187
  init_dist();
15895
16188
  init_layers$1();
16189
+ init_git();
16190
+ init_syntax();
15896
16191
  init_store();
15897
16192
  init_review$1();
15898
- init_error$2();
16193
+ init_error$3();
15899
16194
  init_comments$1();
15900
16195
  init_threads$1();
15901
16196
  init_branches$1();
15902
16197
  init_vouching$1();
15903
16198
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
16199
+ 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.";
15904
16200
  unique = (paths) => [...new Set(paths)];
15905
16201
  spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
15906
16202
  path,
@@ -16023,15 +16319,19 @@ var init_layers = __esmMin((() => {
16023
16319
  };
16024
16320
  });
16025
16321
  };
16026
- reportOf = (patches, layers, branchHead) => {
16322
+ adviceOf = (moved, outdated) => {
16323
+ if (moved) return { advice: STALE_ADVICE };
16324
+ return outdated.length > 0 ? { advice: OUTDATED_ADVICE } : {};
16325
+ };
16326
+ reportOf = (patches, layers, branchHead, outdated = []) => {
16027
16327
  const status = statusOf(patches, layers, branchHead);
16028
16328
  return {
16029
16329
  version: status.version,
16030
16330
  parent: getOrUndefined$1(status.parent),
16031
16331
  head: status.layersHead,
16032
16332
  branchHead: status.branchHead,
16033
- stale: status.stale,
16034
- ...status.stale ? { advice: STALE_ADVICE } : {},
16333
+ stale: status.stale || outdated.length > 0,
16334
+ ...adviceOf(status.stale, outdated),
16035
16335
  written: layers.written,
16036
16336
  summary: layers.summary,
16037
16337
  covered: status.covered,
@@ -16039,10 +16339,36 @@ var init_layers = __esmMin((() => {
16039
16339
  total: status.total,
16040
16340
  uncovered: status.uncovered,
16041
16341
  shared: sharedHunks(patches, layers.layers),
16342
+ split: layers.split ?? [],
16042
16343
  vanished: status.vanished,
16344
+ outdated,
16043
16345
  layers: reportedLayers(patches, layers)
16044
16346
  };
16045
16347
  };
16348
+ pathsOfLayer = (layer) => codeBlocks(layer).map((block) => block.path);
16349
+ sourcesOf = fn("Review.Layers.sourcesOf")(function* (worktree, paths) {
16350
+ const git = yield* Git;
16351
+ const read = fn("Review.Layers.sourceOf")(function* (path) {
16352
+ const lines = yield* git.source(worktree, path);
16353
+ return [path, getOrUndefined$1(lines) ?? []];
16354
+ });
16355
+ return new Map(yield* forEach(paths, read, { concurrency: 8 }));
16356
+ });
16357
+ changedSinceWritten = (patches, layers) => Object.entries(layers.blobs ?? {}).filter(([path, blob]) => {
16358
+ const now = patches.find((patch) => patch.path === path);
16359
+ return now !== void 0 && !sameBlob(now.blob, blob);
16360
+ }).map(([path]) => path);
16361
+ outdatedIn = fn("Review.Layers.outdatedIn")(function* (worktree, patches, layers) {
16362
+ const changed = changedSinceWritten(patches, layers);
16363
+ if (changed.length === 0) return [];
16364
+ return outdatedSpans(layers.layers, yield* sourcesOf(worktree, changed));
16365
+ });
16366
+ splitsFound = fn("Review.Layers.splitsFound")(function* (patches, layers, sources) {
16367
+ const syntax = yield* Syntax;
16368
+ const shared = new Set(sharedPaths(layers));
16369
+ const splitIn = (patch) => map$1(syntax.functions(patch.path, sources.get(patch.path) ?? []), (found) => splitsIn(layers, patch, found));
16370
+ return (yield* forEach(patches.filter((patch) => shared.has(patch.path)), splitIn)).flat();
16371
+ });
16046
16372
  storedLayers = fn("Review.Layers.storedLayers")(function* (worktree) {
16047
16373
  const store = yield* Store;
16048
16374
  return map$5(yield* store.layers(worktree.path), fromStored);
@@ -16052,6 +16378,8 @@ var init_layers = __esmMin((() => {
16052
16378
  const input = yield* readLayers(text);
16053
16379
  const patches$1 = yield* patches(worktree);
16054
16380
  const previous = yield* storedLayers(worktree);
16381
+ const paths = unique(input.layers.flatMap(pathsOfLayer));
16382
+ const sources = yield* sourcesOf(worktree, paths);
16055
16383
  const layers = {
16056
16384
  version: match$3(previous, {
16057
16385
  onNone: () => 1,
@@ -16062,7 +16390,9 @@ var init_layers = __esmMin((() => {
16062
16390
  base: worktree.base,
16063
16391
  written,
16064
16392
  summary: input.summary,
16065
- layers: input.layers
16393
+ layers: stamped(input.layers, sources),
16394
+ blobs: Object.fromEntries(patches$1.filter((patch) => sources.has(patch.path)).map((patch) => [patch.path, patch.blob])),
16395
+ split: yield* splitsFound(patches$1, input.layers, sources)
16066
16396
  };
16067
16397
  yield* store.saveLayers(worktree.path, toStored(layers));
16068
16398
  return reportOf(patches$1, layers, worktree.head);
@@ -16130,7 +16460,8 @@ var init_layers = __esmMin((() => {
16130
16460
  path: patch.path,
16131
16461
  blob: patch.blob
16132
16462
  }));
16133
- const report = reportOf(reading.patches, found.value, reading.worktree.head);
16463
+ const outdated = yield* outdatedIn(reading.worktree, reading.patches, found.value);
16464
+ const report = reportOf(reading.patches, found.value, reading.worktree.head, outdated);
16134
16465
  const spans = report.layers.map((layer) => layer.spans);
16135
16466
  return some(withRead(report, {
16136
16467
  patches: reading.patches,
@@ -16225,9 +16556,10 @@ var init_layers = __esmMin((() => {
16225
16556
  stale: false,
16226
16557
  summary: ""
16227
16558
  };
16559
+ const outdated = yield* outdatedIn(worktree, reading.patches, found.value);
16228
16560
  return {
16229
16561
  layers: reportedLayers(reading.patches, found.value),
16230
- stale: found.value.head !== worktree.head,
16562
+ stale: found.value.head !== worktree.head || outdated.length > 0,
16231
16563
  rebased: found.value.base !== worktree.base,
16232
16564
  summary: found.value.summary
16233
16565
  };
@@ -16384,7 +16716,7 @@ var init_drafts$1 = __esmMin((() => {
16384
16716
  init_dist();
16385
16717
  init_forge();
16386
16718
  init_store();
16387
- init_error$2();
16719
+ init_error$3();
16388
16720
  init_patches();
16389
16721
  unreadIn = (draft, seen) => {
16390
16722
  if (draft.wroteBy !== "agent") return false;
@@ -16732,7 +17064,7 @@ var show;
16732
17064
  var init_pulls = __esmMin((() => {
16733
17065
  init_dist();
16734
17066
  init_forge();
16735
- init_error$2();
17067
+ init_error$3();
16736
17068
  show = fn("Review.Pull.show")(function* (repo, branch) {
16737
17069
  const forge = yield* Forge;
16738
17070
  const found = (yield* forge.pulls(repo)).find((pull) => pull.branch === branch);
@@ -16763,7 +17095,7 @@ var init_review = __esmMin((() => {
16763
17095
  init_drafts$1();
16764
17096
  init_search$1();
16765
17097
  init_pulls();
16766
- init_error$2();
17098
+ init_error$3();
16767
17099
  }));
16768
17100
  //#endregion
16769
17101
  //#region src/cli/help.ts
@@ -16787,7 +17119,7 @@ const banner = () => [
16787
17119
  "An agent working in that worktree answers them:",
16788
17120
  "",
16789
17121
  " adiff comment take --worktree . collect every comment owed an answer",
16790
- " adiff comment take --worktree . --new --wait 6900 block until a new comment arrives",
17122
+ " adiff comment take --worktree . --wait 6900 block until a new comment arrives",
16791
17123
  " adiff comment answer --worktree . --id <id> --body '…'",
16792
17124
  " adiff layers set --worktree . --json - publish a reading order, when asked",
16793
17125
  "",
@@ -26545,6 +26877,7 @@ init_dist();
26545
26877
  init_cli();
26546
26878
  init_review();
26547
26879
  init_git();
26880
+ init_syntax();
26548
26881
  init_forge();
26549
26882
  init_store();
26550
26883
  const WAIT_UNIT = 1e3;
@@ -26645,17 +26978,27 @@ const commentReply = fn("Main.commentReply")(function* (options) {
26645
26978
  });
26646
26979
  yield* answer(options, { batch });
26647
26980
  });
26648
- const NOTHING_WAITING = "No comment is waiting. Pass --new --wait <seconds> to block until a new one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26981
+ const NOTHING_WAITING = "No comment is waiting. Pass --wait <seconds> to block until a new one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26982
+ const WAIT_REPLACED = "A newer wait on this worktree took over, so this wait ended and handed over nothing. Leave this wait ended: the newer wait is the one listening.";
26983
+ const noteOn = (waited) => {
26984
+ if (waited.replaced) return {
26985
+ replaced: true,
26986
+ hint: WAIT_REPLACED
26987
+ };
26988
+ return waited.comments.length === 0 ? { hint: NOTHING_WAITING } : {};
26989
+ };
26649
26990
  const commentTake = fn("Main.commentTake")(function* (options) {
26650
26991
  const worktree = yield* required(options, "worktree");
26651
26992
  const wait = yield* seconds(options, "wait");
26652
- const handing = options["new"] === void 0 ? "owed" : "new";
26653
- const comments = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT, handing) : yield* take(worktree, handing);
26654
- const hint = comments.length === 0 ? { hint: NOTHING_WAITING } : {};
26993
+ const waited = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT, randomUUID()) : {
26994
+ comments: yield* take(worktree),
26995
+ replaced: false
26996
+ };
26997
+ const branch = yield* nameAt(worktree);
26655
26998
  yield* answer(options, {
26656
- comments,
26657
- branch: yield* nameAt(worktree),
26658
- ...hint
26999
+ comments: waited.comments,
27000
+ branch,
27001
+ ...noteOn(waited)
26659
27002
  });
26660
27003
  });
26661
27004
  const commentAnswer = fn("Main.commentAnswer")(function* (options) {
@@ -26994,7 +27337,17 @@ const wanting = (name) => (error) => {
26994
27337
  usage: usageOf(command)
26995
27338
  }));
26996
27339
  };
26997
- const run = (name, options) => onlyKnown(options, knownIn(name)).pipe(flatMap(() => dispatch(name, options)), catchTag("MissingOption", wanting(name)));
27340
+ const stillTaken = (name, options) => {
27341
+ const removed = removedIn(name, Object.keys(options));
27342
+ if (removed !== void 0) return fail(new RemovedOption({
27343
+ option: removed.option,
27344
+ command: name,
27345
+ reason: removed.reason
27346
+ }));
27347
+ const retired = new Set(retiredIn(name, Object.keys(options)));
27348
+ return succeed$1(Object.fromEntries(Object.entries(options).filter(([key]) => !retired.has(key))));
27349
+ };
27350
+ const run = (name, options) => stillTaken(name, options).pipe(flatMap((kept) => onlyKnown(kept, knownIn(name)).pipe(flatMap(() => dispatch(name, kept)))), catchTag("MissingOption", wanting(name)));
26998
27351
  const leading = (argv) => {
26999
27352
  const stop = argv.findIndex((token) => token.startsWith("-"));
27000
27353
  return stop === -1 ? argv : argv.slice(0, stop);
@@ -27044,7 +27397,7 @@ if (said !== void 0) {
27044
27397
  process.stdout.write(`${said}\n`);
27045
27398
  process.exit(0);
27046
27399
  }
27047
- const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot())).pipe(provideMerge(GitLive));
27400
+ const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot()), SyntaxLive).pipe(provideMerge(GitLive));
27048
27401
  const reportFailure = (cause) => sync(() => {
27049
27402
  const reported = failure(squash(cause));
27050
27403
  process.stderr.write(`${reported.line}\n`);