@eliya-oss/agent-diff 0.1.0-alpha.186 → 0.1.0-alpha.188

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 +30 -0
  2. package/dist/main.js +484 -74
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.188
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(CLI): `adiff serve` answers command after command over one pipe, and tells a client the moment a review it watches changes.
8
+
9
+ <details><summary>What it is for</summary>
10
+
11
+ A program that asks adiff often, such as a review page in the browser, keeps one adiff running instead of starting one per question, and redraws when a comment, an answer or a reviewed mark changes instead of asking every few seconds. On a 19-file branch, `comment list` took 546ms as a fresh process and 205ms through `serve`; a watched review reported a comment filed by another process before that process had exited.
12
+
13
+ </details>
14
+
15
+ perf(marks): an open review shows a file marked reviewed from another program without a reload.
16
+
17
+ ## 0.1.0-alpha.187
18
+
19
+ ### Patch Changes
20
+
21
+ - feat(CLI): `pull show`, `base list`, `branch search`, `layers ask`, `comment read` and `comment resolve --read` give every review verb the terminal has a command of its own.
22
+
23
+ <details><summary>What each one does</summary>
24
+
25
+ `pull show` names the pull request behind a branch, its address and whether somebody else opened it. `base list` offers the refs `b` offers. `branch search` is the terminal's `/`. `layers ask` files the request `L` files. `comment read` marks a thread's answers read, and `comment resolve --read` settles every answer already read, as `D` does.
26
+
27
+ </details>
28
+
29
+ feat(layers): `layers show` names the files already read in each layer, and `file review --layer <n>` marks a file two layers share read in one of them, as `m` does on the rail.
30
+
31
+ feat(comment delivery): each comment `adiff comment list` reports says whether the agent has taken it, so another program can draw ◎ and ○ as the terminal does.
32
+
3
33
  ## 0.1.0-alpha.186
4
34
 
5
35
  ### Patch Changes
package/dist/main.js CHANGED
@@ -3,11 +3,12 @@ import { appendFile, mkdir, readFile, realpath, rename, rm, stat, writeFile } fr
3
3
  import { text } from "node:stream/consumers";
