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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.205
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(reading order): `layers show` reports the layers stale and names each span as `outdated` once the code under it changes, even before a commit.
8
+
9
+ <details><summary>What was wrong</summary>
10
+
11
+ A reading order went stale only when the commit moved. An agent that edited a file after writing its layers, without committing, was told the layers were current while their spans pointed at other code.
12
+
13
+ </details>
14
+
15
+ feat(reading order): `layers set` names each TypeScript or TSX function, method or function-valued constant whose changed lines two layers share, under `split`, with its lines and those layers.
16
+
17
+ <details><summary>What was wrong</summary>
18
+
19
+ Spans counted on one version of a file and set on another covered every line, so coverage came back complete while a function was read half in one layer and half in another.
20
+
21
+ </details>
22
+
3
23
  ## 0.1.0-alpha.204
4
24
 
5
25
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/main.js CHANGED
@@ -8,6 +8,7 @@ import { createInterface } from "node:readline";
8
8
  import { join, resolve } from "node:path";
9
9
  import { promisify } from "node:util";
10
10
  import { homedir, hostname, platform } from "node:os";
11
+ import { Language, Parser } from "web-tree-sitter";
11
12
  import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, KeyEvent, LineNumberRenderable, RGBA, StyledText, SyntaxStyle, TextRenderable, TextareaRenderable, addDefaultParsers, bg, bold, createCliRenderer, defaultTextareaKeyBindings, fg, fonts, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
12
13
  //#region \0rolldown/runtime.js
13
14
  var __defProp = Object.defineProperty;
@@ -2686,7 +2687,7 @@ var init_references = __esmMin((() => {
2686
2687
  };
2687
2688
  };
2688
2689
  spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
2689
- })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService$1, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, tapCauseFilter, tapError$1, catchIf, catchFilter, catchTag$1, catchTags$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, filter$2, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2690
+ })), Interrupt, causeInterrupt, findFail, findError$1, findDefect, hasInterrupts, causeFilterInterruptors, hasInterruptsOnly$1, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberJoin, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$5, failCause$3, fail$2, sync$1, suspend$1, yieldNowWith, yieldNow, succeedNone$1, failCauseSync$1, die$1, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$3, mapEager$1, mapErrorEager$1, catchEager$1, exitInterrupt$1, exitIsSuccess, exitIsFailure, exitFilterCause, exitHasInterrupts, exitVoid, exitMap, exitMapError, exitAsVoidAll, updateContext, updateService, context$1, getContext, contextWith$1, provideContext, provideService$1, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$1, tapCauseFilter, tapError$1, catchIf, catchFilter, catchTag$1, catchTags$1, mapError$1, orDie$1, orElseSucceed$1, ignore$1, option$3, result$1, matchCauseEffect, OnSuccessAndFailureProto, matchEffect$1, match, matchEager, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scoped$1, scopedWith, acquireRelease$1, addFinalizer$2, onExitPrimitive, onExit$1, ensuring$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, acquireUseRelease$1, cachedInvalidateWithTTL, cachedWithTTL, cached$1, interrupt$1, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask$1, all$1, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, filter$2, forkUnsafe$1, forkIn$1, forkScoped$1, runForkWith$1, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, endSpan, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, nanosPerMilli, monotonicNowNanos, wallTimeNanos, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
2690
2691
  init_Array();
2691
2692
  init_Context();
2692
2693
  init_Duration();
@@ -3729,6 +3730,35 @@ var init_references = __esmMin((() => {
3729
3730
  }));
3730
3731
  onInterrupt$1 = /*#__PURE__*/ dual(2, (self, finalizer) => onErrorFilter(causeFilterInterruptors, finalizer)(self));
3731
3732
  acquireUseRelease$1 = (acquire, use, release) => uninterruptibleMask$1((restore) => flatMap$1(acquire, (a) => onExitPrimitive(restore(use(a)), (exit) => release(a, exit), true)));
3733
+ cachedInvalidateWithTTL = /*#__PURE__*/ dual(2, (self, ttl) => sync$1(() => {
3734
+ const ttlMillis = toMillis(fromInputUnsafe(ttl));
3735
+ const isFinite = Number.isFinite(ttlMillis);
3736
+ const latch = makeLatchUnsafe(false);
3737
+ let expiresAt = 0;
3738
+ let running = false;
3739
+ let exit;
3740
+ const wait = flatMap$1(latch.await, () => exit);
3741
+ return [withFiber$1((fiber) => {
3742
+ const clock = fiber.getRef(ClockRef);
3743
+ const now = isFinite ? clock.currentTimeMillisUnsafe() : 0;
3744
+ if (running || now < expiresAt) return exit ?? wait;
3745
+ running = true;
3746
+ latch.closeUnsafe();
3747
+ exit = void 0;
3748
+ return onExit$1(self, (exit_) => sync$1(() => {
3749
+ running = false;
3750
+ expiresAt = clock.currentTimeMillisUnsafe() + ttlMillis;
3751
+ exit = exit_;
3752
+ latch.openUnsafe();
3753
+ }));
3754
+ }), sync$1(() => {
3755
+ expiresAt = 0;
3756
+ latch.closeUnsafe();
3757
+ exit = void 0;
3758
+ })];
3759
+ }));
3760
+ cachedWithTTL = /*#__PURE__*/ dual(2, (self, timeToLive) => map$3(cachedInvalidateWithTTL(self, timeToLive), (tuple) => tuple[0]));
3761
+ cached$1 = (self) => cachedWithTTL(self, infinity);
3732
3762
  interrupt$1 = /*#__PURE__*/ withFiber$1((fiber) => failCause$3(causeInterrupt(fiber.id)));
