@eliya-oss/agent-diff 0.1.0-alpha.109 → 0.1.0-alpha.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/main.js +345 -133
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.110
4
+
5
+ ### Patch Changes
6
+
7
+ - A comment now quotes only the lines it says it is about. A selection that crossed a change stored the old and the new version of every changed line in its snippet while naming only the new side, so the agent was handed code that is not at those line numbers in either version of the file. `--side old` was worse: it silently became a new-side comment on a different line.
8
+
9
+ Two writes to one review at the same moment both land. Settling in the terminal while the agent answered from the worktree lost one of them and reported success for both; at twelve at once, five of twelve survived.
10
+
11
+ `draft send` no longer throws away a draft written while it was sending, reports what the forge actually took rather than what it was handed, and posts a range as a range instead of a comment on its last line.
12
+
13
+ The key sheet names every key a command answers to, so `j` and `k` are findable, and it can be searched by key as well as by name. The footer says how to move before anything else, keeps the highest-ranked keys when the terminal is narrow rather than the last ones, and always keeps the two ways out.
14
+
3
15
  ## 0.1.0-alpha.109
4
16
 
5
17
  ### Patch Changes
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { appendFile, mkdir, readFile, realpath, rename, stat, writeFile } from "node:fs/promises";
2
+ import { appendFile, mkdir, readFile, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
3
3
  import { homedir, hostname, platform } from "node:os";
4
4
  import { text } from "node:stream/consumers";
5
5
  import { execFile, spawn } from "node:child_process";
@@ -1480,7 +1480,7 @@ var init_core = __esmMin((() => {
1480
1480
  }));
1481
1481
  //#endregion
1482
1482
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/internal/option.js
1483
- var TypeId$17, CommonProto$1, SomeProto, NoneHash, NoneProto, isOption, isNone$1, isSome$1, none$1, some$1;
1483
+ var TypeId$18, CommonProto$1, SomeProto, NoneHash, NoneProto, isOption, isNone$1, isSome$1, none$1, some$1;
1484
1484
  var init_option = __esmMin((() => {
1485
1485
  init_Equal();
1486
1486
  init_Formatter();
@@ -1489,9 +1489,9 @@ var init_option = __esmMin((() => {
1489
1489
  init_Predicate();
1490
1490
  init_Utils();
1491
1491
  init_core();
1492
- TypeId$17 = "~effect/data/Option";
1492
+ TypeId$18 = "~effect/data/Option";
1493
1493
  CommonProto$1 = {
1494
- [TypeId$17]: { _A: (_) => _ },
1494
+ [TypeId$18]: { _A: (_) => _ },
1495
1495
  ...PipeInspectableProto,
1496
1496
  [Symbol.iterator]() {
1497
1497
  return new SingleShotGen(this);
@@ -1540,7 +1540,7 @@ var init_option = __esmMin((() => {
1540
1540
  };
1541
1541
  }
1542
1542
  });
1543
- isOption = (input) => hasProperty(input, TypeId$17);
1543
+ isOption = (input) => hasProperty(input, TypeId$18);
1544
1544
  isNone$1 = (fa) => fa._tag === "None";
1545
1545
  isSome$1 = (fa) => fa._tag === "Some";
1546
1546
  none$1 = /*#__PURE__*/ Object.create(NoneProto);
@@ -1552,7 +1552,7 @@ var init_option = __esmMin((() => {
1552
1552
  }));
1553
1553
  //#endregion
1554
1554
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/internal/result.js
1555
- var TypeId$16, CommonProto, SuccessProto, FailureProto, isResult, isFailure$1, isSuccess$1, fail$4, succeed$7;
1555
+ var TypeId$17, CommonProto, SuccessProto, FailureProto, isResult, isFailure$1, isSuccess$1, fail$4, succeed$7;
1556
1556
  var init_result = __esmMin((() => {
1557
1557
  init_Equal();
1558
1558
  init_Formatter();
@@ -1561,9 +1561,9 @@ var init_result = __esmMin((() => {
1561
1561
  init_Predicate();
1562
1562
  init_Utils();
1563
1563
  init_core();
1564
- TypeId$16 = "~effect/data/Result";
1564
+ TypeId$17 = "~effect/data/Result";
1565
1565
  CommonProto = {
1566
- [TypeId$16]: {
1566
+ [TypeId$17]: {
1567
1567
  /* v8 ignore next 2 */
1568
1568
  _A: (_) => _,
1569
1569
  _E: (_) => _
@@ -1613,7 +1613,7 @@ var init_result = __esmMin((() => {
1613
1613
  };
1614
1614
  }
1615
1615
  });
1616
- isResult = (input) => hasProperty(input, TypeId$16);
1616
+ isResult = (input) => hasProperty(input, TypeId$17);
1617
1617
  isFailure$1 = (result) => result._tag === "Failure";
1618
1618
  isSuccess$1 = (result) => result._tag === "Success";
1619
1619
  fail$4 = (failure) => {
@@ -1740,7 +1740,7 @@ var init_Result = __esmMin((() => {
1740
1740
  for (const value of input) if (hashBucketsAdd(buckets, value)) out.push(value);
1741
1741
  return out;
1742
1742
  };
1743
- })), TypeId$15, BigDecimalProto, isBigDecimal, make$14, makeNormalizedUnsafe, bigint0$2, bigint10$1, zero$1, normalize, scale, abs, Equivalence$3, equals$1, format, toExponential, isZero, isNegative;
1743
+ })), TypeId$16, BigDecimalProto, isBigDecimal, make$14, makeNormalizedUnsafe, bigint0$2, bigint10$1, zero$1, normalize, scale, abs, Equivalence$3, equals$1, format, toExponential, isZero, isNegative;
1744
1744
  var init_BigDecimal = __esmMin((() => {
1745
1745
  init_Equal();
1746
1746
  init_Equivalence();
@@ -1750,9 +1750,9 @@ var init_BigDecimal = __esmMin((() => {
1750
1750
  init_Order();
1751
1751
  init_Pipeable();
1752
1752
  init_Predicate();
1753
- TypeId$15 = "~effect/BigDecimal";
1753
+ TypeId$16 = "~effect/BigDecimal";
1754
1754
  BigDecimalProto = {
1755
- [TypeId$15]: TypeId$15,
1755
+ [TypeId$16]: TypeId$16,
1756
1756
  [symbol$1]() {
1757
1757
  const normalized = normalize(this);
1758
1758
  return combine(hash(normalized.value), number$1(normalized.scale));
@@ -1777,7 +1777,7 @@ var init_BigDecimal = __esmMin((() => {
1777
1777
  return pipeArguments(this, arguments);
1778
1778
  }
1779
1779
  };
1780
- isBigDecimal = (u) => hasProperty(u, TypeId$15);
1780
+ isBigDecimal = (u) => hasProperty(u, TypeId$16);
1781
1781
  make$14 = (value, scale) => {
1782
1782
  const o = Object.create(BigDecimalProto);
1783
1783
  o.value = value;
@@ -1869,7 +1869,7 @@ var init_Effectable = __esmMin((() => {
1869
1869
  }));
1870
1870
  //#endregion
1871
1871
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Context.js
1872
- var ServiceTypeId, Service, ServiceProto, cacheKeys, ReferenceTypeId, TypeId$14, MaxDepth, FlattenAfterBaseHits, makeImpl, applyOverlays, flatten$1, withFlat, notFound, lookup, makeUnsafe$5, Proto$2, hasSameCache, isContext, isReference, empty, emptyContext, make$13, add$1, addUnsafe, getOrUndefined, getOrUndefinedUnsafe, getUnsafe$1, get, defaultValueCacheKey, getDefaultValue, serviceNotFoundError, merge, mergeAll$1, Reference;
1872
+ var ServiceTypeId, Service, ServiceProto, cacheKeys, ReferenceTypeId, TypeId$15, MaxDepth, FlattenAfterBaseHits, makeImpl, applyOverlays, flatten$1, withFlat, notFound, lookup, makeUnsafe$5, Proto$2, hasSameCache, isContext, isReference, empty, emptyContext, make$13, add$1, addUnsafe, getOrUndefined, getOrUndefinedUnsafe, getUnsafe$1, get, defaultValueCacheKey, getDefaultValue, serviceNotFoundError, merge, mergeAll$1, Reference;
1873
1873
  var init_Context = __esmMin((() => {
1874
1874
  init_Effectable();
1875
1875
  init_Equal();
@@ -1923,7 +1923,7 @@ var init_Context = __esmMin((() => {
1923
1923
  };
1924
1924
  cacheKeys = /*#__PURE__*/ new Set();
1925
1925
  ReferenceTypeId = "~effect/Context/Reference";
1926
- TypeId$14 = "~effect/Context";
1926
+ TypeId$15 = "~effect/Context";
1927
1927
  MaxDepth = 8;
1928
1928
  FlattenAfterBaseHits = 8;
1929
1929
  makeImpl = (cacheRoot, base, overlay, depth) => {
@@ -1969,7 +1969,7 @@ var init_Context = __esmMin((() => {
1969
1969
  makeUnsafe$5 = (mapUnsafe) => makeImpl(void 0, mapUnsafe, void 0, 0);
1970
1970
  Proto$2 = {
1971
1971
  ...PipeInspectableProto,
1972
- [TypeId$14]: { _Services: (_) => _ },
1972
+ [TypeId$15]: { _Services: (_) => _ },
1973
1973
  get mapUnsafe() {
1974
1974
  return flatten$1(this);
1975
1975
  },
@@ -1995,7 +1995,7 @@ var init_Context = __esmMin((() => {
1995
1995
  }
1996
1996
  };
1997
1997
  hasSameCache = (self, that) => self.cacheRoot === that.cacheRoot;
1998
- isContext = (u) => hasProperty(u, TypeId$14);
1998
+ isContext = (u) => hasProperty(u, TypeId$15);
1999
1999
  isReference = (u) => !!u[ReferenceTypeId];
2000
2000
  empty = () => emptyContext;
2001
2001
  emptyContext = /*#__PURE__*/ makeUnsafe$5(/*#__PURE__*/ new Map());
@@ -2059,7 +2059,7 @@ var init_Context = __esmMin((() => {
2059
2059
  }));
2060
2060
  //#endregion
2061
2061
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Duration.js
2062
- var TypeId$13, bigint0$1, bigint1, bigint2, bigint10, bigint1e3, roundTiesAwayFromZero, roundMillisToNanos, parseNanos, DURATION_REGEXP, fromInputUnsafe, invalid, zeroDurationValue, infinityDurationValue, negativeInfinityDurationValue, DurationProto, make$12, isDuration, zero, infinity, negativeInfinity, nanos, millis, seconds, minutes, hours, days, weeks, toMillis, toNanosUnsafe, match$1, matchPair, Equivalence$2, equals;
2062
+ var TypeId$14, bigint0$1, bigint1, bigint2, bigint10, bigint1e3, roundTiesAwayFromZero, roundMillisToNanos, parseNanos, DURATION_REGEXP, fromInputUnsafe, invalid, zeroDurationValue, infinityDurationValue, negativeInfinityDurationValue, DurationProto, make$12, isDuration, zero, infinity, negativeInfinity, nanos, millis, seconds, minutes, hours, days, weeks, toMillis, toNanosUnsafe, match$1, matchPair, Equivalence$2, equals;
2063
2063
  var init_Duration = __esmMin((() => {
2064
2064
  init_Equal();
2065
2065
  init_Function();
@@ -2067,7 +2067,7 @@ var init_Duration = __esmMin((() => {
2067
2067
  init_Inspectable();
2068
2068
  init_Pipeable();
2069
2069
  init_Predicate();
2070
- TypeId$13 = "~effect/time/Duration";
2070
+ TypeId$14 = "~effect/time/Duration";
2071
2071
  bigint0$1 = /*#__PURE__*/ BigInt(0);
2072
2072
  bigint1 = /*#__PURE__*/ BigInt(1);
2073
2073
  bigint2 = /*#__PURE__*/ BigInt(2);
@@ -2117,7 +2117,7 @@ var init_Duration = __esmMin((() => {
2117
2117
  }
2118
2118
  case "object": {
2119
2119
  if (input === null) break;
2120
- if (TypeId$13 in input) return input;
2120
+ if (TypeId$14 in input) return input;
2121
2121
  if (Array.isArray(input)) {
2122
2122
  if (input.length !== 2 || !input.every(isNumber)) return invalid(input);
2123
2123
  if (Number.isNaN(input[0]) || Number.isNaN(input[1])) return zero;
@@ -2149,7 +2149,7 @@ var init_Duration = __esmMin((() => {
2149
2149
  infinityDurationValue = { _tag: "Infinity" };
2150
2150
  negativeInfinityDurationValue = { _tag: "NegativeInfinity" };
2151
2151
  DurationProto = {
2152
- [TypeId$13]: TypeId$13,
2152
+ [TypeId$14]: TypeId$14,
2153
2153
  [symbol$1]() {
2154
2154
  switch (this.value._tag) {
2155
2155
  case "Millis": {
@@ -2219,7 +2219,7 @@ var init_Duration = __esmMin((() => {
2219
2219
  };
2220
2220
  return duration;
2221
2221
  };
2222
- isDuration = (u) => hasProperty(u, TypeId$13);
2222
+ isDuration = (u) => hasProperty(u, TypeId$14);
2223
2223
  zero = /*#__PURE__*/ make$12(0);
2224
2224
  infinity = /*#__PURE__*/ make$12(Infinity);
2225
2225
  negativeInfinity = /*#__PURE__*/ make$12(-Infinity);
@@ -2594,7 +2594,7 @@ var CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations
2594
2594
  };
2595
2595
  };
2596
2596
  spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
2597
- })), Interrupt, causeInterrupt, findFail, findError$1, hasInterrupts, causeFilterInterruptors, 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, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$2, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die, 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$2, mapEager$1, exitInterrupt$1, exitIsSuccess, exitFilterCause, exitVoid, exitMap, exitAsVoidAll, updateContext, updateService, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$1, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchIf, catchTag$1, mapError$1, orElseSucceed$1, ignore$1, option$2, result, matchCauseEffect, OnSuccessAndFailureProto, matchEffect, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scopedWith, acquireRelease$1, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, interrupt$2, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkDetach$1, forkIn$1, runForkWith, 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((() => {
2597
+ })), Interrupt, causeInterrupt, findFail, findError$1, hasInterrupts, causeFilterInterruptors, 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, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$2, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die, 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$2, mapEager$1, exitInterrupt$1, exitIsSuccess, exitFilterCause, exitVoid, exitMap, exitAsVoidAll, updateContext, updateService, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchIf, catchTag$1, mapError$1, orElseSucceed$1, ignore$1, option$2, result, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scopedWith, acquireRelease$1, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, interrupt$2, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkDetach$1, forkIn$1, runForkWith, 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((() => {
2598
2598
  init_Array();
2599
2599
  init_Context();
2600
2600
  init_Duration();
@@ -3353,7 +3353,7 @@ var CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations
3353
3353
  };
3354
3354
  provideServiceImpl = (self, service, implementation) => updateContext(self, add$1(service, implementation));
3355
3355
  when$1 = /*#__PURE__*/ dual(2, (self, condition) => flatMap$1(condition, (pass) => pass ? asSome(self) : succeedNone$1));
3356
- forever$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, options) => whileLoop$1({
3356
+ forever$2 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, options) => whileLoop$1({
3357
3357
  while: constTrue,
3358
3358
  body: constant(options?.disableYield ? self : flatMap$1(self, (_) => yieldNow)),
3359
3359
  step: constVoid
@@ -3389,7 +3389,7 @@ var CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations
3389
3389
  mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
3390
3390
  orElseSucceed$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (_) => sync$2(f)));
3391
3391
  ignore$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, options) => {
3392
- if (!options?.log) return matchEffect(self, {
3392
+ if (!options?.log) return matchEffect$1(self, {
3393
3393
  onFailure: (_) => void_$2,
3394
3394
  onSuccess: (_) => void_$2
3395
3395
  });
@@ -3424,14 +3424,14 @@ var CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations
3424
3424
  return this[args];
3425
3425
  }
3426
3426
  });
3427
- matchEffect = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect(self, {
3427
+ matchEffect$1 = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect(self, {
3428
3428
  onFailure: (cause) => {
3429
3429
  const fail = cause.reasons.find(isFailReason$1);
3430
3430
  return fail ? internalCall(() => options.onFailure(fail.error)) : failCause$3(cause);
3431
3431
  },
3432
3432
  onSuccess: options.onSuccess
3433
3433
  }));
3434
- match = /*#__PURE__*/ dual(2, (self, options) => matchEffect(self, {
3434
+ match = /*#__PURE__*/ dual(2, (self, options) => matchEffect$1(self, {
3435
3435
  onFailure: (error) => sync$2(() => options.onFailure(error)),
3436
3436
  onSuccess: (value) => sync$2(() => options.onSuccess(value))
3437
3437
  }));
@@ -3571,6 +3571,7 @@ var CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations
3571
3571
  return isFailure(result) ? void_$2 : f(result.success, exit.cause);
3572
3572
  }));
3573
3573
  onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
3574
+ acquireUseRelease$1 = (acquire, use, release) => uninterruptibleMask((restore) => flatMap$1(acquire, (a) => onExitPrimitive(restore(use(a)), (exit) => release(a, exit), true)));
3574
3575
  interrupt$2 = /*#__PURE__*/ withFiber$1((fiber) => failCause$3(causeInterrupt(fiber.id)));
3575
3576
  uninterruptible$1 = (self) => withFiber$1((fiber) => {
3576
3577
  if (!fiber.interruptible) return self;
@@ -4249,14 +4250,14 @@ var succeed$4, failCause$2, fail$1, void_$1, isSuccess, init_Exit = __esmMin((()
4249
4250
  fail$1 = exitFail;
4250
4251
  void_$1 = exitVoid;
4251
4252
  isSuccess = exitIsSuccess;
4252
- })), TypeId$12, DeferredProto, makeUnsafe$4, _await, completeWith, done, failCause$1, interruptWith, succeed$3, doneUnsafe, init_Deferred = __esmMin((() => {
4253
+ })), TypeId$13, DeferredProto, makeUnsafe$4, _await, completeWith, done, failCause$1, interruptWith, succeed$3, doneUnsafe, init_Deferred = __esmMin((() => {
4253
4254
  init_Function();
4254
4255
  init_core();
4255
4256
  init_effect();
4256
4257
  init_Pipeable();
4257
- TypeId$12 = "~effect/Deferred";
4258
+ TypeId$13 = "~effect/Deferred";
4258
4259
  DeferredProto = {
4259
- [TypeId$12]: {
4260
+ [TypeId$13]: {
4260
4261
  _A: identity,
4261
4262
  _E: identity
4262
4263
  },
@@ -4304,7 +4305,7 @@ var succeed$4, failCause$2, fail$1, void_$1, isSuccess, init_Exit = __esmMin((()
4304
4305
  addFinalizer = scopeAddFinalizer;
4305
4306
  forkUnsafe = scopeForkUnsafe;
4306
4307
  close = scopeClose;
4307
- })), TypeId$11, MemoMapTypeId, memoMapReuse, LayerProto, fromBuildUnsafe, fromBuild, fromBuildMemo, memoMapBuild, MemoMapImpl, makeMemoMapUnsafe, forkMemoMapUnsafe, CurrentMemoMap, buildWithMemoMap, buildWithScope, succeed$2, succeedContext, sync$1, syncContext, mergeAllEffect, mergeAll, init_Layer = __esmMin((() => {
4308
+ })), TypeId$12, MemoMapTypeId, memoMapReuse, LayerProto, fromBuildUnsafe, fromBuild, fromBuildMemo, memoMapBuild, MemoMapImpl, makeMemoMapUnsafe, forkMemoMapUnsafe, CurrentMemoMap, buildWithMemoMap, buildWithScope, succeed$2, succeedContext, sync$1, syncContext, mergeAllEffect, mergeAll, init_Layer = __esmMin((() => {
4308
4309
  init_Context();
4309
4310
  init_Deferred();
4310
4311
  init_Function();
@@ -4312,14 +4313,14 @@ var succeed$4, failCause$2, fail$1, void_$1, isSuccess, init_Exit = __esmMin((()
4312
4313
  init_effect();
4313
4314
  init_Pipeable();
4314
4315
  init_Scope();
4315
- TypeId$11 = "~effect/Layer";
4316
+ TypeId$12 = "~effect/Layer";
4316
4317
  MemoMapTypeId = "~effect/Layer/MemoMap";
4317
4318
  memoMapReuse = (entry, scope) => {
4318
4319
  entry.observers++;
4319
4320
  return andThen$1(scopeAddFinalizerExit(scope, (exit) => entry.finalizer(exit)), entry.effect);
4320
4321
  };
4321
4322
  LayerProto = {
4322
- [TypeId$11]: {
4323
+ [TypeId$12]: {
4323
4324
  _ROut: identity,
4324
4325
  _E: identity,
4325
4326
  _RIn: identity
@@ -4412,7 +4413,7 @@ var succeed$4, failCause$2, fail$1, void_$1, isSuccess, init_Exit = __esmMin((()
4412
4413
  })), Clock, init_Clock = __esmMin((() => {
4413
4414
  init_effect();
4414
4415
  Clock = ClockRef;
4415
- })), TypeId$10, TimeZoneTypeId, Proto$1, ProtoTimeZone, toDateUtc$1;
4416
+ })), TypeId$11, TimeZoneTypeId, Proto$1, ProtoTimeZone, toDateUtc$1;
4416
4417
  var init_dateTime = __esmMin((() => {
4417
4418
  init_Cause();
4418
4419
  init_Equal();
@@ -4423,10 +4424,10 @@ var init_dateTime = __esmMin((() => {
4423
4424
  init_Order();
4424
4425
  init_Pipeable();
4425
4426
  init_Predicate();
4426
- TypeId$10 = "~effect/time/DateTime";
4427
+ TypeId$11 = "~effect/time/DateTime";
4427
4428
  TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
4428
4429
  Proto$1 = {
4429
- [TypeId$10]: TypeId$10,
4430
+ [TypeId$11]: TypeId$11,
4430
4431
  pipe() {
4431
4432
  return pipeArguments(this, arguments);
4432
4433
  },
@@ -4451,7 +4452,7 @@ var init_dateTime = __esmMin((() => {
4451
4452
  }));
4452
4453
  //#endregion
4453
4454
  //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Pull.js
4454
- var catchDone, isDoneCause, isDoneFailure, filterDoneLeftover;
4455
+ var catchDone, isDoneCause, isDoneFailure, filterDone, filterDoneLeftover, matchEffect;
4455
4456
  var init_Pull = __esmMin((() => {
4456
4457
  init_Cause();
4457
4458
  init_Filter();
@@ -4461,8 +4462,119 @@ var init_Pull = __esmMin((() => {
4461
4462
  catchDone = /*#__PURE__*/ dual(2, (effect, f) => catchCauseFilter(effect, filterDoneLeftover, (l) => f(l)));
4462
4463
  isDoneCause = (cause) => cause.reasons.some(isDoneFailure);
4463
4464
  isDoneFailure = (failure) => failure._tag === "Fail" && isDone(failure.error);
4465
+ filterDone = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$6(e) : fail$3(e));
4464
4466
  filterDoneLeftover = /*#__PURE__*/ composePassthrough(findError, (e) => isDone(e) ? succeed$6(e.value) : fail$3(e));
4465
- })), provideLayer, provide$1, init_layer = __esmMin((() => {
4467
+ matchEffect = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect(self, {
4468
+ onSuccess: options.onSuccess,
4469
+ onFailure: (cause) => {
4470
+ const halt = filterDone(cause);
4471
+ return !isFailure(halt) ? options.onDone(halt.success.value) : options.onFailure(halt.failure);
4472
+ }
4473
+ }));
4474
+ }));
4475
+ //#endregion
4476
+ //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/Schedule.js
4477
+ var TypeId$10, CurrentMetadata, ScheduleProto, isSchedule, fromStep, metadataFn, fromStepWithMetadata, toStep, toStepWithMetadata, passthrough$2, spaced, while_, forever$1;
4478
+ var init_Schedule = __esmMin((() => {
4479
+ init_Cause();
4480
+ init_Context();
4481
+ init_Duration();
4482
+ init_Function();
4483
+ init_core();
4484
+ init_effect();
4485
+ init_Pipeable();
4486
+ init_Predicate();
4487
+ init_Pull();
4488
+ TypeId$10 = "~effect/Schedule";
4489
+ CurrentMetadata = /*#__PURE__*/ Reference("effect/Schedule/CurrentMetadata", { defaultValue: /*#__PURE__*/ constant({
4490
+ input: void 0,
4491
+ output: void 0,
4492
+ duration: zero,
4493
+ attempt: 0,
4494
+ start: 0,
4495
+ now: 0,
4496
+ elapsed: 0,
4497
+ elapsedSincePrevious: 0
4498
+ }) });
4499
+ ScheduleProto = {
4500
+ [TypeId$10]: {
4501
+ _Out: identity,
4502
+ _In: identity,
4503
+ _Env: identity
4504
+ },
4505
+ pipe() {
4506
+ return pipeArguments(this, arguments);
4507
+ }
4508
+ };
4509
+ isSchedule = (u) => hasProperty(u, TypeId$10);
4510
+ fromStep = (step) => {
4511
+ const self = Object.create(ScheduleProto);
4512
+ self.step = step;
4513
+ return self;
4514
+ };
4515
+ metadataFn = () => {
4516
+ let n = 0;
4517
+ let previous;
4518
+ let start;
4519
+ return (now, input) => {
4520
+ if (start === void 0) start = now;
4521
+ const elapsed = now - start;
4522
+ const elapsedSincePrevious = previous === void 0 ? 0 : now - previous;
4523
+ previous = now;
4524
+ return {
4525
+ input,
4526
+ attempt: ++n,
4527
+ start,
4528
+ now,
4529
+ elapsed,
4530
+ elapsedSincePrevious
4531
+ };
4532
+ };
4533
+ };
4534
+ fromStepWithMetadata = (step) => fromStep(map$2(step, (f) => {
4535
+ const meta = metadataFn();
4536
+ return (now, input) => f(meta(now, input));
4537
+ }));
4538
+ toStep = (schedule) => catchCause$1(schedule.step, (cause) => succeed$5(() => failCause$3(cause)));
4539
+ toStepWithMetadata = (schedule) => clockWith((clock) => map$2(toStep(schedule), (step) => {
4540
+ const metaFn = metadataFn();
4541
+ return (input) => suspend$1(() => {
4542
+ const now = clock.currentTimeMillisUnsafe();
4543
+ return flatMap$1(step(now, input), ([output, duration]) => {
4544
+ const meta = metaFn(now, input);
4545
+ meta.output = output;
4546
+ meta.duration = duration;
4547
+ return as$1(sleep$1(duration), meta);
4548
+ });
4549
+ });
4550
+ }));
4551
+ passthrough$2 = (self) => fromStep(map$2(toStep(self), (step) => (now, input) => matchEffect(step(now, input), {
4552
+ onSuccess: (result) => succeed$5([input, result[1]]),
4553
+ onFailure: failCause$3,
4554
+ onDone: () => done$1(input)
4555
+ })));
4556
+ spaced = (duration) => {
4557
+ const decoded = fromInputUnsafe(duration);
4558
+ return fromStepWithMetadata(succeed$5((meta) => succeed$5([meta.attempt - 1, decoded])));
4559
+ };
4560
+ while_ = /*#__PURE__*/ dual(2, (self, predicate) => fromStep(map$2(toStep(self), (step) => {
4561
+ const meta = metadataFn();
4562
+ return (now, input) => flatMap$1(step(now, input), (result) => {
4563
+ const [output, duration] = result;
4564
+ const eff = predicate({
4565
+ ...meta(now, input),
4566
+ output,
4567
+ duration
4568
+ });
4569
+ return flatMap$1(isEffect(eff) ? eff : succeed$5(eff), (check) => check ? succeed$5(result) : done$1(output));
4570
+ });
4571
+ })));
4572
+ forever$1 = /*#__PURE__*/ spaced(zero);
4573
+ }));
4574
+ //#endregion
4575
+ //#region node_modules/.pnpm/effect@4.0.0-rc.110/node_modules/effect/dist/internal/layer.js
4576
+ var provideLayer, provide$1;
4577
+ var init_layer = __esmMin((() => {
4466
4578
  init_Context();
4467
4579
  init_Function();
4468
4580
  init_Layer();
@@ -4470,12 +4582,50 @@ var init_Pull = __esmMin((() => {
4470
4582
  init_effect();
4471
4583
  provideLayer = (self, layer, options) => scopedWith((scope) => flatMap$1(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext(self, context)));
4472
4584
  provide$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, source, options) => isContext(source) ? provideContext(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll(...source) : source, options));
4473
- })), all, forEach, whileLoop, promise, tryPromise, succeed$1, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, try_, withFiber, flatMap, andThen, tap, option$1, exit, map, as, asVoid, catchTag, catchCause, mapError, ignore, orElseSucceed, sleep, raceFirst, when, contextWith, provide, acquireRelease, ensuring, onError, onExit, interrupt$1, onInterrupt, uninterruptible, forever, withSpan, forkIn, forkDetach, runFork, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, flatMapEager, fnUntracedEager;
4585
+ })), retryOrElse, retry$1, passthroughForever, buildFromOptions, init_schedule = __esmMin((() => {
4586
+ init_Function();
4587
+ init_Pull();
4588
+ init_Schedule();
4589
+ init_Utils();
4590
+ init_core();
4591
+ init_effect();
4592
+ retryOrElse = /*#__PURE__*/ dual(3, (self, policy, orElse) => flatMap$1(toStepWithMetadata(policy), (step) => {
4593
+ let meta = CurrentMetadata.defaultValue();
4594
+ let lastError;
4595
+ const loop = catch_(suspend$1(() => provideService(self, CurrentMetadata, meta)), (error) => {
4596
+ lastError = error;
4597
+ return flatMap$1(step(error), (meta_) => {
4598
+ meta = meta_;
4599
+ return loop;
4600
+ });
4601
+ });
4602
+ return catchDone(loop, (out) => internalCall(() => orElse(lastError, out)));
4603
+ }));
4604
+ retry$1 = /*#__PURE__*/ dual(2, (self, options) => {
4605
+ const schedule = typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options);
4606
+ return retryOrElse(self, schedule, fail$2);
4607
+ });
4608
+ passthroughForever = /*#__PURE__*/ passthrough$2(forever$1);
4609
+ buildFromOptions = (options) => {
4610
+ let schedule = options.schedule ? passthrough$2(options.schedule) : passthroughForever;
4611
+ if (options.while) schedule = while_(schedule, ({ input }) => {
4612
+ const applied = options.while(input);
4613
+ return isEffect(applied) ? applied : succeed$5(applied);
4614
+ });
4615
+ if (options.until) schedule = while_(schedule, ({ input }) => {
4616
+ const applied = options.until(input);
4617
+ return isEffect(applied) ? map$2(applied, (b) => !b) : succeed$5(!applied);
4618
+ });
4619
+ if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$5(attempt <= options.times));
4620
+ return schedule;
4621
+ };
4622
+ })), all, forEach, whileLoop, promise, tryPromise, succeed$1, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, try_, withFiber, flatMap, andThen, tap, option$1, exit, map, as, asVoid, catchTag, catchCause, mapError, retry, ignore, orElseSucceed, sleep, raceFirst, when, contextWith, provide, acquireRelease, acquireUseRelease, ensuring, onError, onExit, interrupt$1, onInterrupt, uninterruptible, forever, withSpan, forkIn, forkDetach, runFork, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, flatMapEager, fnUntracedEager;
4474
4623
  var init_Effect = __esmMin((() => {
4475
4624
  init_Context();
4476
4625
  init_core();
4477
4626
  init_effect();
4478
4627
  init_layer();
4628
+ init_schedule();
4479
4629
  all = all$1;
4480
4630
  forEach = forEach$1;
4481
4631
  whileLoop = whileLoop$1;
@@ -4503,6 +4653,7 @@ var init_Effect = __esmMin((() => {
4503
4653
  catchTag = catchTag$1;
4504
4654
  catchCause = catchCause$1;
4505
4655
  mapError = mapError$1;
4656
+ retry = retry$1;
4506
4657
  ignore = ignore$1;
4507
4658
  orElseSucceed = orElseSucceed$1;
4508
4659
  sleep = sleep$1;
@@ -4511,13 +4662,14 @@ var init_Effect = __esmMin((() => {
4511
4662
  contextWith = contextWith$1;
4512
4663
  provide = provide$1;
4513
4664
  acquireRelease = acquireRelease$1;
4665
+ acquireUseRelease = acquireUseRelease$1;
4514
4666
  ensuring = ensuring$1;
4515
4667
  onError = onError$1;
4516
4668
  onExit = onExit$1;
4517
4669
  interrupt$1 = interrupt$2;
4518
4670
  onInterrupt = onInterrupt$1;
4519
4671
  uninterruptible = uninterruptible$1;
4520
- forever = forever$1;
4672
+ forever = forever$2;
4521
4673
  withSpan = withSpan$1;
4522
4674
  forkIn = forkIn$1;
4523
4675
  forkDetach = forkDetach$1;
@@ -8210,6 +8362,7 @@ var init_dist = __esmMin((() => {
8210
8362
  init_MutableRef();
8211
8363
  init_Struct();
8212
8364
  init_Redactable();
8365
+ init_Schedule();
8213
8366
  init_annotations();
8214
8367
  init_schema$1();
8215
8368
  init_SubscriptionRef();
@@ -8224,7 +8377,7 @@ var init_error$3 = __esmMin((() => {
8224
8377
  }));
8225
8378
  //#endregion
8226
8379
  //#region src/service/forge/service.ts
8227
- var Forge, LIMIT, TIMEOUT_MS$1, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Row, decode, stateOf$1, ask, show, read, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named, head, bodyFor, review, ForgeLive;
8380
+ var Forge, LIMIT, TIMEOUT_MS$1, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Row, decode, stateOf$1, ask, show, read, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named, head, sideName, commentBody, bodyFor, Landed, readLanded, landedIn, review, ForgeLive;
8228
8381
  var init_service$2 = __esmMin((() => {
8229
8382
  init_dist();
8230
8383
  init_error$3();
@@ -8355,15 +8508,31 @@ var init_service$2 = __esmMin((() => {
8355
8508
  head = fn("Forge.head")(function* (repo, branch) {
8356
8509
  return (yield* named(repo, branch)).headRefOid;
8357
8510
  });
8511
+ sideName = (side) => side === "old" ? "LEFT" : "RIGHT";
8512
+ commentBody = (one) => ({
8513
+ path: one.path,
8514
+ line: one.line,
8515
+ side: sideName(one.side),
8516
+ body: one.body,
8517
+ ...one.start < one.line ? {
8518
+ start_line: one.start,
8519
+ start_side: sideName(one.side)
8520
+ } : {}
8521
+ });
8358
8522
  bodyFor = (comments) => JSON.stringify({
8359
8523
  event: "COMMENT",
8360
- comments: comments.map((one) => ({
8361
- path: one.path,
8362
- line: one.line,
8363
- side: one.side === "old" ? "LEFT" : "RIGHT",
8364
- body: one.body
8365
- }))
8524
+ comments: comments.map(commentBody)
8366
8525
  });
8526
+ Landed = Struct({ comments: optionalKey(ArraySchema(Struct({
8527
+ path: String$1,
8528
+ line: optionalKey(Int)
8529
+ }))) });
8530
+ readLanded = decodeUnknownEffect(Landed);
8531
+ landedIn = (said, asked) => {
8532
+ const back = runSync(orElseSucceed(flatMap(try_(() => JSON.parse(said)), (value) => orElseSucceed(readLanded(value), () => ({ comments: void 0 }))), () => ({ comments: void 0 }))).comments;
8533
+ if (back === void 0) return asked.map((one) => `${one.path}:${one.line}`);
8534
+ return back.map((one) => `${one.path}:${one.line ?? 0}`);
8535
+ };
8367
8536
  review = fn("Forge.review")(function* (repo, branch, comments) {
8368
8537
  const pull = yield* named(repo, branch);
8369
8538
  const route = `repos/${(yield* gh(repo, [
@@ -8374,7 +8543,7 @@ var init_service$2 = __esmMin((() => {
8374
8543
  "-q",
8375
8544
  ".nameWithOwner"
8376
8545
  ])).trim()}/pulls/${pull.number}/reviews`;
8377
- yield* gh(repo, [
8546
+ const said = yield* gh(repo, [
8378
8547
  "api",
8379
8548
  "--method",
8380
8549
  "POST",
@@ -8383,7 +8552,7 @@ var init_service$2 = __esmMin((() => {
8383
8552
  "-"
8384
8553
  ], bodyFor(comments));
8385
8554
  return {
8386
- landed: comments.map((one) => `${one.path}:${one.line}`),
8555
+ landed: landedIn(said, comments),
8387
8556
  url: pull.url
8388
8557
  };
8389
8558
  });
@@ -8529,7 +8698,7 @@ var init_paths = __esmMin((() => {
8529
8698
  upgradePath = (root) => join(root, "upgrade.json");
8530
8699
  reportsDir = (root) => join(root, "reports");
8531
8700
  reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
8532
- })), Store, ensureDir, readOptional, missing$1, damaged, jsonOf, decoded, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asDrafts, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, cursorOps, settingsOps, upgradeOps, reportOps, HEAD_REF, gitDirOf, headOf$1, repoOf$2, keyOf$2, wasKeyOf, there, adopted, moved, adopt, keyIn, answerOps, draftsOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
8701
+ })), Store, ensureDir, readOptional, missing$1, damaged, jsonOf, decoded, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asDrafts, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, cursorOps, settingsOps, upgradeOps, reportOps, HEAD_REF, gitDirOf, headOf$1, repoOf$2, keyOf$2, wasKeyOf, there, adopted, moved, adopt, keyIn, answerOps, draftsOps, layersOps, inboxOps, LOCK_TRIES, LOCK_WAIT_MS, LOCK_STALE_MS, held$1, stale$1, stolen, taken, freed, stateOps, makeStore, storeAt;
8533
8702
  var init_service$1 = __esmMin((() => {
8534
8703
  init_dist();
8535
8704
  init_error$2();
@@ -8808,34 +8977,63 @@ var init_service$1 = __esmMin((() => {
8808
8977
  })
8809
8978
  };
8810
8979
  };
8980
+ LOCK_TRIES = 60;
8981
+ LOCK_WAIT_MS = 25;
8982
+ LOCK_STALE_MS = 5e3;
8983
+ held$1 = (path) => tryPromise({
8984
+ try: () => writeFile(path, `${process.pid}`, { flag: "wx" }),
8985
+ catch: (cause) => new StoreUnwritable({
8986
+ path,
8987
+ reason: String(cause)
8988
+ })
8989
+ });
8990
+ stale$1 = (path) => promise(() => stat(path).then((found) => Date.now() - found.mtimeMs > LOCK_STALE_MS, () => false));
8991
+ stolen = (path, cause) => flatMap(stale$1(path), (old) => old ? flatMap(promise(() => rm(path, { force: true })), () => held$1(path)) : fail(cause));
8992
+ taken = (path) => retry(held$1(path).pipe(catchTag("StoreUnwritable", (cause) => stolen(path, cause))), {
8993
+ times: LOCK_TRIES,
8994
+ schedule: spaced(LOCK_WAIT_MS)
8995
+ });
8996
+ freed = (path) => promise(() => rm(path, { force: true }));
8811
8997
  stateOps = (root) => {
8998
+ const state = fn("Store.state")(function* (worktreePath) {
8999
+ const key = yield* keyIn(root, worktreePath);
9000
+ const path = statePath(root, key);
9001
+ const raw = yield* readOptional(path);
9002
+ return yield* match$3(raw, {
9003
+ onNone: () => succeed$1(emptyBranchState),
9004
+ onSome: (text) => parseState(path, text)
9005
+ });
9006
+ });
9007
+ const saveState = fn("Store.saveState")(function* (worktreePath, next) {
9008
+ const key = yield* keyIn(root, worktreePath);
9009
+ const path = statePath(root, key);
9010
+ yield* ensureDir(branchDir(root, key));
9011
+ yield* tryPromise({
9012
+ try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
9013
+ catch: (cause) => new StoreUnwritable({
9014
+ path,
9015
+ reason: String(cause)
9016
+ })
9017
+ });
9018
+ });
9019
+ const changeState = fn("Store.changeState")(function* (worktreePath, change) {
9020
+ const key = yield* keyIn(root, worktreePath);
9021
+ yield* ensureDir(branchDir(root, key));
9022
+ const lock = `${statePath(root, key)}.lock`;
9023
+ yield* acquireUseRelease(taken(lock), () => under(worktreePath, change), () => freed(lock));
9024
+ });
9025
+ const under = fn("Store.under")(function* (worktreePath, change) {
9026
+ yield* saveState(worktreePath, change(yield* state(worktreePath)));
9027
+ });
8812
9028
  return {
8813
- state: fn("Store.state")(function* (worktreePath) {
8814
- const key = yield* keyIn(root, worktreePath);
8815
- const path = statePath(root, key);
8816
- const raw = yield* readOptional(path);
8817
- return yield* match$3(raw, {
8818
- onNone: () => succeed$1(emptyBranchState),
8819
- onSome: (text) => parseState(path, text)
8820
- });
8821
- }),
8822
- saveState: fn("Store.saveState")(function* (worktreePath, next) {
8823
- const key = yield* keyIn(root, worktreePath);
8824
- const path = statePath(root, key);
8825
- yield* ensureDir(branchDir(root, key));
8826
- yield* tryPromise({
8827
- try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
8828
- catch: (cause) => new StoreUnwritable({
8829
- path,
8830
- reason: String(cause)
8831
- })
8832
- });
8833
- })
9029
+ state,
9030
+ saveState,
9031
+ changeState
8834
9032
  };
8835
9033
  };
8836
9034
  makeStore = (root) => {
8837
9035
  const { submit, inbox } = inboxOps(root);
8838
- const { state, saveState } = stateOps(root);
9036
+ const { state, saveState, changeState } = stateOps(root);
8839
9037
  const talk = answerOps(root);
8840
9038
  const cursors = cursorOps(state, inbox, talk.answers);
8841
9039
  return {
@@ -8845,6 +9043,7 @@ var init_service$1 = __esmMin((() => {
8845
9043
  inbox,
8846
9044
  state,
8847
9045
  saveState,
9046
+ changeState,
8848
9047
  saveReport: reportOps(root),
8849
9048
  ...settingsOps(root),
8850
9049
  ...upgradeOps(root),
@@ -8882,12 +9081,13 @@ var init_anchor = __esmMin((() => {
8882
9081
  onNone: () => [],
8883
9082
  onSome: (n) => [n]
8884
9083
  }));
8885
- anchorFor = (patch, from, to) => {
9084
+ anchorFor = (patch, from, to, wanted) => {
8886
9085
  const [low, high] = from <= to ? [from, to] : [to, from];
8887
9086
  const rows = patch.rows.slice(low, high + 1);
8888
9087
  if (rows.length === 0) return none();
8889
- const side = sideOf(rows);
8890
- const lines = linesOn(rows, side);
9088
+ const side = wanted ?? sideOf(rows);
9089
+ const onSide = rows.filter((row) => isSome(lineOn(row, side)));
9090
+ const lines = linesOn(onSide, side);
8891
9091
  if (lines.length === 0) return none();
8892
9092
  return some({
8893
9093
  path: patch.path,
@@ -8895,7 +9095,7 @@ var init_anchor = __esmMin((() => {
8895
9095
  side,
8896
9096
  start: Math.min(...lines),
8897
9097
  end: Math.max(...lines),
8898
- snippet: rows.map((row) => row.text).join("\n")
9098
+ snippet: onSide.map((row) => row.text).join("\n")
8899
9099
  });
8900
9100
  };
8901
9101
  }));
@@ -9552,10 +9752,10 @@ var init_commands = __esmMin((() => {
9552
9752
  });
9553
9753
  const current = yield* store.state(reading.worktree.path);
9554
9754
  const next = vouch(current.vouches, file, blob);
9555
- yield* store.saveState(reading.worktree.path, {
9556
- ...current,
9557
- vouches: next
9558
- });
9755
+ yield* store.changeState(reading.worktree.path, (was) => ({
9756
+ ...was,
9757
+ vouches: vouch(was.vouches, file, blob)
9758
+ }));
9559
9759
  return {
9560
9760
  vouched: patches.map((patch) => ({
9561
9761
  path: patch.path,
@@ -9661,7 +9861,7 @@ var init_commands = __esmMin((() => {
9661
9861
  const rows = rowsCovering(resolved, request.side, request.start, request.end);
9662
9862
  const first = rows[0];
9663
9863
  const last = rows.at(-1);
9664
- const anchor = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
9864
+ const anchor = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last, request.side);
9665
9865
  return yield* match$3(anchor, {
9666
9866
  onNone: () => new UnselectableRange({
9667
9867
  file: request.file,
@@ -9710,10 +9910,10 @@ var init_commands = __esmMin((() => {
9710
9910
  };
9711
9911
  yield* store.submit(worktree.path, batch);
9712
9912
  const current = yield* store.state(worktree.path);
9713
- if (Object.hasOwn(current.settled, root)) yield* store.saveState(worktree.path, {
9714
- ...current,
9715
- settled: without$1(current.settled, root)
9716
- });
9913
+ if (Object.hasOwn(current.settled, root)) yield* store.changeState(worktree.path, (was) => ({
9914
+ ...was,
9915
+ settled: without$1(was.settled, root)
9916
+ }));
9717
9917
  return batch;
9718
9918
  });
9719
9919
  listPatches = fn("Cli.listPatches")(function* (repo, branch, context = CONTEXT, only) {
@@ -9857,11 +10057,10 @@ var init_commands = __esmMin((() => {
9857
10057
  setBase = fn("Cli.setBase")(function* (repo, branch, base) {
9858
10058
  const store = yield* Store;
9859
10059
  const based = yield* baseFor(repo, branch, base);
9860
- const current = yield* store.state(based.worktree.path);
9861
- yield* store.saveState(based.worktree.path, {
9862
- ...current,
10060
+ yield* store.changeState(based.worktree.path, (was) => ({
10061
+ ...was,
9863
10062
  base
9864
- });
10063
+ }));
9865
10064
  return {
9866
10065
  branch,
9867
10066
  base: based.base,
@@ -9871,11 +10070,10 @@ var init_commands = __esmMin((() => {
9871
10070
  clearBase = fn("Cli.clearBase")(function* (repo, branch) {
9872
10071
  const store = yield* Store;
9873
10072
  const worktree = yield* findBranch(repo, branch);
9874
- const current = yield* store.state(worktree.path);
9875
- yield* store.saveState(worktree.path, {
9876
- ...current,
10073
+ yield* store.changeState(worktree.path, (was) => ({
10074
+ ...was,
9877
10075
  base: ""
9878
- });
10076
+ }));
9879
10077
  const based = yield* baseFor(repo, branch);
9880
10078
  return {
9881
10079
  branch,
@@ -9899,10 +10097,10 @@ var init_commands = __esmMin((() => {
9899
10097
  };
9900
10098
  const read = { ...current.read };
9901
10099
  for (const one of owed) read[one.id] = one.seen;
9902
- yield* store.saveState(worktree.path, {
9903
- ...current,
10100
+ yield* store.changeState(worktree.path, (was) => ({
10101
+ ...was,
9904
10102
  read
9905
- });
10103
+ }));
9906
10104
  return {
9907
10105
  id,
9908
10106
  unread: 0
@@ -9977,6 +10175,7 @@ var init_drafts = __esmMin((() => {
9977
10175
  };
9978
10176
  commentOf = (draft) => ({
9979
10177
  path: draft.anchor.path,
10178
+ start: draft.anchor.start,
9980
10179
  line: draft.anchor.end,
9981
10180
  side: draft.anchor.side,
9982
10181
  body: draft.body
@@ -9994,11 +10193,13 @@ var init_drafts = __esmMin((() => {
9994
10193
  now: head
9995
10194
  });
9996
10195
  const sent = yield* forge.review(repo, branch, held.map(commentOf));
9997
- yield* store.saveDrafts(worktree.path, []);
10196
+ const gone = new Set(held.map((one) => one.id));
10197
+ const waiting = (yield* store.drafts(worktree.path)).filter((one) => !gone.has(one.id));
10198
+ yield* store.saveDrafts(worktree.path, waiting);
9998
10199
  return {
9999
10200
  sent: sent.landed.length,
10000
10201
  url: sent.url,
10001
- held: 0
10202
+ held: waiting.length
10002
10203
  };
10003
10204
  });
10004
10205
  }));
@@ -10256,7 +10457,7 @@ var init_pane = __esmMin((() => {
10256
10457
  init_drafts();
10257
10458
  init_init();
10258
10459
  init_pane();
10259
- var version$1 = "0.1.0-alpha.109";
10460
+ var version$1 = "0.1.0-alpha.110";
10260
10461
  //#endregion
10261
10462
  //#region src/cli/upgrade.ts
10262
10463
  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, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -10956,19 +11157,18 @@ var init_threads = __esmMin((() => {
10956
11157
  settleIn = fn("Cli.settleIn")(function* (worktree, id, at) {
10957
11158
  const store = yield* Store;
10958
11159
  if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
10959
- const current = yield* store.state(worktree.path);
10960
11160
  const replies = (yield* store.answers(worktree.path)).filter((entry) => entry.comment === id);
10961
- yield* store.saveState(worktree.path, {
10962
- ...current,
11161
+ yield* store.changeState(worktree.path, (was) => ({
11162
+ ...was,
10963
11163
  settled: {
10964
- ...current.settled,
11164
+ ...was.settled,
10965
11165
  [id]: at
10966
11166
  },
10967
11167
  read: {
10968
- ...current.read,
11168
+ ...was.read,
10969
11169
  [id]: replies.length
10970
11170
  }
10971
- });
11171
+ }));
10972
11172
  return { settled: id };
10973
11173
  });
10974
11174
  settleThread = fn("Cli.settleThread")(function* (repo, branch, id, at) {
@@ -10976,20 +11176,19 @@ var init_threads = __esmMin((() => {
10976
11176
  });
10977
11177
  removeIn = fn("Cli.removeIn")(function* (worktree, id, at) {
10978
11178
  const store = yield* Store;
10979
- const current = yield* store.state(worktree.path);
10980
11179
  if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
10981
11180
  const replies = (yield* store.answers(worktree.path)).filter((entry) => entry.comment === id);
10982
- yield* store.saveState(worktree.path, {
10983
- ...current,
11181
+ yield* store.changeState(worktree.path, (was) => ({
11182
+ ...was,
10984
11183
  removed: {
10985
- ...current.removed,
11184
+ ...was.removed,
10986
11185
  [id]: at
10987
11186
  },
10988
11187
  read: {
10989
- ...current.read,
11188
+ ...was.read,
10990
11189
  [id]: replies.length
10991
11190
  }
10992
- });
11191
+ }));
10993
11192
  return { removed: id };
10994
11193
  });
10995
11194
  removeComment = fn("Cli.removeComment")(function* (repo, branch, id, at) {
@@ -11000,11 +11199,10 @@ var init_threads = __esmMin((() => {
11000
11199
  const store = yield* Store;
11001
11200
  const worktree = yield* findBranch(repo, branch);
11002
11201
  if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
11003
- const current = yield* store.state(worktree.path);
11004
- yield* store.saveState(worktree.path, {
11005
- ...current,
11006
- removed: without(current.removed, id)
11007
- });
11202
+ yield* store.changeState(worktree.path, (was) => ({
11203
+ ...was,
11204
+ removed: without(was.removed, id)
11205
+ }));
11008
11206
  return { restored: id };
11009
11207
  });
11010
11208
  settleRead = fn("Cli.settleRead")(function* (repo, branch, at) {
@@ -11018,13 +11216,14 @@ var init_threads = __esmMin((() => {
11018
11216
  return said > 0 && (current.read[id] ?? 0) >= said && !Object.hasOwn(current.settled, id) && !Object.hasOwn(current.removed, id);
11019
11217
  });
11020
11218
  if (ripe.length === 0) return { settled: 0 };
11021
- yield* store.saveState(worktree.path, {
11022
- ...current,
11219
+ const now = Object.fromEntries(ripe.map((id) => [id, at]));
11220
+ yield* store.changeState(worktree.path, (was) => ({
11221
+ ...was,
11023
11222
  settled: {
11024
- ...current.settled,
11025
- ...Object.fromEntries(ripe.map((id) => [id, at]))
11223
+ ...was.settled,
11224
+ ...now
11026
11225
  }
11027
- });
11226
+ }));
11028
11227
  return { settled: ripe.length };
11029
11228
  });
11030
11229
  }));
@@ -12999,7 +13198,14 @@ var init_command = __esmMin((() => {
12999
13198
  category: "Moving",
13000
13199
  title: "Next line",
13001
13200
  keys: ["down", "j"],
13002
- screens: ["review"]
13201
+ screens: ["review"],
13202
+ panes: [
13203
+ "tree",
13204
+ "diff",
13205
+ "review"
13206
+ ],
13207
+ hint: "move",
13208
+ rank: 0
13003
13209
  }),
13004
13210
  command({
13005
13211
  action: "cursor.prev",
@@ -13394,7 +13600,7 @@ var init_command = __esmMin((() => {
13394
13600
  keys: ["v"],
13395
13601
  screens: ["review"],
13396
13602
  hint: "select",
13397
- rank: 3
13603
+ rank: 4
13398
13604
  }),
13399
13605
  command({
13400
13606
  action: "compose.open",
@@ -13404,7 +13610,7 @@ var init_command = __esmMin((() => {
13404
13610
  keys: ["c", "return"],
13405
13611
  screens: ["review"],
13406
13612
  hint: "comment",
13407
- rank: 4
13613
+ rank: 3
13408
13614
  }),
13409
13615
  command({
13410
13616
  action: "report.open",
@@ -13568,7 +13774,7 @@ var init_match = __esmMin((() => {
13568
13774
  }
13569
13775
  return needle.length === 0;
13570
13776
  };
13571
- label = (entry) => `${entry.category} ${entry.title}`.toLowerCase();
13777
+ label = (entry) => `${entry.category} ${entry.title} ${entry.keys.join(" ")}`.toLowerCase();
13572
13778
  matches = (entry, query) => query.toLowerCase().split(/\s+/).filter((word) => word.length > 0).every((word) => subsequence(label(entry), word));
13573
13779
  closeness = (entry, query) => {
13574
13780
  const wanted = query.trim().toLowerCase();
@@ -15160,7 +15366,7 @@ var init_diffview = __esmMin((() => {
15160
15366
  }));
15161
15367
  //#endregion
15162
15368
  //#region src/tui/render.ts
15163
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerMark, layerLead, layerGutter, layerText, litRow, leftOver, titlePaint, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
15369
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, keysOf, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, chipWidth, WAYS_OUT, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerMark, layerLead, layerGutter, layerText, litRow, leftOver, titlePaint, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
15164
15370
  var init_render = __esmMin((() => {
15165
15371
  init_command();
15166
15372
  init_layers$1();
@@ -15182,7 +15388,7 @@ var init_render = __esmMin((() => {
15182
15388
  reportActions = (full) => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^t")} ${fg(palette.muted)(full ? "sending everything" : "sending the least")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
15183
15389
  actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("send it")}`;
15184
15390
  SNIPPET_LINES = 4;
15185
- PALETTE_KEY = 7;
15391
+ PALETTE_KEY = 11;
15186
15392
  PALETTE_TITLE = 60;
15187
15393
  PALETTE_GAP = 2;
15188
15394
  PALETTE_CHROME = 4;
@@ -15211,8 +15417,9 @@ var init_render = __esmMin((() => {
15211
15417
  homeWidth = (width, longest, said = STATE_MIN) => Math.max(0, Math.min(width - 2, Math.min(PANEL_MAX, Math.max(BRANCH_WIDTH, longest + BRANCH_FIXED + Math.max(STATE_MIN, said)))));
15212
15418
  longestName = (state) => Math.max(0, ...state.branches.map((branch) => branch.branch.length));
15213
15419
  longestState = (state) => Math.max(0, ...state.branches.map((branch) => stateCell(state, branch).length));
15420
+ keysOf = (entry) => entry.keys.map((one) => displayKey(one)).join(" ");
15214
15421
  commandRow = (entry, room) => {
15215
- const key = clip(displayKey(entry.keys[0] ?? ""), 5).padEnd(PALETTE_KEY);
15422
+ const key = clip(keysOf(entry), 9).padEnd(PALETTE_KEY);
15216
15423
  const left = Math.max(1, Math.min(PALETTE_TITLE, room - PALETTE_KEY - entry.category.length - PALETTE_GAP));
15217
15424
  return `${key}${clip(entry.title, left - PALETTE_GAP).padEnd(left)}${entry.category}`;
15218
15425
  };
@@ -15681,16 +15888,21 @@ var init_render = __esmMin((() => {
15681
15888
  for (let at = 0; at < chunks.length; at += CHIP_CHUNKS) chips.push(chunks.slice(at, at + CHIP_CHUNKS));
15682
15889
  return chips;
15683
15890
  };
15891
+ chipWidth = (chip) => chip.reduce((total, chunk) => total + chunk.text.length, 0);
15892
+ WAYS_OUT = 2;
15684
15893
  keptWithin = (chunks, room) => {
15894
+ const chips = paired(chunks);
15895
+ if (chips.length <= WAYS_OUT) return chips.flat();
15896
+ const ways = chips.slice(-2);
15685
15897
  const kept = [];
15686
- let used = 0;
15687
- for (const chip of paired(chunks).toReversed()) {
15688
- const width = chip.reduce((total, chunk) => total + chunk.text.length, 0);
15898
+ let used = ways.reduce((total, chip) => total + chipWidth(chip), 0);
15899
+ for (const chip of chips.slice(0, -2)) {
15900
+ const width = chipWidth(chip);
15689
15901
  if (used + width > room) break;
15690
- kept.unshift(chip);
15902
+ kept.push(chip);
15691
15903
  used += width;
15692
15904
  }
15693
- return kept.flat();
15905
+ return [...kept, ...ways].flat();
15694
15906
  };
15695
15907
  CHIP_CHUNKS = 3;
15696
15908
  shortPath = (path) => {
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.109",
26
+ "version": "0.1.0-alpha.110",
27
27
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
28
  "license": "MIT",
29
29
  "repository": {