4
4
  import { execFile, spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { existsSync, mkdirSync, watch } from "node:fs";
7
+ import { createInterface } from "node:readline";
6
8
  import { join, resolve } from "node:path";
7
9
  import { promisify } from "node:util";
8
10
  import { homedir, hostname, platform } from "node:os";
9
11
  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";
10
- import { existsSync, mkdirSync, watch } from "node:fs";
11
12
  //#region \0rolldown/runtime.js
12
13
  var __defProp = Object.defineProperty;
13
14
  var __esmMin = (fn, res, err) => () => {
@@ -2684,7 +2685,7 @@ var init_references = __esmMin((() => {
2684
2685
  };
2685
2686
  };
2686
2687
  spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
2687
- })), 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, provideServiceImpl, when$1, forever$2, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchDefect$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, 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((() => {
2688
+ })), 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, 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, 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((() => {
2688
2689
  init_Array();
2689
2690
  init_Context();
2690
2691
  init_Duration();
@@ -3470,7 +3471,7 @@ var init_references = __esmMin((() => {
3470
3471
  if (effectIsExit(self)) return self;
3471
3472
  return updateContext(self, merge(context));
3472
3473
  });
3473
- provideService = function() {
3474
+ provideService$1 = function() {
3474
3475
  if (arguments.length === 1) return dual(2, (self, impl) => provideServiceImpl(self, arguments[0], impl));
3475
3476
  return dual(3, (self, service, impl) => provideServiceImpl(self, service, impl)).apply(this, arguments);
3476
3477
  };
@@ -3667,7 +3668,7 @@ var init_references = __esmMin((() => {
3667
3668
  });
3668
3669
  constScopeEmpty = { _tag: "Empty" };
3669
3670
  scope = scopeTag;
3670
- provideScope = /*#__PURE__*/ provideService(scopeTag);
3671
+ provideScope = /*#__PURE__*/ provideService$1(scopeTag);
3671
3672
  scoped$1 = (self) => withFiber$1((fiber) => {
3672
3673
  const prev = fiber.context;
3673
3674
  const scope = scopeMakeUnsafe();
@@ -4167,7 +4168,7 @@ var init_references = __esmMin((() => {
4167
4168
  return onExit$1(internalCall(() => evaluate(span)), (exit) => endSpan(span, exit, clock, timingEnabled));
4168
4169
  });
4169
4170
  };
4170
- provideParentSpan = /*#__PURE__*/ provideService(ParentSpan);
4171
+ provideParentSpan = /*#__PURE__*/ provideService$1(ParentSpan);
4171
4172
  withParentSpan = function() {
4172
4173
  const dataFirst = isEffect$1(arguments[0]);
4173
4174
  const span = dataFirst ? arguments[1] : arguments[0];
@@ -4546,7 +4547,7 @@ var succeed$4, failCause$2, fail$1, void_$1, isSuccess, isFailure, init_Exit = _
4546
4547
  return current ? forkMemoMapUnsafe(current) : makeMemoMapUnsafe();
4547
4548
  }
4548
4549
  };
4549
- buildWithMemoMap = /*#__PURE__*/ dual(3, (self, memoMap, scope) => provideService(map$3(self.build(memoMap, scope), add$2(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap));
4550
+ buildWithMemoMap = /*#__PURE__*/ dual(3, (self, memoMap, scope) => provideService$1(map$3(self.build(memoMap, scope), add$2(CurrentMemoMap, memoMap)), CurrentMemoMap, memoMap));
4550
4551
  buildWithScope = /*#__PURE__*/ dual(2, (self, scope) => withFiber$1((fiber) => buildWithMemoMap(self, CurrentMemoMap.forkOrCreate(fiber.context), scope)));
4551
4552
  succeed$2 = function() {
4552
4553
  if (arguments.length === 1) return (resource) => succeedContext(make$18(arguments[0], resource));
@@ -4751,14 +4752,14 @@ var repeatOrElse, retryOrElse, repeat$1, retry$1, passthroughForever, buildFromO
4751
4752
  init_effect();
4752
4753
  repeatOrElse = /*#__PURE__*/ dual(3, (self, schedule, orElse) => flatMap$1(toStepWithMetadata(schedule), (step) => {
4753
4754
  let meta = CurrentMetadata.defaultValue();
4754
- return catch_(forever$2(tap$1(flatMap$1(suspend$1(() => provideService(self, CurrentMetadata, meta)), step), (meta_) => sync$1(() => {
4755
+ return catch_(forever$2(tap$1(flatMap$1(suspend$1(() => provideService$1(self, CurrentMetadata, meta)), step), (meta_) => sync$1(() => {
4755
4756
  meta = meta_;
4756
4757
  })), { disableYield: true }), (error) => isDone$1(error) ? succeed$5(error.value) : orElse(error, meta.attempt === 0 ? none() : some(meta)));
4757
4758
  }));
4758
4759
  retryOrElse = /*#__PURE__*/ dual(3, (self, policy, orElse) => flatMap$1(toStepWithMetadata(policy), (step) => {
4759
4760
  let meta = CurrentMetadata.defaultValue();
4760
4761
  let lastError;
4761
- const loop = catch_(suspend$1(() => provideService(self, CurrentMetadata, meta)), (error) => {
4762
+ const loop = catch_(suspend$1(() => provideService$1(self, CurrentMetadata, meta)), (error) => {
4762
4763
  lastError = error;
4763
4764
  return flatMap$1(step(error), (meta_) => {
4764
4765
  meta = meta_;
@@ -4789,7 +4790,7 @@ var repeatOrElse, retryOrElse, repeat$1, retry$1, passthroughForever, buildFromO
4789
4790
  if (options.times !== void 0) schedule = while_(schedule, ({ attempt }) => succeed$5(attempt <= options.times));
4790
4791
  return schedule;
4791
4792
  };
4792
- })), 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, retry, ignore, orElseSucceed, sleep, raceFirst, when, context, contextWith, provide, 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;
4793
+ })), 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, retry, ignore, orElseSucceed, sleep, raceFirst, 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;
4793
4794
  var init_Effect = __esmMin((() => {
4794
4795
  init_Context();
4795
4796
  init_core();
@@ -4839,6 +4840,7 @@ var init_Effect = __esmMin((() => {
4839
4840
  context = context$1;
4840
4841
  contextWith = contextWith$1;
4841
4842
  provide = provide$1;
4843
+ provideService = provideService$1;
4842
4844
  scoped = scoped$1;
4843
4845
  acquireRelease = acquireRelease$1;
4844
4846
  acquireUseRelease = acquireUseRelease$1;
@@ -10042,10 +10044,10 @@ var init_config = __esmMin((() => {
10042
10044
  //#region package.json
10043
10045
  init_pane();
10044
10046
  init_config();
10045
- var version$1 = "0.1.0-alpha.186";
10047
+ var version$1 = "0.1.0-alpha.188";
10046
10048
  //#endregion
10047
10049
  //#region src/cli/error.ts
10048
- var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered;
10050
+ var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10049
10051
  var init_error$5 = __esmMin((() => {
10050
10052
  init_dist();
10051
10053
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
@@ -10054,6 +10056,8 @@ var init_error$5 = __esmMin((() => {
10054
10056
  UnknownOption = class extends TaggedError("UnknownOption") {};
10055
10057
  BadOption = class extends TaggedError("BadOption") {};
10056
10058
  RegistryUnanswered = class extends TaggedError("RegistryUnanswered") {};
10059
+ NotServed = class extends TaggedError("NotServed") {};
10060
+ BadRequest = class extends TaggedError("BadRequest") {};
10057
10061
  }));
10058
10062
  //#endregion
10059
10063
  //#region src/cli/upgrade.ts
@@ -10381,6 +10385,41 @@ var init_catalog = __esmMin((() => {
10381
10385
  dataKey: "pane",
10382
10386
  example: "adiff review pane --repo ."
10383
10387
  },
10388
+ {
10389
+ name: "pull show",
10390
+ about: "The pull request opened from a branch: its address, its state, and whether somebody else opened it",
10391
+ group: READ_A_BRANCH,
10392
+ addresses: "review",
10393
+ safety: "read",
10394
+ options: [...addressing],
10395
+ dataKey: "pull",
10396
+ example: "adiff pull show --repo . --branch add-invitations --fields url,theirs"
10397
+ },
10398
+ {
10399
+ name: "base list",
10400
+ about: "The refs worth comparing a branch against: its last few commits, then every other ref",
10401
+ group: READ_A_BRANCH,
10402
+ addresses: "review",
10403
+ safety: "read",
10404
+ options: [...addressing],
10405
+ dataKey: "bases",
10406
+ example: "adiff base list --repo . --branch add-invitations"
10407
+ },
10408
+ {
10409
+ name: "branch search",
10410
+ about: "Search a branch's files, changed files first and declarations before uses",
10411
+ group: READ_A_BRANCH,
10412
+ addresses: "review",
10413
+ safety: "read",
10414
+ options: [...based, {
10415
+ name: "term",
10416
+ required: true,
10417
+ value: "text",
10418
+ about: "What to look for"
10419
+ }],
10420
+ dataKey: "matches",
10421
+ example: "adiff branch search --repo . --branch add-invitations --term sendInvite"
10422
+ },
10384
10423
  {
10385
10424
  name: "patch show",
10386
10425
  about: "A branch's diff as rows with line numbers on both sides, read from the same parse the terminal draws. Binary and generated files are listed and flagged",
@@ -10411,7 +10450,16 @@ var init_catalog = __esmMin((() => {
10411
10450
  group: READ_A_BRANCH,
10412
10451
  addresses: "review",
10413
10452
  safety: "write",
10414
- options: [...based, file],
10453
+ options: [
10454
+ ...based,
10455
+ file,
10456
+ {
10457
+ name: "layer",
10458
+ required: false,
10459
+ value: "number",
10460
+ about: "Mark the file read in this layer only, counting from 1, when more than one layer claims it"
10461
+ }
10462
+ ],
10415
10463
  dataKey: "reviewed",
10416
10464
  example: "adiff file review --worktree . --file src/api.ts"
10417
10465
  },
@@ -10554,6 +10602,16 @@ var init_catalog = __esmMin((() => {
10554
10602
  dataKey: "layers",
10555
10603
  example: "adiff layers show --worktree . --fields layers,uncovered"
10556
10604
  },
10605
+ {
10606
+ name: "layers ask",
10607
+ about: "Ask the agent for a reading order, or a new one, as `L` does in the terminal",
10608
+ group: WRITE_COMMENTS,
10609
+ addresses: "review",
10610
+ safety: "write",
10611
+ options: [...based],
10612
+ dataKey: "asked",
10613
+ example: "adiff layers ask --repo . --branch add-invitations"
10614
+ },
10557
10615
  {
10558
10616
  name: "draft list",
10559
10617
  about: "The comments held for this pull request, in the order they were written",
@@ -10727,14 +10785,38 @@ var init_catalog = __esmMin((() => {
10727
10785
  group: FOLLOW_UP,
10728
10786
  addresses: "review",
10729
10787
  safety: "write",
10788
+ options: [
10789
+ ...addressing,
10790
+ {
10791
+ name: "id",
10792
+ required: false,
10793
+ value: "id",
10794
+ about: "The comment to settle. Pass this or --read"
10795
+ },
10796
+ {
10797
+ name: "read",
10798
+ required: false,
10799
+ value: "flag",
10800
+ about: "Settle every comment whose answers have all been read, as `D` does in the terminal"
10801
+ }
10802
+ ],
10803
+ dataKey: "settled",
10804
+ example: "adiff comment resolve --repo . --branch add-invitations --id c1"
10805
+ },
10806
+ {
10807
+ name: "comment read",
10808
+ about: "Mark the answers on a comment read, as reading them in the terminal does",
10809
+ group: FOLLOW_UP,
10810
+ addresses: "review",
10811
+ safety: "write",
10730
10812
  options: [...addressing, {
10731
10813
  name: "id",
10732
10814
  required: true,
10733
10815
  value: "id",
10734
- about: "The comment to settle"
10816
+ about: "The comment whose answers were read"
10735
10817
  }],
10736
- dataKey: "settled",
10737
- example: "adiff comment resolve --repo . --branch add-invitations --id c1"
10818
+ dataKey: "read",
10819
+ example: "adiff comment read --repo . --branch add-invitations --id c1"
10738
10820
  },
10739
10821
  {
10740
10822
  name: "comment remove",
@@ -10846,6 +10928,16 @@ var init_catalog = __esmMin((() => {
10846
10928
  dataKey: "upgrade",
10847
10929
  example: "adiff upgrade --check --json --fields route,latest,current"
10848
10930
  },
10931
+ {
10932
+ name: "serve",
10933
+ about: "Answer commands one JSON line at a time on stdin and stdout, and report changes to the reviews a client watches. For a program that asks adiff often, such as a review page",
10934
+ group: SET_UP,
10935
+ addresses: "repo",
10936
+ safety: "read",
10937
+ options: [],
10938
+ dataKey: "",
10939
+ example: "echo '{\"id\":1,\"args\":[\"comment\",\"list\",\"--worktree\",\".\"]}' | adiff serve"
10940
+ },
10849
10941
  {
10850
10942
  name: "resume",
10851
10943
  about: "Open the review you left last in this repository. Opens the terminal, like `review open`, on the branch it was opened on most recently",
@@ -11086,6 +11178,16 @@ var init_report$1 = __esmMin((() => {
11086
11178
  suggestion: "No layers has been written for this worktree. Write one with `adiff layers set`.",
11087
11179
  retriable: false
11088
11180
  },
11181
+ UnknownLayer: {
11182
+ exit: 3,
11183
+ suggestion: "No layer carries that number. `adiff layers show` lists them, counting from 1.",
11184
+ retriable: false
11185
+ },
11186
+ NoPull: {
11187
+ exit: 3,
11188
+ suggestion: "No pull request is open from this branch. Push it and open one, then ask again.",
11189
+ retriable: false
11190
+ },
11089
11191
  UnknownComment: {
11090
11192
  exit: 3,
11091
11193
  suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment list` reports every id on a review.",
@@ -11111,6 +11213,16 @@ var init_report$1 = __esmMin((() => {
11111
11213
  suggestion: "That remark is already a comment on this review. `adiff comment list` reports it, and removing that comment frees the remark.",
11112
11214
  retriable: false
11113
11215
  },
11216
+ NotServed: {
11217
+ exit: 2,
11218
+ suggestion: "serve answers only commands that answer in JSON. Run the review terminal, review pane, resume and upgrade on their own.",
11219
+ retriable: false
11220
+ },
11221
+ BadRequest: {
11222
+ exit: 2,
11223
+ suggestion: "A request is one JSON object per line, such as {\"id\":1,\"args\":[\"comment\",\"list\",\"--worktree\",\".\"]} or {\"id\":2,\"watch\":[\"--worktree\",\".\"]}.",
11224
+ retriable: false
11225
+ },
11114
11226
  UnknownField: {
11115
11227
  exit: 2,
11116
11228
  suggestion: "That is not a field this answer carries. The ones it does are named above.",
@@ -11248,6 +11360,122 @@ var init_report$1 = __esmMin((() => {
11248
11360
  };
11249
11361
  }));
11250
11362
  //#endregion
11363
+ //#region src/cli/serve.ts
11364
+ var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11365
+ var init_serve = __esmMin((() => {
11366
+ init_dist();
11367
+ init_error$5();
11368
+ init_report$1();
11369
+ init_parse$1();
11370
+ init_catalog();
11371
+ Replies = class extends Service()("adiff/Replies") {};
11372
+ toStdout = succeed$2(Replies)({ say: (line) => sync(() => void process.stdout.write(`${line}\n`)) });
11373
+ NOT_SERVED = /* @__PURE__ */ new Set([
11374
+ "review open",
11375
+ "review pane",
11376
+ "resume",
11377
+ "upgrade",
11378
+ "serve"
11379
+ ]);
11380
+ SETTLE_MS$1 = 120;
11381
+ refused = (cause) => {
11382
+ const reported = failure(cause);
11383
+ return {
11384
+ exit: reported.exit,
11385
+ answer: JSON.parse(reported.line)
11386
+ };
11387
+ };
11388
+ write = (line) => {
11389
+ process.stdout.write(`${JSON.stringify(line)}\n`);
11390
+ };
11391
+ answering = (serving, args) => {
11392
+ const name = serving.nameOf(args);
11393
+ if (NOT_SERVED.has(name)) return succeed$1(refused(new NotServed({ command: name })));
11394
+ const heard = [];
11395
+ return serving.run(name, optionsFrom(args, valuedIn(name))).pipe(provideService(Replies, { say: (line) => sync(() => void heard.push(line)) }), map$1(() => ({
11396
+ exit: 0,
11397
+ answer: JSON.parse(heard.at(-1) ?? "{}")
11398
+ })), catchCause((cause) => succeed$1(refused(squash(cause)))));
11399
+ };
11400
+ settled$1 = (folder, tell) => {
11401
+ mkdirSync(folder, { recursive: true });
11402
+ let timer;
11403
+ const watcher = watch(folder, () => {
11404
+ if (timer !== void 0) clearTimeout(timer);
11405
+ timer = setTimeout(tell, SETTLE_MS$1);
11406
+ });
11407
+ watcher.on("error", () => void 0);
11408
+ return watcher;
11409
+ };
11410
+ watching = (serving, request, watchers) => serving.folderOf(optionsFrom(request.watch ?? [], valuedIn("comment list"))).pipe(map$1((folder) => {
11411
+ watchers.get(request.id)?.close();
11412
+ watchers.set(request.id, settled$1(folder, () => write({
11413
+ id: request.id,
11414
+ event: "changed"
11415
+ })));
11416
+ return {
11417
+ exit: 0,
11418
+ answer: {
11419
+ ok: true,
11420
+ watching: folder
11421
+ }
11422
+ };
11423
+ }), catchCause((cause) => succeed$1(refused(squash(cause)))));
11424
+ unwatching = (request, watchers) => {
11425
+ watchers.get(request.id)?.close();
11426
+ watchers.delete(request.id);
11427
+ return {
11428
+ exit: 0,
11429
+ answer: {
11430
+ ok: true,
11431
+ watching: false
11432
+ }
11433
+ };
11434
+ };
11435
+ readRequest = (line) => {
11436
+ try {
11437
+ const parsed = JSON.parse(line);
11438
+ if (typeof parsed !== "object" || parsed === null || !("id" in parsed)) return void 0;
11439
+ return parsed;
11440
+ } catch {
11441
+ return;
11442
+ }
11443
+ };
11444
+ handled = (serving, line, watchers) => {
11445
+ const request = readRequest(line);
11446
+ if (request === void 0) return sync(() => write(refused(new BadRequest({ line }))));
11447
+ const answer = request.unwatch === true ? succeed$1(unwatching(request, watchers)) : request.watch !== void 0 ? watching(serving, request, watchers) : answering(serving, request.args ?? []);
11448
+ return map$1(answer, (said) => write({
11449
+ id: request.id,
11450
+ ...said
11451
+ }));
11452
+ };
11453
+ listen = (serving, listening) => {
11454
+ const lines = createInterface({ input: process.stdin });
11455
+ const heard = (line) => {
11456
+ if (line.trim().length === 0) return;
11457
+ runForkWith(listening.context)(handled(serving, line, listening.watchers));
11458
+ };
11459
+ const closed = () => {
11460
+ for (const watcher of listening.watchers.values()) watcher.close();
11461
+ listening.done();
11462
+ };
11463
+ lines.on("line", heard);
11464
+ lines.on("close", closed);
11465
+ };
11466
+ serve = fn("Cli.serve")(function* (serving) {
11467
+ const context$2 = yield* context();
11468
+ const watchers = /* @__PURE__ */ new Map();
11469
+ yield* callback$1((resume) => {
11470
+ listen(serving, {
11471
+ context: context$2,
11472
+ watchers,
11473
+ done: () => resume(void_)
11474
+ });
11475
+ });
11476
+ });
11477
+ }));
11478
+ //#endregion
11251
11479
  //#region src/cli/index.ts
11252
11480
  var init_cli = __esmMin((() => {
11253
11481
  init_config();
@@ -11256,6 +11484,7 @@ var init_cli = __esmMin((() => {
11256
11484
  init_catalog();
11257
11485
  init_report$1();
11258
11486
  init_error$5();
11487
+ init_serve();
11259
11488
  }));
11260
11489
  //#endregion
11261
11490
  //#region src/domain/patch/model.ts
@@ -12231,7 +12460,10 @@ var init_paths = __esmMin((() => {
12231
12460
  upgradePath = (root) => join(root, "upgrade.json");
12232
12461
  reportsDir = (root) => join(root, "reports");
12233
12462
  reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
12234
- })), Store, ensureDir, readOptional, missing$2, damaged, jsonOf$2, decoded, unwritable, wrote, added, 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, 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;
12463
+ }));
12464
+ //#endregion
12465
+ //#region src/service/store/service.ts
12466
+ var Store, ensureDir, readOptional, missing$2, damaged, jsonOf$2, decoded, unwritable, 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;
12235
12467
  var init_service$1 = __esmMin((() => {
12236
12468
  init_dist();
12237
12469
  init_git();
@@ -12279,7 +12511,7 @@ var init_service$1 = __esmMin((() => {
12279
12511
  try: () => writeFile(path, body, "utf8"),
12280
12512
  catch: unwritable(path)
12281
12513
  });
12282
- added = (path, body) => tryPromise({
12514
+ added$1 = (path, body) => tryPromise({
12283
12515
  try: () => appendFile(path, `${body}\n`, "utf8"),
12284
12516
  catch: unwritable(path)
12285
12517
  });
@@ -12295,7 +12527,7 @@ var init_service$1 = __esmMin((() => {
12295
12527
  };
12296
12528
  appends = (schema) => {
12297
12529
  const encode = encoded(schema);
12298
- return (path, value) => flatMap(encode(path, value), (wire) => added(path, JSON.stringify(wire)));
12530
+ return (path, value) => flatMap(encode(path, value), (wire) => added$1(path, JSON.stringify(wire)));
12299
12531
  };
12300
12532
  writeSettings = writes(Settings);
12301
12533
  writeUpgradeCheck = writes(UpgradeCheck, INDENT);
@@ -12411,7 +12643,7 @@ var init_service$1 = __esmMin((() => {
12411
12643
  const [repo, head] = yield* all([git.commonDirOf(worktreePath), git.headOf(worktreePath)], { concurrency: 2 });
12412
12644
  return `${repo}#${head}`;
12413
12645
  });
12414
- fn("Store.branchKeyOf")(function* (worktreePath) {
12646
+ branchKeyOf = fn("Store.branchKeyOf")(function* (worktreePath) {
12415
12647
  return yield* branchKeyIn(yield* Git, worktreePath);
12416
12648
  });
12417
12649
  wasKeyOf = fn("Store.wasKeyOf")(function* (git, worktreePath) {
@@ -12676,7 +12908,7 @@ var init_store = __esmMin((() => {
12676
12908
  }));
12677
12909
  //#endregion
12678
12910
  //#region src/review/error.ts
12679
- var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers;
12911
+ var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
12680
12912
  var init_error$2 = __esmMin((() => {
12681
12913
  init_dist();
12682
12914
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
@@ -12697,6 +12929,8 @@ var init_error$2 = __esmMin((() => {
12697
12929
  PartlySent = class extends TaggedError("PartlySent") {};
12698
12930
  PullMoved = class extends TaggedError("PullMoved") {};
12699
12931
  NoLayers = class extends TaggedError("NoLayers") {};
12932
+ NoPull = class extends TaggedError("NoPull") {};
12933
+ UnknownLayer = class extends TaggedError("UnknownLayer") {};
12700
12934
  })), realOf, AUTO, askedFor$1, basedOn, named$3, find, basedAt, worktreeAt, patches, reading, waitingOn, summaryOf, summary, list$5, markOpened, lastOpened, repoOf, nameAt, saveReport, refs, forOne, recentBases, setBase, clearBase;
12701
12935
  var init_branches$1 = __esmMin((() => {
12702
12936
  init_dist();
@@ -12921,7 +13155,7 @@ var init_branches$1 = __esmMin((() => {
12921
13155
  }));
12922
13156
  //#endregion
12923
13157
  //#region src/review/patches.ts
12924
- var findPatch, blobOf, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, shownFile, show$2;
13158
+ var findPatch, blobOf, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, shownFile, show$3;
12925
13159
  var init_patches = __esmMin((() => {
12926
13160
  init_dist();
12927
13161
  init_patch();
@@ -12995,7 +13229,7 @@ var init_patches = __esmMin((() => {
12995
13229
  removed: patch.removed,
12996
13230
  hunks: patch.hunks.map(shownHunk)
12997
13231
  });
12998
- show$2 = fn("Review.Diff.show")(function* (based, showing) {
13232
+ show$3 = fn("Review.Diff.show")(function* (based, showing) {
12999
13233
  const git = yield* Git;
13000
13234
  const { worktree } = based;
13001
13235
  const patches$3 = yield* patches(worktree, linesAround(showing.context), showing.file);
@@ -13512,6 +13746,7 @@ var init_threads$1 = __esmMin((() => {
13512
13746
  stale: batch.head !== conversation.head,
13513
13747
  outside: !conversation.shown.has(comment.anchor.path) || !sits.placed,
13514
13748
  unread: Math.max(0, mine.length - seen),
13749
+ taken: [...ids].some((id) => Object.hasOwn(conversation.taken, id)),
13515
13750
  answers: mine.map(answerOf),
13516
13751
  turns,
13517
13752
  settled
@@ -13543,7 +13778,8 @@ var init_threads$1 = __esmMin((() => {
13543
13778
  head: worktree.head,
13544
13779
  shown: new Set(patches.map((patch) => patch.path)),
13545
13780
  patches,
13546
- read: current.read
13781
+ read: current.read,
13782
+ taken: current.taken ?? {}
13547
13783
  });
13548
13784
  });
13549
13785
  answer$3 = fn("Review.Thread.answer")(function* (worktree, request) {
@@ -13648,7 +13884,7 @@ var init_error$1 = __esmMin((() => {
13648
13884
  }));
13649
13885
  //#endregion
13650
13886
  //#region src/service/forge/service.ts
13651
- var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask, show$1, 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$1, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, ForgeLive;
13887
+ 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$1, 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;
13652
13888
  var init_service = __esmMin((() => {
13653
13889
  init_dist();
13654
13890
  init_error$1();
@@ -13687,7 +13923,7 @@ var init_service = __esmMin((() => {
13687
13923
  }
13688
13924
  };
13689
13925
  ended = (child) => sync(() => void child.kill());
13690
- ask = (repo) => callback$1((resume) => {
13926
+ ask$1 = (repo) => callback$1((resume) => {
13691
13927
  const child = execFile("gh", [
13692
13928
  "pr",
13693
13929
  "list",
@@ -13710,7 +13946,7 @@ var init_service = __esmMin((() => {
13710
13946
  });
13711
13947
  return ended(child);
13712
13948
  });
13713
- show$1 = (repo, branch) => callback$1((resume) => {
13949
+ show$2 = (repo, branch) => callback$1((resume) => {
13714
13950
  const child = execFile("gh", [
13715
13951
  "pr",
13716
13952
  "view",
@@ -13773,11 +14009,11 @@ var init_service = __esmMin((() => {
13773
14009
  }))).login;
13774
14010
  });
13775
14011
  pulls = fn("Forge.pulls")(function* (repo) {
13776
- const [raw, viewer] = yield* all([ask(repo), viewerOf(repo)], { concurrency: 2 });
14012
+ const [raw, viewer] = yield* all([ask$1(repo), viewerOf(repo)], { concurrency: 2 });
13777
14013
  return yield* read$2(repo, raw, viewer);
13778
14014
  });
13779
14015
  openPull = fn("Forge.openPull")(function* (repo, branch) {
13780
- yield* show$1(repo, branch);
14016
+ yield* show$2(repo, branch);
13781
14017
  });
13782
14018
  NUMBER_FIELDS = "number,headRefOid,url";
13783
14019
  Named = Struct({
@@ -13974,7 +14210,7 @@ var init_service = __esmMin((() => {
13974
14210
  "-F",
13975
14211
  "name={repo}"
13976
14212
  ];
13977
- asked = (repo, branch, after) => gh(repo, [
14213
+ asked$1 = (repo, branch, after) => gh(repo, [
13978
14214
  "api",
13979
14215
  "graphql",
13980
14216
  "-f",
@@ -14015,7 +14251,7 @@ var init_service = __esmMin((() => {
14015
14251
  const held = [];
14016
14252
  let after;
14017
14253
  for (let page = 0; page < PAGES; page += 1) {
14018
- const raw = yield* asked(repo, branch, after);
14254
+ const raw = yield* asked$1(repo, branch, after);
14019
14255
  const found = yield* threadsIn(repo, raw);
14020
14256
  if (found === void 0) return held;
14021
14257
  held.push(...found.nodes);
@@ -14077,9 +14313,17 @@ var init_service = __esmMin((() => {
14077
14313
  url: pull.url
14078
14314
  };
14079
14315
  });
14316
+ address = fn("Forge.address")(function* (repo, branch) {
14317
+ const found = yield* named$2(repo, branch);
14318
+ return {
14319
+ number: found.number,
14320
+ url: found.url
14321
+ };
14322
+ });
14080
14323
  ForgeLive = succeed$2(Forge)({
14081
14324
  pulls,
14082
14325
  openPull,
14326
+ address,
14083
14327
  head,
14084
14328
  review,
14085
14329
  remarks,
@@ -14546,13 +14790,14 @@ var init_preferences = __esmMin((() => {
14546
14790
  }));
14547
14791
  //#endregion
14548
14792
  //#region src/review/layers.ts
14549
- var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, storedLayers, set, show, read, partsOfFile, vouchPart;
14793
+ var STALE_ADVICE, unique, spansOfLayer, tidyPath, spanFault, blockFault, codeBlockOf, tidyBlock, blocksOf, layerFault, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, storedLayers, set, readInLayer, withRead, show$1, read, partsOfFile, vouchPart, ASK_LEAD, askingFor, ask, claims, vouchIn;
14550
14794
  var init_layers = __esmMin((() => {
14551
14795
  init_dist();
14552
14796
  init_layers$1();
14553
14797
  init_store();
14554
14798
  init_review$1();
14555
14799
  init_error$2();
14800
+ init_comments$1();
14556
14801
  init_branches$1();
14557
14802
  init_vouching$1();
14558
14803
  STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
@@ -14715,14 +14960,37 @@ var init_layers = __esmMin((() => {
14715
14960
  yield* store.saveLayers(worktree.path, toStored(layers));
14716
14961
  return reportOf(patches$1, layers, worktree.head);
14717
14962
  });
14718
- show = fn("Review.Layers.show")(function* (worktree) {
14963
+ readInLayer = (layer, reading) => layer.files.filter((path) => {
14964
+ const blob = reading.patches.find((patch) => patch.path === path)?.blob ?? "";
14965
+ if (isVouched(reading.vouches, path, blob)) return true;
14966
+ const spans = layer.spans.filter((span) => span.path === path);
14967
+ return reading.parts.includes(partOf(path, spans));
14968
+ });
14969
+ withRead = (report, reading) => ({
14970
+ ...report,
14971
+ layers: report.layers.map((layer) => ({
14972
+ ...layer,
14973
+ read: readInLayer(layer, reading)
14974
+ }))
14975
+ });
14976
+ show$1 = fn("Review.Layers.show")(function* (worktree) {
14977
+ const store = yield* Store;
14719
14978
  const patches$2 = yield* patches(worktree);
14720
14979
  const found = yield* storedLayers(worktree);
14721
14980
  const layers = yield* match$3(found, {
14722
14981
  onNone: () => new NoLayers({ worktree: worktree.path }),
14723
14982
  onSome: succeed$1
14724
14983
  });
14725
- return reportOf(patches$2, layers, worktree.head);
14984
+ const current = yield* store.state(worktree.path);
14985
+ const files = patches$2.map((patch) => ({
14986
+ path: patch.path,
14987
+ blob: patch.blob
14988
+ }));
14989
+ return withRead(reportOf(patches$2, layers, worktree.head), {
14990
+ patches: patches$2,
14991
+ vouches: current.vouches,
14992
+ parts: readParts(current.parts, files)
14993
+ });
14726
14994
  });
14727
14995
  read = fn("Review.Layers.read")(function* (reading) {
14728
14996
  const worktree = reading.worktree;
@@ -14763,6 +15031,47 @@ var init_layers = __esmMin((() => {
14763
15031
  total: reading.patches.length
14764
15032
  };
14765
15033
  });
15034
+ ASK_LEAD = "About this branch, not about this line.";
15035
+ askingFor = (told) => {
15036
+ if (told.count === 0) return `${ASK_LEAD} Please write a reading order for it with \`adiff layers set\`, so the diff can be read in the order the change was made rather than by filename.`;
15037
+ if (told.stale) return `${ASK_LEAD} The reading order on it describes an older commit — please read the diff again and write a new one with \`adiff layers set\`.`;
15038
+ return `${ASK_LEAD} Please revise its reading order with \`adiff layers set\`.`;
15039
+ };
15040
+ ask = fn("Review.Layers.ask")(function* (reading, request) {
15041
+ const first = reading.patches[0];
15042
+ if (first === void 0) return yield* new UnknownFile({
15043
+ file: "",
15044
+ known: []
15045
+ });
15046
+ const told = yield* read(reading);
15047
+ const body = askingFor({
15048
+ count: told.layers.length,
15049
+ stale: told.stale
15050
+ });
15051
+ yield* submit(reading.worktree, {
15052
+ file: first.path,
15053
+ side: "new",
15054
+ start: 1,
15055
+ end: 1,
15056
+ body,
15057
+ id: request.id,
15058
+ at: request.at
15059
+ });
15060
+ return { asked: body };
15061
+ });
15062
+ claims = (layer, file) => layer.spans.some((span) => span.path === file);
15063
+ vouchIn = fn("Review.Layers.vouchIn")(function* (reading, file, number) {
15064
+ const held = yield* read(reading);
15065
+ const layer = held.layers[number - 1];
15066
+ if (layer === void 0) return yield* new UnknownLayer({
15067
+ layer: number,
15068
+ known: held.layers.length
15069
+ });
15070
+ const holding = held.layers.filter((one) => claims(one, file)).length;
15071
+ const spans = layer.spans.filter((span) => span.path === file);
15072
+ if (holding < 2 || spans.length === 0) return yield* toggle(reading, file);
15073
+ return yield* vouchPart(reading, file, partOf(file, spans));
15074
+ });
14766
15075
  }));
14767
15076
  //#endregion
14768
15077
  //#region src/review/drafts.ts
@@ -15114,6 +15423,29 @@ var init_search$1 = __esmMin((() => {
15114
15423
  });
15115
15424
  }));
15116
15425
  //#endregion
15426
+ //#region src/review/pulls.ts
15427
+ var show;
15428
+ var init_pulls = __esmMin((() => {
15429
+ init_dist();
15430
+ init_forge();
15431
+ init_error$2();
15432
+ show = fn("Review.Pull.show")(function* (repo, branch) {
15433
+ const forge = yield* Forge;
15434
+ const found = (yield* forge.pulls(repo)).find((pull) => pull.branch === branch);
15435
+ if (found === void 0) return yield* new NoPull({ branch });
15436
+ const where = yield* forge.address(repo, branch);
15437
+ return {
15438
+ branch,
15439
+ number: where.number,
15440
+ url: where.url,
15441
+ state: found.state,
15442
+ draft: found.state === "draft",
15443
+ author: found.author,
15444
+ theirs: found.theirs
15445
+ };
15446
+ });
15447
+ }));
15448
+ //#endregion
15117
15449
  //#region src/review/index.ts
15118
15450
  var init_review = __esmMin((() => {
15119
15451
  init_branches$1();
@@ -15126,6 +15458,7 @@ var init_review = __esmMin((() => {
15126
15458
  init_layers();
15127
15459
  init_drafts$1();
15128
15460
  init_search$1();
15461
+ init_pulls();
15129
15462
  init_error$2();
15130
15463
  }));
15131
15464
  //#endregion
@@ -15262,18 +15595,31 @@ var init_watch = __esmMin((() => {
15262
15595
  }));
15263
15596
  //#endregion
15264
15597
  //#region src/tui/grammars.ts
15265
- var besideThis, css, grammarsAdded;
15598
+ var besideThis, onDisk, embedded, compiled, added, grammarsAdded;
15266
15599
  var init_grammars = __esmMin((() => {
15267
15600
  init_dist();
15268
15601
  besideThis = (path) => fileURLToPath(new URL(`./grammars/${path}`, import.meta.url));
15269
- css = {
15270
- filetype: "css",
15271
- queries: { highlights: [besideThis("css/highlights.scm")] },
15272
- wasm: besideThis("css/tree-sitter-css.wasm")
15602
+ onDisk = sync(() => ({
15603
+ wasm: besideThis("css/tree-sitter-css.wasm"),
15604
+ highlights: besideThis("css/highlights.scm")
15605
+ }));
15606
+ embedded = all({
15607
+ wasm: promise(() => import("./grammars/css/tree-sitter-css.wasm", { with: { type: "file" } })),
15608
+ highlights: promise(() => import("./grammars/css/highlights.scm", { with: { type: "file" } }))
15609
+ }).pipe(map$1((loaded) => ({
15610
+ wasm: loaded.wasm.default,
15611
+ highlights: loaded.highlights.default
15612
+ })));
15613
+ compiled = () => process.versions["bun"] !== void 0;
15614
+ added = (found) => {
15615
+ if (!compiled() && !existsSync(found.wasm)) return;
15616
+ addDefaultParsers([{
15617
+ filetype: "css",
15618
+ queries: { highlights: [found.highlights] },
15619
+ wasm: found.wasm
15620
+ }]);
15273
15621
  };
15274
- grammarsAdded = sync(() => {
15275
- if (existsSync(css.wasm)) addDefaultParsers([css]);
15276
- });
15622
+ grammarsAdded = suspend(() => compiled() ? embedded : onDisk).pipe(map$1(added), catchCause(() => void_));
15277
15623
  }));
15278
15624
  //#endregion
15279
15625
  //#region src/tui/command.ts
@@ -22557,7 +22903,7 @@ var init_remarks = __esmMin((() => {
22557
22903
  }));
22558
22904
  //#endregion
22559
22905
  //#region src/tui/branches.ts
22560
- var openedPull, openedOn, resumeAt, openBranch, readBranch, fillBranches, reloadList, reloadBranch, goBack, loadPulls, loadHeld, showPull, openBases, basedOnRef, clearBaseHere, afterBase, setBaseHere, noticeAnswers, sameSent, noticeFiled, noticeOnList;
22906
+ var openedPull, openedOn, resumeAt, openBranch, readBranch, fillBranches, reloadList, reloadBranch, goBack, loadPulls, loadHeld, showPull, openBases, basedOnRef, clearBaseHere, afterBase, setBaseHere, noticeAnswers, sameSent, sameMarks, noticeFiled, noticeOnList;
22561
22907
  var init_branches = __esmMin((() => {
22562
22908
  init_dist();
22563
22909
  init_forge();
@@ -22613,14 +22959,14 @@ var init_branches = __esmMin((() => {
22613
22959
  const reading$1 = yield* reading(app.repo, name, app.base);
22614
22960
  app.reading = reading$1;
22615
22961
  yield* markOpened(reading$1.worktree, (/* @__PURE__ */ new Date()).toISOString());
22616
- const [progress$1, layers, sent, remarks, drafts] = yield* all([
22962
+ const [progress$2, layers, sent, remarks, drafts] = yield* all([
22617
22963
  progress(reading$1),
22618
22964
  read(reading$1),
22619
22965
  listSent(reading$1),
22620
22966
  app.state.remarksOn ? list$2(reading$1) : succeed$1([]),
22621
22967
  list(reading$1.worktree)
22622
22968
  ], { concurrency: "unbounded" });
22623
- const opened = withVouched(withPatches(app.state, reading$1.patches), progress$1.vouched);
22969
+ const opened = withVouched(withPatches(app.state, reading$1.patches), progress$2.vouched);
22624
22970
  const held = drafts.length > 0 || theirPull(app.state) ? heldOf(drafts) : app.state.held;
22625
22971
  return withRemarks(withLayers(withSent({
22626
22972
  ...opened,
@@ -22715,9 +23061,9 @@ var init_branches = __esmMin((() => {
22715
23061
  return gen(function* () {
22716
23062
  const branch = selectedBranch(app.state);
22717
23063
  if (branch === void 0) return;
22718
- const [refs$1, recent] = yield* all([refs(app.repo), recentBases(app.repo, branch.branch)]);
23064
+ const [refs$2, recent] = yield* all([refs(app.repo), recentBases(app.repo, branch.branch)]);
22719
23065
  const said = Object.fromEntries(recent.map((one) => [one.ref, one.said]));
22720
- const kept = refs$1.filter((ref) => ref !== branch.branch);
23066
+ const kept = refs$2.filter((ref) => ref !== branch.branch);
22721
23067
  app.commit(withRefs(app.state, [...recent.map((one) => one.ref), ...kept], said));
22722
23068
  });
22723
23069
  };
@@ -22780,16 +23126,18 @@ var init_branches = __esmMin((() => {
22780
23126
  });
22781
23127
  };
22782
23128
  sameSent = (one, other) => JSON.stringify(one) === JSON.stringify(other);
23129
+ sameMarks = (state, progress) => JSON.stringify([state.vouched, state.partsRead]) === JSON.stringify([progress.vouched, progress.parts]);
22783
23130
  noticeFiled = (app) => {
22784
23131
  return gen(function* () {
22785
23132
  const branch = selectedBranch(app.state);
22786
23133
  if (branch === void 0) return;
22787
- const sent = yield* loadSent(app, branch.branch);
22788
- if (sameSent(app.state.sent, sent)) return;
22789
- app.commit({
23134
+ const reading = yield* readingOf(app, branch.branch);
23135
+ const [sent, progress$1] = yield* all([listSent(reading), progress(reading)]);
23136
+ if (sameSent(app.state.sent, sent) && sameMarks(app.state, progress$1)) return;
23137
+ app.commit(withVouched({
22790
23138
  ...app.state,
22791
23139
  sent
22792
- });
23140
+ }, progress$1.vouched, progress$1.parts));
22793
23141
  });
22794
23142
  };
22795
23143
  noticeOnList = (app) => {
@@ -22798,7 +23146,7 @@ var init_branches = __esmMin((() => {
22798
23146
  }));
22799
23147
  //#endregion
22800
23148
  //#region src/tui/comments.ts
22801
- var LAYERS_ASK_LEAD, layersAsk, askedFor, compose, openOther, openPanelEntry, openAway, openThreadInFull, jumpingPastGaps, readRewrite, readAnswers, send, toAgent, sendRedraftAsk, toAuthor, sendReply, sendComment, stillListing, dropHeld, unreadSaid, keptSaid, dispatchDrafts, sendHeld, askForLayers, heldChosen, askAgent, replyHere;
23149
+ var layersAsk$1, askedFor, compose, openOther, openPanelEntry, openAway, openThreadInFull, jumpingPastGaps, readRewrite, readAnswers, send, toAgent, sendRedraftAsk, toAuthor, sendReply, sendComment, stillListing, dropHeld, unreadSaid, keptSaid, dispatchDrafts, sendHeld, askForLayers, heldChosen, askAgent, replyHere;
22802
23150
  var init_comments = __esmMin((() => {
22803
23151
  init_dist();
22804
23152
  init_patch();
@@ -22814,12 +23162,10 @@ var init_comments = __esmMin((() => {
22814
23162
  init_words();
22815
23163
  init_review();
22816
23164
  init_reading();
22817
- LAYERS_ASK_LEAD = "About this branch, not about this line.";
22818
- layersAsk = (state) => {
22819
- if (state.layers.length === 0) return `${LAYERS_ASK_LEAD} Please write a reading order for it with \`adiff layers set\`, so the diff can be read in the order the change was made rather than by filename.`;
22820
- if (state.layersStale) return `${LAYERS_ASK_LEAD} The reading order on it describes an older commit — please read the diff again and write a new one with \`adiff layers set\`.`;
22821
- return `${LAYERS_ASK_LEAD} Please revise its reading order with \`adiff layers set\`.`;
22822
- };
23165
+ layersAsk$1 = (state) => askingFor({
23166
+ count: state.layers.length,
23167
+ stale: state.layersStale
23168
+ });
22823
23169
  askedFor = (state) => state.layers.length === 0 ? "asked for a reading order" : "asked for a new reading order";
22824
23170
  compose = (app) => {
22825
23171
  return gen(function* () {
@@ -23140,7 +23486,7 @@ var init_comments = __esmMin((() => {
23140
23486
  side: "new",
23141
23487
  start: 1,
23142
23488
  end: 1,
23143
- body: layersAsk(app.state),
23489
+ body: layersAsk$1(app.state),
23144
23490
  id: randomUUID(),
23145
23491
  at: (/* @__PURE__ */ new Date()).toISOString()
23146
23492
  });
@@ -24855,18 +25201,16 @@ init_git();
24855
25201
  init_forge();
24856
25202
  init_store();
24857
25203
  const WAIT_UNIT = 1e3;
24858
- const answer = (options, body) => {
25204
+ const answer = fn("Main.answer")(function* (options, body) {
24859
25205
  const fields = fieldsOf(options);
24860
25206
  const strange = strangeField(body, fields);
24861
- if (strange !== void 0) return fail(new UnknownField(strange));
24862
- return sync(() => {
24863
- const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
24864
- process.stdout.write(`${JSON.stringify({
24865
- ok: true,
24866
- ...narrowed
24867
- })}\n`);
24868
- });
24869
- };
25207
+ if (strange !== void 0) return yield* new UnknownField(strange);
25208
+ const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
25209
+ return yield* (yield* Replies).say(JSON.stringify({
25210
+ ok: true,
25211
+ ...narrowed
25212
+ }));
25213
+ });
24870
25214
  const worktreeIn = fn("Main.worktreeIn")(function* (options) {
24871
25215
  return yield* find(yield* required(options, "repo"), yield* required(options, "branch"));
24872
25216
  });
@@ -24994,9 +25338,51 @@ const commentList = fn("Main.commentList")(function* (options) {
24994
25338
  const comments = yield* list$3(yield* readingIn(options));
24995
25339
  yield* answer(options, { comments });
24996
25340
  });
25341
+ const resolveRead = fn("Main.resolveRead")(function* (options) {
25342
+ const report = yield* settleRead(yield* worktreeIn(options), stamp(options));
25343
+ yield* answer(options, { settled: report.settled });
25344
+ });
25345
+ const commentRead = fn("Main.commentRead")(function* (options) {
25346
+ const report = yield* markRead(yield* worktreeIn(options), yield* required(options, "id"));
25347
+ yield* answer(options, {
25348
+ read: report.id,
25349
+ unread: report.unread
25350
+ });
25351
+ });
25352
+ const pullShow = fn("Main.pullShow")(function* (options) {
25353
+ const pull = yield* show(yield* required(options, "repo"), yield* required(options, "branch"));
25354
+ yield* answer(options, { pull });
25355
+ });
25356
+ const baseList = fn("Main.baseList")(function* (options) {
25357
+ const repo = yield* required(options, "repo");
25358
+ const branch = yield* required(options, "branch");
25359
+ const [refs$1, recent] = yield* all([refs(repo), recentBases(repo, branch)]);
25360
+ const offered = /* @__PURE__ */ new Set([branch, ...recent.map((one) => one.ref)]);
25361
+ const rest = refs$1.filter((ref) => !offered.has(ref));
25362
+ yield* answer(options, { bases: [...recent, ...rest.map((ref) => ({
25363
+ ref,
25364
+ said: ""
25365
+ }))] });
25366
+ });
25367
+ const branchSearch = fn("Main.branchSearch")(function* (options) {
25368
+ const found = yield* files(yield* readingIn(options), yield* required(options, "term"));
25369
+ yield* answer(options, {
25370
+ matches: found.matches,
25371
+ counted: found.counted,
25372
+ left: found.left
25373
+ });
25374
+ });
25375
+ const layersAsk = fn("Main.layersAsk")(function* (options) {
25376
+ const asked = yield* ask(yield* readingIn(options), {
25377
+ id: options["id"] ?? randomUUID(),
25378
+ at: stamp(options)
25379
+ });
25380
+ yield* answer(options, { asked: asked.asked });
25381
+ });
24997
25382
  const commentResolve = fn("Main.commentResolve")(function* (options) {
25383
+ if (options["read"] !== void 0) return yield* resolveRead(options);
24998
25384
  const report = yield* settle(yield* worktreeIn(options), yield* required(options, "id"), stamp(options));
24999
- yield* answer(options, { settled: report.settled });
25385
+ return yield* answer(options, { settled: report.settled });
25000
25386
  });
25001
25387
  const commentRemove = fn("Main.commentRemove")(function* (options) {
25002
25388
  const report = yield* remove(yield* worktreeIn(options), yield* required(options, "id"), stamp(options));
@@ -25010,8 +25396,14 @@ const commentReopen = fn("Main.commentReopen")(function* (options) {
25010
25396
  const report = yield* unsettle(yield* worktreeIn(options), yield* required(options, "id"));
25011
25397
  yield* answer(options, { reopened: report.unsettled });
25012
25398
  });
25399
+ const vouched = fn("Main.vouched")(function* (options) {
25400
+ const reading = yield* readingIn(options);
25401
+ const file = yield* required(options, "file");
25402
+ if (options["layer"] === void 0) return yield* toggle(reading, file);
25403
+ return yield* vouchIn(reading, file, yield* numeric(options, "layer"));
25404
+ });
25013
25405
  const fileReview = fn("Main.fileReview")(function* (options) {
25014
- const report = yield* toggle(yield* readingIn(options), yield* required(options, "file"));
25406
+ const report = yield* vouched(options);
25015
25407
  yield* answer(options, {
25016
25408
  reviewed: report.vouched,
25017
25409
  total: report.total
@@ -25036,12 +25428,12 @@ const layersSet = fn("Main.layersSet")(function* (options) {
25036
25428
  yield* answer(options, { layers });
25037
25429
  });
25038
25430
  const layersShow = fn("Main.layersShow")(function* (options) {
25039
- const layers = yield* show(yield* worktreeNamed(options));
25431
+ const layers = yield* show$1(yield* worktreeNamed(options));
25040
25432
  yield* answer(options, { layers });
25041
25433
  });
25042
25434
  const patchShow = fn("Main.patchShow")(function* (options) {
25043
25435
  const based = yield* basedAt(yield* required(options, "worktree"), options["base"]);
25044
- const patch = yield* show$2(based, {
25436
+ const patch = yield* show$3(based, {
25045
25437
  file: options["file"],
25046
25438
  context: yield* around$1(options, "context")
25047
25439
  });
@@ -25096,6 +25488,11 @@ const routes = {
25096
25488
  "draft drop": draftDrop,
25097
25489
  "draft send": draftSend,
25098
25490
  "comment resolve": commentResolve,
25491
+ "comment read": commentRead,
25492
+ "pull show": pullShow,
25493
+ "base list": baseList,
25494
+ "branch search": branchSearch,
25495
+ "layers ask": layersAsk,
25099
25496
  "comment remove": commentRemove,
25100
25497
  "comment restore": commentRestore,
25101
25498
  "comment reopen": commentReopen,
@@ -25214,6 +25611,17 @@ const nameOf = (argv) => {
25214
25611
  if (findCommand(pair) !== void 0) return pair;
25215
25612
  return words.length > 1 ? pair : words[0] ?? "";
25216
25613
  };
25614
+ const storeRoot = () => process.env["ADIFF_ROOT"] ?? defaultRoot();
25615
+ const folderOf = fn("Main.folderOf")(function* (given) {
25616
+ const options = yield* addressOf("comment list", given);
25617
+ const worktree = yield* find(yield* required(options, "repo"), yield* required(options, "branch"));
25618
+ return branchDir(storeRoot(), yield* branchKeyOf(worktree.path));
25619
+ });
25620
+ const serving = () => serve({
25621
+ nameOf,
25622
+ run,
25623
+ folderOf
25624
+ });
25217
25625
  const argv = process.argv.slice(2);
25218
25626
  const ASKS = {
25219
25627
  "--version": version,
@@ -25242,12 +25650,14 @@ if (said !== void 0) {
25242
25650
  process.stdout.write(`${said}\n`);
25243
25651
  process.exit(0);
25244
25652
  }
25245
- const layer = mergeAll(ForgeLive, storeAt(process.env["ADIFF_ROOT"] ?? defaultRoot())).pipe(provideMerge(GitLive));
25653
+ const layer = mergeAll(ForgeLive, toStdout, storeAt(storeRoot())).pipe(provideMerge(GitLive));
25246
25654
  const reportFailure = (cause) => sync(() => {
25247
25655
  const reported = failure(squash(cause));
25248
25656
  process.stderr.write(`${reported.line}\n`);
25249
25657
  process.exitCode = reported.exit;
25250
25658
  });
25251
- runFork(run(opening ? "review open" : nameOf(argv), opening ? { repo: "." } : optionsFrom(argv, valuedIn(nameOf(argv)))).pipe(provide(layer), catchCause(reportFailure)));
25659
+ const asked = opening ? "review open" : nameOf(argv);
25660
+ const started = asked === "serve" ? serving() : run(asked, opening ? { repo: "." } : optionsFrom(argv, valuedIn(asked)));
25661
+ runFork(started.pipe(provide(layer), catchCause(reportFailure)));
25252
25662
  //#endregion
25253
25663
  export {};
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.186",
26
+ "version": "0.1.0-alpha.188",
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": {