3733
3763
  uninterruptible$1 = (self) => withFiber$1((fiber) => {
3734
3764
  if (!fiber.interruptible) return self;
@@ -4813,7 +4843,7 @@ var repeatOrElse, retryOrElse, repeat$1, retry$1, passthroughForever, buildFromO
4813
4843
  if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$5(attempt <= options.times));
4814
4844
  return schedule;
4815
4845
  };
4816
- })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchTags, catchCause, catchDefect, mapError, orDie, tapError, retry, ignore, orElseSucceed, sleep, raceFirst, filter$1, when, context, contextWith, provide, provideService, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4846
+ })), isEffect, all, forEach, whileLoop, promise, tryPromise, succeed$1, succeedNone, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, die, try_, withFiber, flatMap, andThen, tap, result, option$2, exit, map$1, as, asVoid, catchTag, catchTags, catchCause, catchDefect, mapError, orDie, tapError, retry, ignore, orElseSucceed, sleep, raceFirst, filter$1, when, context, contextWith, provide, provideService, scoped, acquireRelease, acquireUseRelease, addFinalizer, ensuring, onError, onExit, cached, interrupt, onInterrupt, uninterruptible, uninterruptibleMask, forever, repeat, withSpan, forkIn, forkScoped, runFork, runForkWith, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, mapErrorEager, flatMapEager, catchEager, fnUntracedEager;
4817
4847
  var init_Effect = __esmMin((() => {
4818
4848
  init_Context();
4819
4849
  init_core();
@@ -4873,6 +4903,7 @@ var init_Effect = __esmMin((() => {
4873
4903
  ensuring = ensuring$1;
4874
4904
  onError = onError$1;
4875
4905
  onExit = onExit$1;
4906
+ cached = cached$1;
4876
4907
  interrupt = interrupt$1;
4877
4908
  onInterrupt = onInterrupt$1;
4878
4909
  uninterruptible = uninterruptible$1;
@@ -10083,11 +10114,11 @@ var init_config = __esmMin((() => {
10083
10114
  //#region package.json
10084
10115
  init_pane();
10085
10116
  init_config();
10086
- var version$1 = "0.1.0-alpha.204";
10117
+ var version$1 = "0.1.0-alpha.205";
10087
10118
  //#endregion
10088
10119
  //#region src/cli/error.ts
10089
10120
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10090
- var init_error$5 = __esmMin((() => {
10121
+ var init_error$6 = __esmMin((() => {
10091
10122
  init_dist();
10092
10123
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
10093
10124
  MissingOption = class extends TaggedError("MissingOption") {};
@@ -10103,7 +10134,7 @@ var init_error$5 = __esmMin((() => {
10103
10134
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$2, newer, DistTags, readTags, unanswered, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
10104
10135
  var init_upgrade$1 = __esmMin((() => {
10105
10136
  init_dist();
10106
- init_error$5();
10137
+ init_error$6();
10107
10138
  PACKAGE = "@eliya-oss/agent-diff";
10108
10139
  TAG = "alpha";
10109
10140
  RELEASES = "https://github.com/Newbie012/agent-diff/releases/latest";
@@ -11142,7 +11173,7 @@ var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, on
11142
11173
  var init_parse$1 = __esmMin((() => {
11143
11174
  init_dist();
11144
11175
  init_catalog();
11145
- init_error$5();
11176
+ init_error$6();
11146
11177
  FLAG = /^--(?<name>[^=]+)(?:=(?<value>[\s\S]*))?$/;
11147
11178
  REPEATED = /* @__PURE__ */ new Set(["choice"]);
11148
11179
  MANY = "\n";
@@ -11543,7 +11574,7 @@ var init_report$1 = __esmMin((() => {
11543
11574
  var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11544
11575
  var init_serve = __esmMin((() => {
11545
11576
  init_dist();
11546
- init_error$5();
11577
+ init_error$6();
11547
11578
  init_report$1();
11548
11579
  init_parse$1();
11549
11580
  init_catalog();
@@ -11682,7 +11713,7 @@ var init_cli = __esmMin((() => {
11682
11713
  init_parse$1();
11683
11714
  init_catalog();
11684
11715
  init_report$1();
11685
- init_error$5();
11716
+ init_error$6();
11686
11717
  init_serve();
11687
11718
  }));
11688
11719
  //#endregion
@@ -12272,7 +12303,7 @@ var init_patch = __esmMin((() => {
12272
12303
  //#endregion
12273
12304
  //#region src/service/git/error.ts
12274
12305
  var GitCommandFailed, NotARepository, FileUnreadable;
12275
- var init_error$4 = __esmMin((() => {
12306
+ var init_error$5 = __esmMin((() => {
12276
12307
  init_dist();
12277
12308
  GitCommandFailed = class extends TaggedError("GitCommandFailed") {};
12278
12309
  NotARepository = class extends TaggedError("NotARepository") {};
@@ -12283,7 +12314,7 @@ var init_error$4 = __esmMin((() => {
12283
12314
  var exec, MAX_OUTPUT, git, gitOrEmpty;
12284
12315
  var init_run = __esmMin((() => {
12285
12316
  init_dist();
12286
- init_error$4();
12317
+ init_error$5();
12287
12318
  exec = promisify(execFile);
12288
12319
  MAX_OUTPUT = 67108864;
12289
12320
  git = fn("Git.run")(function* (cwd, args) {
@@ -12305,9 +12336,9 @@ var init_run = __esmMin((() => {
12305
12336
  return yield* git(cwd, args).pipe(catchTag("GitCommandFailed", () => succeed$1("")));
12306
12337
  });
12307
12338
  })), CACHE_SIZE, NAME_TTL, FRESH_TTL, SPLIT$1, DEFAULT_BRANCH_CANDIDATES, PLAIN_PATHS, STAT, Git, parseStat, readEntries, verifiedIn, findDefaultBranch, partsOf$1, findMergeBase, toWorktree, branchTips, findParent, splitLines, absent, readText, settled, seenAs, listWorktrees, readDiff, readStat, readSource, readBlob, NO_CONTENT, keepContent, findKept, readBetween, readGrep, GENERATED_SAID, markedGenerated, readGenerated, askRepo, LINKED_GIT_DIR, HEAD_REF, gitDirOf, findCommonDir, readHead, REFS_MOST, readCommits, readRefs, refResolves, sharedCommit, makeCaches, shapeWith, makeGit, GitLive;
12308
- var init_service$2 = __esmMin((() => {
12339
+ var init_service$3 = __esmMin((() => {
12309
12340
  init_dist();
12310
- init_error$4();
12341
+ init_error$5();
12311
12342
  init_run();
12312
12343
  CACHE_SIZE = 256;
12313
12344
  NAME_TTL = "5 minutes";
@@ -12654,13 +12685,13 @@ var init_service$2 = __esmMin((() => {
12654
12685
  //#endregion
12655
12686
  //#region src/service/git/index.ts
12656
12687
  var init_git = __esmMin((() => {
12657
- init_service$2();
12658
- init_error$4();
12688
+ init_service$3();
12689
+ init_error$5();
12659
12690
  }));
12660
12691
  //#endregion
12661
12692
  //#region src/service/store/error.ts
12662
12693
  var StoreUnwritable, StoreUnreadable;
12663
- var init_error$3 = __esmMin((() => {
12694
+ var init_error$4 = __esmMin((() => {
12664
12695
  init_dist();
12665
12696
  StoreUnwritable = class extends TaggedError("StoreUnwritable") {};
12666
12697
  StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
@@ -12687,7 +12718,7 @@ var init_model$4 = __esmMin((() => {
12687
12718
  }));
12688
12719
  //#endregion
12689
12720
  //#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;
12721
+ var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredLayers;
12691
12722
  var init_schema = __esmMin((() => {
12692
12723
  init_dist();
12693
12724
  Side = Literals(["old", "new"]);
@@ -12807,7 +12838,15 @@ var init_schema = __esmMin((() => {
12807
12838
  kind: Literal("code"),
12808
12839
  path: String$1,
12809
12840
  start: Int,
12810
- end: Int
12841
+ end: Int,
12842
+ text: optionalKey(String$1)
12843
+ });
12844
+ Split = Struct({
12845
+ path: String$1,
12846
+ name: String$1,
12847
+ start: Int,
12848
+ end: Int,
12849
+ layers: ArraySchema(Int)
12811
12850
  });
12812
12851
  StoredLayer = Struct({
12813
12852
  title: String$1,
@@ -12820,7 +12859,9 @@ var init_schema = __esmMin((() => {
12820
12859
  parent: optionalKey(UndefinedOr(Int)),
12821
12860
  written: String$1,
12822
12861
  summary: String$1,
12823
- layers: ArraySchema(StoredLayer)
12862
+ layers: ArraySchema(StoredLayer),
12863
+ blobs: optionalKey(Record(String$1, String$1)),
12864
+ split: optionalKey(ArraySchema(Split))
12824
12865
  });
12825
12866
  }));
12826
12867
  //#endregion
@@ -12846,10 +12887,10 @@ var init_paths = __esmMin((() => {
12846
12887
  //#endregion
12847
12888
  //#region src/service/store/service.ts
12848
12889
  var Store, ensureDir, readOptional, missing$2, damaged, jsonOf$2, decoded, unwritable, besideOf$1, wrote, added$1, INDENT, DRAFTS_VERSION, encoded, writes, appends, writeSettings, writeUpgradeCheck, writeState, writeLayers, writeRemarks, writeDrafts, writeBatch, writeAnswer, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asRemarks, asDrafts, asWatching, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, parseRemarks, idsIn$1, takes, cursorOps, settingsOps, upgradeOps, reportOps, branchKeyIn, branchKeyOf, wasKeyOf, there, moved, adopt, SPLIT, ADOPT_SIZE, adopting, keyIn, answerOps, layersOps, remarksOps, inboxOps, STATE_LOCK, DRAFTS_LOCK, held$2, stale$1, stolen, taken, freed, alone, watchOps, draftsOps, stateOps, makeStore, madeStore, storeAt;
12849
- var init_service$1 = __esmMin((() => {
12890
+ var init_service$2 = __esmMin((() => {
12850
12891
  init_dist();
12851
12892
  init_git();
12852
- init_error$3();
12893
+ init_error$4();
12853
12894
  init_model$4();
12854
12895
  init_schema();
12855
12896
  init_paths();
@@ -13286,15 +13327,15 @@ var init_service$1 = __esmMin((() => {
13286
13327
  //#endregion
13287
13328
  //#region src/service/store/index.ts
13288
13329
  var init_store = __esmMin((() => {
13289
- init_service$1();
13290
- init_error$3();
13330
+ init_service$2();
13331
+ init_error$4();
13291
13332
  init_paths();
13292
13333
  init_model$4();
13293
13334
  }));
13294
13335
  //#endregion
13295
13336
  //#region src/review/error.ts
13296
13337
  var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13297
- var init_error$2 = __esmMin((() => {
13338
+ var init_error$3 = __esmMin((() => {
13298
13339
  init_dist();
13299
13340
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
13300
13341
  BranchMoved = class extends TaggedError("BranchMoved") {};
@@ -13325,7 +13366,7 @@ var init_branches$1 = __esmMin((() => {
13325
13366
  init_patch();
13326
13367
  init_git();
13327
13368
  init_store();
13328
- init_error$2();
13369
+ init_error$3();
13329
13370
  realOf = (worktree) => tryPromise({
13330
13371
  try: () => realpath(worktree),
13331
13372
  catch: () => new UnknownWorktree({
@@ -13555,12 +13596,12 @@ var init_branches$1 = __esmMin((() => {
13555
13596
  }));
13556
13597
  //#endregion
13557
13598
  //#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;
13599
+ var findPatch, blobOf, wholeFile, rowAt, picked, anchorWith, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$3, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, shownAs, onDisk$2, show$3;
13559
13600
  var init_patches = __esmMin((() => {
13560
13601
  init_dist();
13561
13602
  init_patch();
13562
13603
  init_git();
13563
- init_error$2();
13604
+ init_error$3();
13564
13605
  init_branches$1();
13565
13606
  findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
13566
13607
  blobOf = (patches, file) => map$5(findPatch(patches, file), (patch) => patch.blob);
@@ -13671,12 +13712,12 @@ var init_patches = __esmMin((() => {
13671
13712
  });
13672
13713
  fileShown$1 = (worktree, generated) => (patch) => map$1(sourceShown(worktree, patch), (lines) => shownFile(patch, generated, lines));
13673
13714
  shownAs = (patch, lines) => shownFile(patch, /* @__PURE__ */ new Set(), lines);
13674
- onDisk$1 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13715
+ onDisk$2 = (patches) => patches.filter((patch) => patch.status !== "deleted").map((patch) => patch.path);
13675
13716
  show$3 = fn("Review.Diff.show")(function* (based, showing) {
13676
13717
  const git = yield* Git;
13677
13718
  const { worktree } = based;
13678
13719
  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 });
13720
+ const [generated] = yield* all([git.generated(worktree, patches$3.map((patch) => patch.path)), git.keep(worktree, onDisk$2(patches$3))], { concurrency: 2 });
13680
13721
  return {
13681
13722
  branch: worktree.branch,
13682
13723
  base: based.base,
@@ -13936,12 +13977,70 @@ var init_quiet = __esmMin((() => {
13936
13977
  };
13937
13978
  }));
13938
13979
  //#endregion
13980
+ //#region src/domain/layers/text.ts
13981
+ var OFFSET, PRIME, hashOf, textOf, stamped, outdatedSpans;
13982
+ var init_text = __esmMin((() => {
13983
+ OFFSET = 2166136261;
13984
+ PRIME = 16777619;
13985
+ hashOf = (text) => {
13986
+ let hash = OFFSET;
13987
+ for (const unit of text) hash = Math.imul(hash ^ (unit.codePointAt(0) ?? 0), PRIME);
13988
+ return (hash >>> 0).toString(16).padStart(8, "0");
13989
+ };
13990
+ textOf = (lines, start, end) => hashOf(lines.slice(start - 1, end).join("\n"));
13991
+ stamped = (layers, sources) => layers.map((layer) => ({
13992
+ ...layer,
13993
+ blocks: layer.blocks.map((block) => block.kind === "code" ? {
13994
+ ...block,
13995
+ text: textOf(sources.get(block.path) ?? [], block.start, block.end)
13996
+ } : block)
13997
+ }));
13998
+ outdatedSpans = (layers, sources) => layers.flatMap((layer, at) => layer.blocks.flatMap((block) => {
13999
+ if (block.kind !== "code" || block.text === void 0) return [];
14000
+ const lines = sources.get(block.path);
14001
+ if (lines === void 0 || textOf(lines, block.start, block.end) === block.text) return [];
14002
+ return [{
14003
+ layer: at + 1,
14004
+ path: block.path,
14005
+ start: block.start,
14006
+ end: block.end
14007
+ }];
14008
+ }));
14009
+ }));
14010
+ //#endregion
14011
+ //#region src/domain/layers/split.ts
14012
+ var addedLines, claimsAny, sharedPaths, splitsIn;
14013
+ var init_split = __esmMin((() => {
14014
+ init_dist();
14015
+ init_coverage();
14016
+ addedLines = (patch) => patch.rows.filter((row) => row.kind === "added").flatMap((row) => toArray(row.newLine));
14017
+ claimsAny = (layer, path, lines) => codeBlocks(layer).some((block) => block.path === path && lines.some((line) => line >= block.start && line <= block.end));
14018
+ sharedPaths = (layers) => {
14019
+ const claimed = layers.flatMap((layer) => [...new Set(codeBlocks(layer).map((block) => block.path))]);
14020
+ return [...new Set(claimed.filter((path, at) => claimed.indexOf(path) !== at))];
14021
+ };
14022
+ splitsIn = (layers, patch, declarations) => {
14023
+ const added = addedLines(patch);
14024
+ return declarations.flatMap((declaration) => {
14025
+ const inside = added.filter((line) => line >= declaration.start && line <= declaration.end);
14026
+ const holding = layers.flatMap((layer, at) => claimsAny(layer, patch.path, inside) ? [at + 1] : []);
14027
+ return holding.length > 1 ? [{
14028
+ path: patch.path,
14029
+ ...declaration,
14030
+ layers: holding
14031
+ }] : [];
14032
+ });
14033
+ };
14034
+ }));
14035
+ //#endregion
13939
14036
  //#region src/domain/layers/index.ts
13940
14037
  var init_layers$1 = __esmMin((() => {
13941
14038
  init_coverage();
13942
14039
  init_version();
13943
14040
  init_quiet();
13944
14041
  init_model$3();
14042
+ init_text();
14043
+ init_split();
13945
14044
  }));
13946
14045
  //#endregion
13947
14046
  //#region src/review/placing.ts
@@ -14094,7 +14193,7 @@ var init_comments$1 = __esmMin((() => {
14094
14193
  init_git();
14095
14194
  init_layers$1();
14096
14195
  init_store();
14097
- init_error$2();
14196
+ init_error$3();
14098
14197
  init_branches$1();
14099
14198
  init_patches();
14100
14199
  init_placing();
@@ -14441,7 +14540,7 @@ var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf
14441
14540
  var init_threads$1 = __esmMin((() => {
14442
14541
  init_dist();
14443
14542
  init_store();
14444
- init_error$2();
14543
+ init_error$3();
14445
14544
  init_placing();
14446
14545
  init_review$1();
14447
14546
  ASK_LEAD = "About this branch, not about this line.";
@@ -14773,16 +14872,16 @@ var init_threads$1 = __esmMin((() => {
14773
14872
  //#endregion
14774
14873
  //#region src/service/forge/error.ts
14775
14874
  var ForgeUnavailable;
14776
- var init_error$1 = __esmMin((() => {
14875
+ var init_error$2 = __esmMin((() => {
14777
14876
  init_dist();
14778
14877
  ForgeUnavailable = class extends TaggedError("ForgeUnavailable") {};
14779
14878
  }));
14780
14879
  //#endregion
14781
14880
  //#region src/service/forge/service.ts
14782
14881
  var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask$1, show$2, whoseOf, pullOf, read$2, viewerOf, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$2, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked$1, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, address, ForgeLive;
14783
- var init_service = __esmMin((() => {
14882
+ var init_service$1 = __esmMin((() => {
14784
14883
  init_dist();
14785
- init_error$1();
14884
+ init_error$2();
14786
14885
  Forge = class extends Service()("adiff/Forge") {};
14787
14886
  LIMIT = "200";
14788
14887
  TIMEOUT_MS = 4e3;
@@ -15228,15 +15327,15 @@ var init_service = __esmMin((() => {
15228
15327
  //#endregion
15229
15328
  //#region src/service/forge/index.ts
15230
15329
  var init_forge = __esmMin((() => {
15231
- init_service();
15232
- init_error$1();
15330
+ init_service$1();
15331
+ init_error$2();
15233
15332
  })), VERSION, OPENING, CLOSING, heldOf$1, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
15234
15333
  var init_remarks$1 = __esmMin((() => {
15235
15334
  init_dist();
15236
15335
  init_patch();
15237
15336
  init_forge();
15238
15337
  init_store();
15239
- init_error$2();
15338
+ init_error$3();
15240
15339
  VERSION = 1;
15241
15340
  OPENING = /^```suggestion[^\n]*\n?/gm;
15242
15341
  CLOSING = /^```[ \t]*$/gm;
@@ -15483,7 +15582,7 @@ var init_vouching$1 = __esmMin((() => {
15483
15582
  init_review$1();
15484
15583
  init_git();
15485
15584
  init_store();
15486
- init_error$2();
15585
+ init_error$3();
15487
15586
  init_branches$1();
15488
15587
  init_patches();
15489
15588
  pathOfMark = (mark) => mark.split("@")[0] ?? "";
@@ -15831,7 +15930,7 @@ var init_preferences = __esmMin((() => {
15831
15930
  init_dist();
15832
15931
  init_store();
15833
15932
  init_preferences$1();
15834
- init_error$2();
15933
+ init_error$3();
15835
15934
  list$1 = fn("Review.Preference.list")(function* () {
15836
15935
  const kept = yield* (yield* Store).settings;
15837
15936
  return preferences.map((one) => ({
@@ -15888,19 +15987,124 @@ var init_preferences = __esmMin((() => {
15888
15987
  });
15889
15988
  }));
15890
15989
  //#endregion
15990
+ //#region src/service/syntax/error.ts
15991
+ var GrammarUnreadable;
15992
+ var init_error$1 = __esmMin((() => {
15993
+ init_dist();
15994
+ GrammarUnreadable = class extends TaggedError("GrammarUnreadable") {};
15995
+ }));
15996
+ //#endregion
15997
+ //#region src/service/syntax/service.ts
15998
+ var Syntax, TYPESCRIPT, TSX, NAMED_FUNCTIONS, HOLDING_A_FUNCTION, FUNCTION_VALUES, besideThis$1, onDisk$1, embedded$1, compiled$1, started$1, readFrom, loaded, grammarsLoaded, grammarOf, holdsFunction, declared, declarationsUnder, parsed$1, functionsWith, makeSyntax, SyntaxLive;
15999
+ var init_service = __esmMin((() => {
16000
+ init_dist();
16001
+ init_error$1();
16002
+ Syntax = class extends Service()("adiff/Syntax") {};
16003
+ TYPESCRIPT = /\.[mc]?ts$/;
16004
+ TSX = /\.tsx$/;
16005
+ NAMED_FUNCTIONS = /* @__PURE__ */ new Set([
16006
+ "function_declaration",
16007
+ "generator_function_declaration",
16008
+ "method_definition"
16009
+ ]);
16010
+ HOLDING_A_FUNCTION = /* @__PURE__ */ new Set(["variable_declarator", "public_field_definition"]);
16011
+ FUNCTION_VALUES = /* @__PURE__ */ new Set([
16012
+ "arrow_function",
16013
+ "function_expression",
16014
+ "generator_function"
16015
+ ]);
16016
+ besideThis$1 = (path) => fileURLToPath(new URL(`./grammars/${path}`, import.meta.url));
16017
+ onDisk$1 = sync(() => ({
16018
+ runtime: void 0,
16019
+ typescript: besideThis$1("typescript/tree-sitter-typescript.wasm"),
16020
+ tsx: besideThis$1("tsx/tree-sitter-tsx.wasm")
16021
+ }));
16022
+ embedded$1 = all({
16023
+ runtime: promise(() => import("web-tree-sitter/tree-sitter.wasm", { with: { type: "file" } })),
16024
+ typescript: promise(() => import("./grammars/typescript/tree-sitter-typescript.wasm", { with: { type: "file" } })),
16025
+ tsx: promise(() => import("./grammars/tsx/tree-sitter-tsx.wasm", { with: { type: "file" } }))
16026
+ }).pipe(map$1((loaded) => ({
16027
+ runtime: loaded.runtime.default,
16028
+ typescript: loaded.typescript.default,
16029
+ tsx: loaded.tsx.default
16030
+ })));
16031
+ compiled$1 = () => process.versions["bun"] !== void 0;
16032
+ started$1 = (found) => found.runtime === void 0 ? Parser.init() : Parser.init({ locateFile: () => found.runtime ?? "" });
16033
+ readFrom = (path, load) => tryPromise({
16034
+ try: load,
16035
+ catch: (cause) => new GrammarUnreadable({
16036
+ path,
16037
+ reason: String(cause)
16038
+ })
16039
+ });
16040
+ loaded = fn("Syntax.loaded")(function* (found) {
16041
+ yield* readFrom(found.runtime ?? "web-tree-sitter", () => started$1(found));
16042
+ return yield* all({
16043
+ typescript: readFrom(found.typescript, () => Language.load(found.typescript)),
16044
+ tsx: readFrom(found.tsx, () => Language.load(found.tsx))
16045
+ }, { concurrency: "unbounded" });
16046
+ });
16047
+ grammarsLoaded = suspend(() => compiled$1() ? embedded$1 : onDisk$1).pipe(flatMap(loaded), option$2);
16048
+ grammarOf = (grammars, path) => {
16049
+ if (TSX.test(path)) return some(grammars.tsx);
16050
+ if (TYPESCRIPT.test(path)) return some(grammars.typescript);
16051
+ return none();
16052
+ };
16053
+ holdsFunction = (node) => {
16054
+ const value = node.childForFieldName("value");
16055
+ return value !== null && FUNCTION_VALUES.has(value.type);
16056
+ };
16057
+ declared = (node) => {
16058
+ const name = NAMED_FUNCTIONS.has(node.type) || HOLDING_A_FUNCTION.has(node.type) && holdsFunction(node) ? node.childForFieldName("name")?.text : void 0;
16059
+ if (name === void 0) return none();
16060
+ return some({
16061
+ name,
16062
+ start: node.startPosition.row + 1,
16063
+ end: node.endPosition.row + 1
16064
+ });
16065
+ };
16066
+ declarationsUnder = (node) => [...toArray(declared(node)), ...node.namedChildren.flatMap((child) => child === null ? [] : declarationsUnder(child))];
16067
+ parsed$1 = (language, lines) => {
16068
+ const parser = new Parser();
16069
+ parser.setLanguage(language);
16070
+ const tree = parser.parse(lines.join("\n"));
16071
+ const found = tree === null ? [] : declarationsUnder(tree.rootNode);
16072
+ tree?.delete();
16073
+ parser.delete();
16074
+ return found;
16075
+ };
16076
+ functionsWith = (grammars) => (path, lines) => map$1(grammars, (ready) => match$3(flatMap$2(ready, (loadedGrammars) => grammarOf(loadedGrammars, path)), {
16077
+ onNone: () => [],
16078
+ onSome: (language) => parsed$1(language, lines)
16079
+ }));
16080
+ makeSyntax = fn("Syntax.make")(function* () {
16081
+ const grammars = yield* cached(grammarsLoaded);
16082
+ return { functions: functionsWith(grammars) };
16083
+ });
16084
+ SyntaxLive = effect(Syntax)(makeSyntax());
16085
+ }));
16086
+ //#endregion
16087
+ //#region src/service/syntax/index.ts
16088
+ var init_syntax = __esmMin((() => {
16089
+ init_service();
16090
+ }));
16091
+ //#endregion
15891
16092
  //#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;
16093
+ var STALE_ADVICE, OUTDATED_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, partIn, reportedLayers, adviceOf, reportOf, pathsOfLayer, sourcesOf, changedSinceWritten, outdatedIn, splitsFound, storedLayers, set, readInLayer, withRead, coversThread, readsFile, lastHolding, layersHolding$1, loudest, partWithThreads, withThreads, readReport, view, show$1, placeThreads, spansIn, layersAt, taggedRow, nearestNew, lineNow, taggedHunk, taggedFile, tagSince, quietRow, quietFile, tagRows, read, partsOfFile, vouchPart, carriedStamps, unmarkedPart, markedPart, askingFor, openAskOf, askIn, seenOf, ask, claims, vouchIn;
15893
16094
  var init_layers = __esmMin((() => {
15894
16095
  init_dist();
15895
16096
  init_layers$1();
16097
+ init_git();
16098
+ init_syntax();
15896
16099
  init_store();
15897
16100
  init_review$1();
15898
- init_error$2();
16101
+ init_error$3();
15899
16102
  init_comments$1();
15900
16103
  init_threads$1();
15901
16104
  init_branches$1();
15902
16105
  init_vouching$1();
15903
16106
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
16107
+ OUTDATED_ADVICE = "The code under the outdated spans changed after these layers were written. Read those lines again and write a new revision with layers set.";
15904
16108
  unique = (paths) => [...new Set(paths)];
15905
16109
  spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
15906
16110
  path,
@@ -16023,15 +16227,19 @@ var init_layers = __esmMin((() => {
16023
16227
  };
16024
16228
  });
16025
16229
  };
16026
- reportOf = (patches, layers, branchHead) => {
16230
+ adviceOf = (moved, outdated) => {
16231
+ if (moved) return { advice: STALE_ADVICE };
16232
+ return outdated.length > 0 ? { advice: OUTDATED_ADVICE } : {};
16233
+ };
16234
+ reportOf = (patches, layers, branchHead, outdated = []) => {
16027
16235
  const status = statusOf(patches, layers, branchHead);
16028
16236
  return {
16029
16237
  version: status.version,
16030
16238
  parent: getOrUndefined$1(status.parent),
16031
16239
  head: status.layersHead,
16032
16240
  branchHead: status.branchHead,
16033
- stale: status.stale,
16034
- ...status.stale ? { advice: STALE_ADVICE } : {},
16241
+ stale: status.stale || outdated.length > 0,
16242
+ ...adviceOf(status.stale, outdated),
16035
16243
  written: layers.written,
16036
16244
  summary: layers.summary,
16037
16245
  covered: status.covered,
@@ -16039,10 +16247,36 @@ var init_layers = __esmMin((() => {
16039
16247
  total: status.total,
16040
16248
  uncovered: status.uncovered,
16041
16249
  shared: sharedHunks(patches, layers.layers),
16250
+ split: layers.split ?? [],
16042
16251
  vanished: status.vanished,
16252
+ outdated,
16043
16253
  layers: reportedLayers(patches, layers)
16044
16254
  };
16045
16255
  };
16256
+ pathsOfLayer = (layer) => codeBlocks(layer).map((block) => block.path);
16257
+ sourcesOf = fn("Review.Layers.sourcesOf")(function* (worktree, paths) {
16258
+ const git = yield* Git;
16259
+ const read = fn("Review.Layers.sourceOf")(function* (path) {
16260
+ const lines = yield* git.source(worktree, path);
16261
+ return [path, getOrUndefined$1(lines) ?? []];
16262
+ });
16263
+ return new Map(yield* forEach(paths, read, { concurrency: 8 }));
16264
+ });
16265
+ changedSinceWritten = (patches, layers) => Object.entries(layers.blobs ?? {}).filter(([path, blob]) => {
16266
+ const now = patches.find((patch) => patch.path === path);
16267
+ return now !== void 0 && !sameBlob(now.blob, blob);
16268
+ }).map(([path]) => path);
16269
+ outdatedIn = fn("Review.Layers.outdatedIn")(function* (worktree, patches, layers) {
16270
+ const changed = changedSinceWritten(patches, layers);
16271
+ if (changed.length === 0) return [];
16272
+ return outdatedSpans(layers.layers, yield* sourcesOf(worktree, changed));
16273
+ });
16274
+ splitsFound = fn("Review.Layers.splitsFound")(function* (patches, layers, sources) {
16275
+ const syntax = yield* Syntax;
16276
+ const shared = new Set(sharedPaths(layers));
16277
+ const splitIn = (patch) => map$1(syntax.functions(patch.path, sources.get(patch.path) ?? []), (found) => splitsIn(layers, patch, found));
16278
+ return (yield* forEach(patches.filter((patch) => shared.has(patch.path)), splitIn)).flat();
16279
+ });
16046
16280
  storedLayers = fn("Review.Layers.storedLayers")(function* (worktree) {
16047
16281
  const store = yield* Store;
16048
16282
  return map$5(yield* store.layers(worktree.path), fromStored);
@@ -16052,6 +16286,8 @@ var init_layers = __esmMin((() => {
16052
16286
  const input = yield* readLayers(text);
16053
16287
  const patches$1 = yield* patches(worktree);
16054
16288
  const previous = yield* storedLayers(worktree);
16289
+ const paths = unique(input.layers.flatMap(pathsOfLayer));
16290
+ const sources = yield* sourcesOf(worktree, paths);
16055
16291
  const layers = {
16056
16292
  version: match$3(previous, {
16057
16293
  onNone: () => 1,
@@ -16062,7 +16298,9 @@ var init_layers = __esmMin((() => {
16062
16298
  base: worktree.base,
16063
16299
  written,
16064
16300
  summary: input.summary,
16065
- layers: input.layers
16301
+ layers: stamped(input.layers, sources),
16302
+ blobs: Object.fromEntries(patches$1.filter((patch) => sources.has(patch.path)).map((patch) => [patch.path, patch.blob])),
16303
+ split: yield* splitsFound(patches$1, input.layers, sources)
16066
16304
  };
16067
16305
  yield* store.saveLayers(worktree.path, toStored(layers));
16068
16306
  return reportOf(patches$1, layers, worktree.head);
@@ -16130,7 +16368,8 @@ var init_layers = __esmMin((() => {
16130
16368
  path: patch.path,
16131
16369
  blob: patch.blob
16132
16370
  }));
16133
- const report = reportOf(reading.patches, found.value, reading.worktree.head);
16371
+ const outdated = yield* outdatedIn(reading.worktree, reading.patches, found.value);
16372
+ const report = reportOf(reading.patches, found.value, reading.worktree.head, outdated);
16134
16373
  const spans = report.layers.map((layer) => layer.spans);
16135
16374
  return some(withRead(report, {
16136
16375
  patches: reading.patches,
@@ -16225,9 +16464,10 @@ var init_layers = __esmMin((() => {
16225
16464
  stale: false,
16226
16465
  summary: ""
16227
16466
  };
16467
+ const outdated = yield* outdatedIn(worktree, reading.patches, found.value);
16228
16468
  return {
16229
16469
  layers: reportedLayers(reading.patches, found.value),
16230
- stale: found.value.head !== worktree.head,
16470
+ stale: found.value.head !== worktree.head || outdated.length > 0,
16231
16471
  rebased: found.value.base !== worktree.base,
16232
16472
  summary: found.value.summary
16233
16473
  };
@@ -16384,7 +16624,7 @@ var init_drafts$1 = __esmMin((() => {
16384
16624
  init_dist();
16385
16625
  init_forge();
16386
16626
  init_store();
16387
- init_error$2();
16627
+ init_error$3();
16388
16628
  init_patches();
16389
16629
  unreadIn = (draft, seen) => {
16390
16630
  if (draft.wroteBy !== "agent") return false;
@@ -16732,7 +16972,7 @@ var show;
16732
16972
  var init_pulls = __esmMin((() => {
16733
16973
  init_dist();
16734
16974
  init_forge();
16735
- init_error$2();
16975
+ init_error$3();
16736
16976
  show = fn("Review.Pull.show")(function* (repo, branch) {
16737
16977
  const forge = yield* Forge;
16738
16978
  const found = (yield* forge.pulls(repo)).find((pull) => pull.branch === branch);
@@ -16763,7 +17003,7 @@ var init_review = __esmMin((() => {
16763
17003
  init_drafts$1();
16764
17004
  init_search$1();
16765
17005
  init_pulls();
16766
- init_error$2();
17006
+ init_error$3();
16767
17007
  }));
16768
17008
  //#endregion
16769
17009
  //#region src/cli/help.ts
@@ -26545,6 +26785,7 @@ init_dist();
26545
26785
  init_cli();
26546
26786
  init_review();
26547
26787
  init_git();
26788
+ init_syntax();
26548
26789
  init_forge();
26549
26790
  init_store();
26550
26791
  const WAIT_UNIT = 1e3;
@@ -27044,7 +27285,7 @@ if (said !== void 0) {
27044
27285
  process.stdout.write(`${said}\n`);
27045
27286
  process.exit(0);
27046
27287
  }
27047
- const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot())).pipe(provideMerge(GitLive));
27288
+ const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot()), SyntaxLive).pipe(provideMerge(GitLive));
27048
27289
  const reportFailure = (cause) => sync(() => {
27049
27290
  const reported = failure(squash(cause));
27050
27291
  process.stderr.write(`${reported.line}\n`);
package/package.json CHANGED
@@ -15,7 +15,8 @@
15
15
  "typescript": "^7.0.2"
16
16
  },
17
17
  "dependencies": {
18
- "@opentui/core": "^0.4.5"
18
+ "@opentui/core": "^0.4.5",
19
+ "web-tree-sitter": "0.25.10"
19
20
  },
20
21
  "engines": {
21
22
  "node": ">=22"
@@ -23,7 +24,7 @@
23
24
  "bin": {
24
25
  "adiff": "./bin/adiff.js"
25
26
  },
26
- "version": "0.1.0-alpha.204",
27
+ "version": "0.1.0-alpha.205",
27
28
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
29
  "license": "MIT",
29
30
  "repository": {
@@ -343,8 +343,15 @@ reviewer asks for another.
343
343
  reading order whose layers each claim the whole diff reports the same `covered` as one whose layers
344
344
  each claim their own run. Done means `uncovered` is empty **and** `shared` is zero.
345
345
 
346
+ `split` in the answer names each TypeScript or TSX function, method or function-valued constant
347
+ whose changed lines your layers cut between two or more layers, with its lines and those layers. A
348
+ reviewer reads half of it in one layer and the rest in another, so move the boundary until `split`
349
+ is empty. Count spans on the file as it is on disk now, never on a committed copy you have since
350
+ edited: spans counted on other text cover the right number of lines and still cut the wrong code.
351
+
346
352
  Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
347
- was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
353
+ was written for and the text each span held, and adiff reports it as `stale` once the branch moves
354
+ past that commit or the code under a span changes. `outdated` names each span whose lines changed. Once a
348
355
  reviewer has a reading order, keep it true, as the next section says.
349
356
 
350
357
  When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
@@ -358,13 +365,14 @@ Once a branch has layers, check them after each change you make (a commit, an an
358
365
  rebase) and before you say the work is ready:
359
366
 
360
367
  ```bash
361
- adiff layers show --worktree . --fields stale,uncovered,shared,vanished
368
+ adiff layers show --worktree . --fields stale,uncovered,shared,vanished,outdated,split
362
369
  ```
363
370
 
364
- If `uncovered` is not empty, `stale` is true or `vanished` names a path, write a new revision with
371
+ If `uncovered` is not empty, `stale` is true, `vanished` names a path, `outdated` names a span or
372
+ `split` names a function, write a new revision with
365
373
  `adiff layers set` right away. Put new runs into the layer whose claim they serve, and add a final
366
374
  layer only for lines that serve none. When the base moved, read the diff again rather than patching
367
- line numbers. Done means `uncovered` is empty and `shared` is zero.
375
+ line numbers. Done means `uncovered` is empty, `shared` is zero and `split` is empty.
368
376
 
369
377
  Do it silently: it is upkeep, not news, so do not ask first and do not report it unless the reviewer
370
378
  asks. `NoLayers` (exit 3) means the branch has no reading order, and then you write one only when