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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.206
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(comment delivery): one `comment take --wait` listens per worktree, and starting a second one ends the first with `"replaced": true` and no comments.
8
+
9
+ <details><summary>What this changes for an agent</summary>
10
+
11
+ An agent that lost track of a background wait armed another, and both woke on the same comment. The
12
+ newer wait now takes over. The older one exits 0 with an empty `comments` array and
13
+ `"replaced": true`, so its owner knows to leave it ended. A take with no `--wait` leaves the
14
+ listening wait running.
15
+
16
+ </details>
17
+
18
+ breaking(comment delivery): `comment take --wait` hands over only comments this review has not handed over before, and `--new` is retired.
19
+
20
+ <details><summary>What to change</summary>
21
+
22
+ A wait used to end at once on a comment the agent already held unless it was given `--new`. Every
23
+ wait now wakes only for a new comment, a reply, or a comment the reviewer reopened or restored. Drop
24
+ `--new` from the command line. Beside `--wait` it still works and changes nothing, so a wait armed
25
+ from an older skill keeps listening; on a take with no `--wait` it is refused with exit 2. A take
26
+ with no `--wait` still collects every comment owed an answer.
27
+
28
+ </details>
29
+
3
30
  ## 0.1.0-alpha.205
4
31
 
5
32
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10114,16 +10114,17 @@ var init_config = __esmMin((() => {
10114
10114
  //#region package.json
10115
10115
  init_pane();
10116
10116
  init_config();
10117
- var version$1 = "0.1.0-alpha.205";
10117
+ var version$1 = "0.1.0-alpha.206";
10118
10118
  //#endregion
10119
10119
  //#region src/cli/error.ts
10120
- var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10120
+ var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10121
10121
  var init_error$6 = __esmMin((() => {
10122
10122
  init_dist();
10123
10123
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
10124
10124
  MissingOption = class extends TaggedError("MissingOption") {};
10125
10125
  UnknownField = class extends TaggedError("UnknownField") {};
10126
10126
  UnknownOption = class extends TaggedError("UnknownOption") {};
10127
+ RemovedOption = class extends TaggedError("RemovedOption") {};
10127
10128
  BadOption = class extends TaggedError("BadOption") {};
10128
10129
  RegistryUnanswered = class extends TaggedError("RegistryUnanswered") {};
10129
10130
  NotServed = class extends TaggedError("NotServed") {};
@@ -10322,7 +10323,7 @@ var init_upgrade$1 = __esmMin((() => {
10322
10323
  }));
10323
10324
  //#endregion
10324
10325
  //#region src/cli/catalog.ts
10325
- var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, picking, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10326
+ var WAIT_MOST, worktreeOf$1, repoOf$1, branchOf, fieldsOption, addressing, baseOf$1, based, repo, opening$2, file, picking, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, RETIRED, retiredOf, removedIn, retiredIn, knownIn, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, nearestCommand;
10326
10327
  var init_catalog = __esmMin((() => {
10327
10328
  WAIT_MOST = 86400;
10328
10329
  worktreeOf$1 = {
@@ -10645,23 +10646,14 @@ var init_catalog = __esmMin((() => {
10645
10646
  group: ANSWER_COMMENTS,
10646
10647
  addresses: "review",
10647
10648
  safety: "read",
10648
- options: [
10649
- ...addressing,
10650
- {
10651
- name: "wait",
10652
- required: false,
10653
- value: "seconds",
10654
- about: `Block until a comment arrives or the timeout elapses. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10655
- },
10656
- {
10657
- name: "new",
10658
- required: false,
10659
- value: "flag",
10660
- about: "Hand over only comments this review has not handed over before, so a wait ends on something new"
10661
- }
10662
- ],
10649
+ options: [...addressing, {
10650
+ name: "wait",
10651
+ required: false,
10652
+ value: "seconds",
10653
+ about: `Block until a comment this review has not handed over before arrives, or the timeout elapses. One wait listens per worktree: a newer wait ends this one, which then answers with replaced. A whole number of seconds from 1 to ${WAIT_MOST}; anything else is refused`
10654
+ }],
10663
10655
  dataKey: "comments",
10664
- example: "adiff comment take --worktree . --new --wait 6900"
10656
+ example: "adiff comment take --worktree . --wait 6900"
10665
10657
  },
10666
10658
  {
10667
10659
  name: "comment answer",
@@ -11136,6 +11128,20 @@ var init_catalog = __esmMin((() => {
11136
11128
  "quiet"
11137
11129
  ];
11138
11130
  valuedIn = (name) => /* @__PURE__ */ new Set([...VALUED_ANYWHERE, ...(findCommand(name)?.options ?? []).filter((option) => option.value !== "flag").map((option) => option.name)]);
11131
+ RETIRED = { "comment take": { new: {
11132
+ reason: "A take with no --wait hands over every comment still owed an answer. To hand over only new comments, give --wait: every wait does that now.",
11133
+ meantWith: "wait"
11134
+ } } };
11135
+ retiredOf = (name) => RETIRED[name] ?? {};
11136
+ removedIn = (name, given) => {
11137
+ const retired = retiredOf(name);
11138
+ const option = given.find((one) => Object.hasOwn(retired, one) && !given.includes(retired[one]?.meantWith ?? ""));
11139
+ return option === void 0 ? void 0 : {
11140
+ option,
11141
+ reason: retired[option]?.reason ?? ""
11142
+ };
11143
+ };
11144
+ retiredIn = (name, given) => given.filter((one) => Object.hasOwn(retiredOf(name), one));
11139
11145
  knownIn = (name) => /* @__PURE__ */ new Set([...KNOWN_ANYWHERE, ...(findCommand(name)?.options ?? []).map((option) => option.name)]);
11140
11146
  verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
11141
11147
  groups = [...new Set(catalog.map((command) => command.group))];
@@ -11433,6 +11439,11 @@ var init_report$1 = __esmMin((() => {
11433
11439
  suggestion: "That option is not one this command takes. `adiff <command> --help` lists the options it does.",
11434
11440
  retriable: false
11435
11441
  },
11442
+ RemovedOption: {
11443
+ exit: 2,
11444
+ suggestion: "This command no longer takes that option. Run it again without the option; the reason is named above.",
11445
+ retriable: false
11446
+ },
11436
11447
  BadOption: {
11437
11448
  exit: 2,
11438
11449
  suggestion: "That value is not one the option allows. The allowed ones are named above.",
@@ -11571,7 +11582,7 @@ var init_report$1 = __esmMin((() => {
11571
11582
  }));
11572
11583
  //#endregion
11573
11584
  //#region src/cli/serve.ts
11574
- var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11585
+ var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, heldOpen, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11575
11586
  var init_serve = __esmMin((() => {
11576
11587
  init_dist();
11577
11588
  init_error$6();
@@ -11612,8 +11623,10 @@ var init_serve = __esmMin((() => {
11612
11623
  "outbox.jsonl": "comments",
11613
11624
  "state.json": "state",
11614
11625
  "layers.json": "layers",
11615
- "watch.json": "watch"
11626
+ "watch.json": "watch",
11627
+ "wait.json": "watch"
11616
11628
  };
11629
+ heldOpen = (name) => name !== null && name.endsWith(".lock");
11617
11630
  kindOf = (name) => {
11618
11631
  if (name === null) return "other";
11619
11632
  const file = Object.keys(KIND_OF).find((known) => name === known || name.startsWith(`${known}.`));
@@ -11629,6 +11642,7 @@ var init_serve = __esmMin((() => {
11629
11642
  tell(what);
11630
11643
  };
11631
11644
  const watcher = watch(folder, (_event, name) => {
11645
+ if (heldOpen(name)) return;
11632
11646
  seen.add(kindOf(name));
11633
11647
  if (timer !== void 0) clearTimeout(timer);
11634
11648
  timer = setTimeout(told, SETTLE_MS$1);
@@ -12718,7 +12732,7 @@ var init_model$4 = __esmMin((() => {
12718
12732
  }));
12719
12733
  //#endregion
12720
12734
  //#region src/service/store/schema.ts
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;
12735
+ var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, Stamps, Counts, Doing, noStamps, BranchState, StoredSaid, StoredRemark, StoredRemarks, Settings, Watching, Listening, UpgradeCheck, Prose, Code$1, Split, StoredLayer, StoredLayers;
12722
12736
  var init_schema = __esmMin((() => {
12723
12737
  init_dist();
12724
12738
  Side = Literals(["old", "new"]);
@@ -12824,6 +12838,10 @@ var init_schema = __esmMin((() => {
12824
12838
  editor: optionalKey(String$1)
12825
12839
  });
12826
12840
  Watching = Struct({ lookedAt: String$1 });
12841
+ Listening = Struct({
12842
+ wait: String$1,
12843
+ since: String$1
12844
+ });
12827
12845
  UpgradeCheck = Struct({
12828
12846
  note: optionalKey(String$1),
12829
12847
  checkedAt: optionalKey(String$1),
@@ -12866,7 +12884,7 @@ var init_schema = __esmMin((() => {
12866
12884
  }));
12867
12885
  //#endregion
12868
12886
  //#region src/service/store/paths.ts
12869
- var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, watchPath, draftsPath, layersPath, remarksPath, settingsPath, upgradePath, reportsDir, reportPath;
12887
+ var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, watchPath, waitPath, draftsPath, layersPath, remarksPath, settingsPath, upgradePath, reportsDir, reportPath;
12870
12888
  var init_paths = __esmMin((() => {
12871
12889
  NON_SLUG = /[^a-zA-Z0-9]+/g;
12872
12890
  slugOf = (worktreePath) => worktreePath.replace(NON_SLUG, "-");
@@ -12876,6 +12894,7 @@ var init_paths = __esmMin((() => {
12876
12894
  outboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "outbox.jsonl");
12877
12895
  statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
12878
12896
  watchPath = (root, worktreePath) => join(branchDir(root, worktreePath), "watch.json");
12897
+ waitPath = (root, worktreePath) => join(branchDir(root, worktreePath), "wait.json");
12879
12898
  draftsPath = (root, worktreePath) => join(branchDir(root, worktreePath), "drafts.json");
12880
12899
  layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
12881
12900
  remarksPath = (root, worktreePath) => join(branchDir(root, worktreePath), "remarks.json");
@@ -12886,7 +12905,7 @@ var init_paths = __esmMin((() => {
12886
12905
  }));
12887
12906
  //#endregion
12888
12907
  //#region src/service/store/service.ts
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;
12908
+ var Store, ensureDir, readOptional, missing$2, damaged, jsonOf$2, decoded, unwritable, besideOf$1, wrote, added$1, INDENT, DRAFTS_VERSION, encoded, writes, appends, writeSettings, writeUpgradeCheck, writeState, writeLayers, writeRemarks, writeDrafts, writeBatch, writeAnswer, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asRemarks, asDrafts, asWatching, asListening, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, parseRemarks, idsIn$1, takes, handedOps, cursorOps, waitOps, settingsOps, upgradeOps, reportOps, branchKeyIn, branchKeyOf, wasKeyOf, there, moved, adopt, SPLIT, ADOPT_SIZE, adopting, keyIn, answerOps, layersOps, remarksOps, inboxOps, STATE_LOCK, DRAFTS_LOCK, held$2, stale$1, stolen, taken, freed, alone, watchOps, draftsOps, stateOps, makeStore, madeStore, storeAt;
12890
12909
  var init_service$2 = __esmMin((() => {
12891
12910
  init_dist();
12892
12911
  init_git();
@@ -12976,6 +12995,7 @@ var init_service$2 = __esmMin((() => {
12976
12995
  asRemarks = decoded(StoredRemarks);
12977
12996
  asDrafts = decoded(Drafts);
12978
12997
  asWatching = decoded(Watching);
12998
+ asListening = decoded(Listening);
12979
12999
  linesOf = (raw) => raw.split("\n").filter((line) => line.trim().length > 0);
12980
13000
  readLines = (path, raw, as) => forEach(linesOf(raw), (line) => jsonOf$2(path, line).pipe(flatMap((value) => as(path, value))));
12981
13001
  parseSettings = fn("Store.parseSettings")(function* (path, raw) {
@@ -13003,34 +13023,52 @@ var init_service$2 = __esmMin((() => {
13003
13023
  ...was.taken
13004
13024
  }
13005
13025
  });
13006
- cursorOps = (state, inbox, spoken, changeState) => {
13007
- const handedIn = fn("Store.handedIn")(function* (worktreePath, handing) {
13008
- const batches = yield* inbox(worktreePath);
13009
- const current = yield* state(worktreePath);
13010
- const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
13011
- const taken = current.taken ?? {};
13012
- const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id) && (handing === "owed" || !Object.hasOwn(taken, comment.id));
13013
- return batches.flatMap((batch) => {
13014
- const comments = batch.comments.filter(owed);
13015
- return comments.length === 0 ? [] : [{
13016
- id: batch.id,
13017
- at: batch.at,
13018
- head: batch.head,
13019
- comments
13020
- }];
13021
- });
13026
+ handedOps = (state, inbox, spoken) => fn("Store.handedIn")(function* (worktreePath, handing) {
13027
+ const batches = yield* inbox(worktreePath);
13028
+ const current = yield* state(worktreePath);
13029
+ const answered = new Set((yield* spoken(worktreePath)).map((entry) => entry.comment));
13030
+ const taken = current.taken ?? {};
13031
+ const owed = (comment) => !answered.has(comment.id) && !Object.hasOwn(current.settled, comment.id) && !Object.hasOwn(current.removed, comment.id) && (handing === "owed" || !Object.hasOwn(taken, comment.id));
13032
+ return batches.flatMap((batch) => {
13033
+ const comments = batch.comments.filter(owed);
13034
+ return comments.length === 0 ? [] : [{
13035
+ id: batch.id,
13036
+ at: batch.at,
13037
+ head: batch.head,
13038
+ comments
13039
+ }];
13022
13040
  });
13041
+ });
13042
+ cursorOps = (handedIn, state, saveState, holdingState) => {
13023
13043
  const owedIn = (worktreePath) => handedIn(worktreePath, "owed");
13044
+ const marked = fn("Store.marked")(function* (worktreePath, at, handing) {
13045
+ const batches = yield* handedIn(worktreePath, handing);
13046
+ const ids = idsIn$1(batches);
13047
+ if (ids.length > 0) yield* saveState(worktreePath, takes(ids, at)(yield* state(worktreePath)));
13048
+ return batches;
13049
+ });
13024
13050
  return {
13025
- take: fn("Store.take")(function* (worktreePath, at, handing = "owed") {
13026
- const batches = yield* handedIn(worktreePath, handing);
13027
- const ids = idsIn$1(batches);
13028
- if (ids.length > 0) yield* changeState(worktreePath, takes(ids, at));
13029
- return batches;
13051
+ take: fn("Store.take")(function* (worktreePath, at) {
13052
+ const seen = yield* handedIn(worktreePath, "owed");
13053
+ return seen.length === 0 ? seen : yield* holdingState(worktreePath, marked(worktreePath, at, "owed"));
13030
13054
  }),
13055
+ marked,
13031
13056
  owed: owedIn
13032
13057
  };
13033
13058
  };
13059
+ waitOps = (handedIn, marked, holdingState, listening) => {
13060
+ const heldBy = (worktreePath, wait) => map$1(listening(worktreePath), (found) => isSome(found) && found.value.wait === wait);
13061
+ const markedFor = fn("Store.markedFor")(function* (worktreePath, at, wait) {
13062
+ if (!(yield* heldBy(worktreePath, wait))) return none();
13063
+ return some(yield* marked(worktreePath, at, "new"));
13064
+ });
13065
+ return { takeListening: fn("Store.takeListening")(function* (worktreePath, at, wait) {
13066
+ if (!(yield* heldBy(worktreePath, wait))) return none();
13067
+ const seen = yield* handedIn(worktreePath, "new");
13068
+ if (seen.length === 0) return some(seen);
13069
+ return yield* holdingState(worktreePath, markedFor(worktreePath, at, wait));
13070
+ }) };
13071
+ };
13034
13072
  settingsOps = (root) => {
13035
13073
  return {
13036
13074
  settings: gen(function* () {
@@ -13228,6 +13266,14 @@ var init_service$2 = __esmMin((() => {
13228
13266
  const path = watchPath(root, key);
13229
13267
  yield* ensureDir(branchDir(root, key));
13230
13268
  yield* wrote(path, JSON.stringify({ lookedAt: at }));
13269
+ }),
13270
+ listening: fn("Store.listening")(function* (worktreePath) {
13271
+ const key = yield* keyOf(worktreePath);
13272
+ const path = waitPath(root, key);
13273
+ const raw = yield* readOptional(path);
13274
+ if (isNone(raw)) return none();
13275
+ const value = yield* jsonOf$2(path, raw.value);
13276
+ return some(yield* asListening(path, value));
13231
13277
  })
13232
13278
  };
13233
13279
  };
@@ -13276,10 +13322,13 @@ var init_service$2 = __esmMin((() => {
13276
13322
  yield* ensureDir(branchDir(root, key));
13277
13323
  yield* writeState(path, next);
13278
13324
  });
13279
- const changeState = fn("Store.changeState")(function* (worktreePath, change) {
13325
+ const holdingState = (worktreePath, work) => gen(function* () {
13280
13326
  const key = yield* keyOf(worktreePath);
13281
13327
  yield* ensureDir(branchDir(root, key));
13282
- yield* alone(`${statePath(root, key)}.lock`, STATE_LOCK, under(worktreePath, change));
13328
+ return yield* alone(`${statePath(root, key)}.lock`, STATE_LOCK, work);
13329
+ }).pipe(withSpan("Store.holdingState"));
13330
+ const changeState = fn("Store.changeState")(function* (worktreePath, change) {
13331
+ yield* holdingState(worktreePath, under(worktreePath, change));
13283
13332
  });
13284
13333
  const under = fn("Store.under")(function* (worktreePath, change) {
13285
13334
  yield* saveState(worktreePath, change(yield* state(worktreePath)));
@@ -13287,14 +13336,25 @@ var init_service$2 = __esmMin((() => {
13287
13336
  return {
13288
13337
  state,
13289
13338
  saveState,
13290
- changeState
13339
+ changeState,
13340
+ holdingState
13291
13341
  };
13292
13342
  };
13293
13343
  makeStore = (root, git, keyOf) => {
13294
13344
  const { submit, inbox } = inboxOps(root, keyOf);
13295
- const { state, saveState, changeState } = stateOps(root, keyOf);
13345
+ const { state, saveState, changeState, holdingState } = stateOps(root, keyOf);
13296
13346
  const talk = answerOps(root, keyOf);
13297
- const cursors = cursorOps(state, inbox, talk.answers, changeState);
13347
+ const watch = watchOps(root, keyOf);
13348
+ const handedIn = handedOps(state, inbox, talk.answers);
13349
+ const { marked, ...cursors } = cursorOps(handedIn, state, saveState, holdingState);
13350
+ const waits = waitOps(handedIn, marked, holdingState, watch.listening);
13351
+ const listen = fn("Store.listen")(function* (worktreePath, wait, since) {
13352
+ const key = yield* keyOf(worktreePath);
13353
+ yield* holdingState(worktreePath, wrote(waitPath(root, key), JSON.stringify({
13354
+ wait,
13355
+ since
13356
+ })));
13357
+ });
13298
13358
  return {
13299
13359
  root,
13300
13360
  branchAt: git.headOf,
@@ -13309,9 +13369,11 @@ var init_service$2 = __esmMin((() => {
13309
13369
  ...talk,
13310
13370
  ...layersOps(root, keyOf),
13311
13371
  ...remarksOps(root, keyOf),
13312
- ...watchOps(root, keyOf),
13372
+ ...watch,
13373
+ listen,
13313
13374
  ...draftsOps(root, keyOf),
13314
- ...cursors
13375
+ ...cursors,
13376
+ ...waits
13315
13377
  };
13316
13378
  };
13317
13379
  madeStore = fn("Store.make")(function* (root) {
@@ -14186,7 +14248,7 @@ var init_placing = __esmMin((() => {
14186
14248
  }));
14187
14249
  //#endregion
14188
14250
  //#region src/review/comments.ts
14189
- var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, take, awaitTaken, markRead;
14251
+ var POLL, bodyOf, saidTo, spunOf, sentOf, placedNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, flatten, listSent, submitMany, submit, without$2, reply, threadBefore, layerOver, layersOn, dressed, take, REPLACED, listened, awaitTaken, markRead;
14190
14252
  var init_comments$1 = __esmMin((() => {
14191
14253
  init_dist();
14192
14254
  init_patch();
@@ -14424,12 +14486,9 @@ var init_comments$1 = __esmMin((() => {
14424
14486
  onSome: (held) => held.layers
14425
14487
  });
14426
14488
  });
14427
- take = fn("Review.Comment.take")(function* (worktreePath, handing = "owed") {
14489
+ dressed = fn("Review.Comment.dressed")(function* (resolved, batches) {
14428
14490
  const store = yield* Store;
14429
- const resolved = yield* realOf(worktreePath);
14430
- const at = (/* @__PURE__ */ new Date()).toISOString();
14431
- yield* ignore(store.noteWatching(resolved, at));
14432
- const owed = flatten(yield* store.take(resolved, at, handing));
14491
+ const owed = flatten(batches);
14433
14492
  if (owed.length === 0) return owed;
14434
14493
  const layers = yield* layersOn(resolved);
14435
14494
  const under = (one) => {
@@ -14442,7 +14501,40 @@ var init_comments$1 = __esmMin((() => {
14442
14501
  const carried = (one) => one.replyTo === void 0 ? one : Object.assign({}, one, { thread: threadBefore(one, held, spoken) });
14443
14502
  return owed.map(carried).map(under);
14444
14503
  });
14445
- awaitTaken = (worktreePath, deadline, handing = "owed") => take(worktreePath, handing).pipe(flatMap((comments) => comments.length > 0 || Date.now() >= deadline ? succeed$1(comments) : sleep(POLL).pipe(flatMap(() => awaitTaken(worktreePath, deadline, handing)))));
14504
+ take = fn("Review.Comment.take")(function* (worktreePath) {
14505
+ const store = yield* Store;
14506
+ const resolved = yield* realOf(worktreePath);
14507
+ const at = (/* @__PURE__ */ new Date()).toISOString();
14508
+ yield* ignore(store.noteWatching(resolved, at));
14509
+ return yield* dressed(resolved, yield* store.take(resolved, at));
14510
+ });
14511
+ REPLACED = {
14512
+ comments: [],
14513
+ replaced: true
14514
+ };
14515
+ listened = (listen) => gen(function* () {
14516
+ const store = yield* Store;
14517
+ const at = (/* @__PURE__ */ new Date()).toISOString();
14518
+ yield* ignore(store.noteWatching(listen.resolved, at));
14519
+ const taken = yield* store.takeListening(listen.resolved, at, listen.wait);
14520
+ if (isNone(taken)) return REPLACED;
14521
+ const comments = yield* dressed(listen.resolved, taken.value);
14522
+ if (comments.length > 0 || Date.now() >= listen.deadline) return {
14523
+ comments,
14524
+ replaced: false
14525
+ };
14526
+ return yield* sleep(POLL).pipe(flatMap(() => listened(listen)));
14527
+ });
14528
+ awaitTaken = fn("Review.Comment.awaitTaken")(function* (worktreePath, deadline, wait) {
14529
+ const store = yield* Store;
14530
+ const resolved = yield* realOf(worktreePath);
14531
+ yield* store.listen(resolved, wait, (/* @__PURE__ */ new Date()).toISOString());
14532
+ return yield* listened({
14533
+ resolved,
14534
+ deadline,
14535
+ wait
14536
+ });
14537
+ });
14446
14538
  markRead = fn("Review.Comment.markRead")(function* (worktree, id) {
14447
14539
  const store = yield* Store;
14448
14540
  const spoken = yield* store.answers(worktree.path);
@@ -17027,7 +17119,7 @@ const banner = () => [
17027
17119
  "An agent working in that worktree answers them:",
17028
17120
  "",
17029
17121
  " adiff comment take --worktree . collect every comment owed an answer",
17030
- " adiff comment take --worktree . --new --wait 6900 block until a new comment arrives",
17122
+ " adiff comment take --worktree . --wait 6900 block until a new comment arrives",
17031
17123
  " adiff comment answer --worktree . --id <id> --body '…'",
17032
17124
  " adiff layers set --worktree . --json - publish a reading order, when asked",
17033
17125
  "",
@@ -26886,17 +26978,27 @@ const commentReply = fn("Main.commentReply")(function* (options) {
26886
26978
  });
26887
26979
  yield* answer(options, { batch });
26888
26980
  });
26889
- const NOTHING_WAITING = "No comment is waiting. Pass --new --wait <seconds> to block until a new one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26981
+ const NOTHING_WAITING = "No comment is waiting. Pass --wait <seconds> to block until a new one arrives, and answer what you collect with `adiff comment answer --worktree . --id <id> --body '…'`.";
26982
+ const WAIT_REPLACED = "A newer wait on this worktree took over, so this wait ended and handed over nothing. Leave this wait ended: the newer wait is the one listening.";
26983
+ const noteOn = (waited) => {
26984
+ if (waited.replaced) return {
26985
+ replaced: true,
26986
+ hint: WAIT_REPLACED
26987
+ };
26988
+ return waited.comments.length === 0 ? { hint: NOTHING_WAITING } : {};
26989
+ };
26890
26990
  const commentTake = fn("Main.commentTake")(function* (options) {
26891
26991
  const worktree = yield* required(options, "worktree");
26892
26992
  const wait = yield* seconds(options, "wait");
26893
- const handing = options["new"] === void 0 ? "owed" : "new";
26894
- const comments = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT, handing) : yield* take(worktree, handing);
26895
- const hint = comments.length === 0 ? { hint: NOTHING_WAITING } : {};
26993
+ const waited = wait > 0 ? yield* awaitTaken(worktree, Date.now() + wait * WAIT_UNIT, randomUUID()) : {
26994
+ comments: yield* take(worktree),
26995
+ replaced: false
26996
+ };
26997
+ const branch = yield* nameAt(worktree);
26896
26998
  yield* answer(options, {
26897
- comments,
26898
- branch: yield* nameAt(worktree),
26899
- ...hint
26999
+ comments: waited.comments,
27000
+ branch,
27001
+ ...noteOn(waited)
26900
27002
  });
26901
27003
  });
26902
27004
  const commentAnswer = fn("Main.commentAnswer")(function* (options) {
@@ -27235,7 +27337,17 @@ const wanting = (name) => (error) => {
27235
27337
  usage: usageOf(command)
27236
27338
  }));
27237
27339
  };
27238
- const run = (name, options) => onlyKnown(options, knownIn(name)).pipe(flatMap(() => dispatch(name, options)), catchTag("MissingOption", wanting(name)));
27340
+ const stillTaken = (name, options) => {
27341
+ const removed = removedIn(name, Object.keys(options));
27342
+ if (removed !== void 0) return fail(new RemovedOption({
27343
+ option: removed.option,
27344
+ command: name,
27345
+ reason: removed.reason
27346
+ }));
27347
+ const retired = new Set(retiredIn(name, Object.keys(options)));
27348
+ return succeed$1(Object.fromEntries(Object.entries(options).filter(([key]) => !retired.has(key))));
27349
+ };
27350
+ const run = (name, options) => stillTaken(name, options).pipe(flatMap((kept) => onlyKnown(kept, knownIn(name)).pipe(flatMap(() => dispatch(name, kept)))), catchTag("MissingOption", wanting(name)));
27239
27351
  const leading = (argv) => {
27240
27352
  const stop = argv.findIndex((token) => token.startsWith("-"));
27241
27353
  return stop === -1 ? argv : argv.slice(0, stop);
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "bin": {
25
25
  "adiff": "./bin/adiff.js"
26
26
  },
27
- "version": "0.1.0-alpha.205",
27
+ "version": "0.1.0-alpha.206",
28
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.",
29
29
  "license": "MIT",
30
30
  "repository": {
@@ -52,16 +52,19 @@ adiff comment take --worktree .
52
52
  Then listen for what comes next:
53
53
 
54
54
  ```bash
55
- adiff comment take --worktree . --new --wait 6900
55
+ adiff comment take --worktree . --wait 6900
56
56
  ```
57
57
 
58
- `--new` hands back only comments this review has not handed you before: a new comment, a reply to
58
+ A wait hands back only comments this review has not handed you before: a new comment, a reply to
59
59
  one of your answers, or a comment the reviewer reopened or restored. Comments you already took
60
60
  and are still working on never end the wait, so it wakes you only for something new. It blocks until
61
61
  such a comment arrives or the timeout in seconds elapses, then returns the same envelope.
62
62
 
63
- An empty `comments` array means only that the wait ran out. It is not an error and not news: run the
64
- same wait again and say nothing to the user about it.
63
+ Do not pass `--new`. Every wait already hands over only new comments; beside `--wait` the option
64
+ changes nothing, and on a take with no `--wait` it is refused with exit 2.
65
+
66
+ An empty `comments` array with no `replaced` field means only that the wait ran out. It is not an
67
+ error and not news: run the same wait again and say nothing to the user about it.
65
68
 
66
69
  Run it in the background, never in the foreground. In Claude Code that is the Bash tool with
67
70
  `run_in_background` and a `timeout` of 7200000. 6900 seconds keeps the wait under the harness's
@@ -81,17 +84,28 @@ Arm the wait as the first thing you do in a turn, before the work. A turn that i
81
84
  half-way then still leaves a listener running, and a wait armed at the end of a turn is a wait that
82
85
  often never gets armed.
83
86
 
84
- Keep one wait per worktree. Two waits running at once hand the same comment to both, which is two of
85
- you answering one comment. Before starting one, check whether one is already running.
87
+ adiff keeps one wait per worktree. Starting a wait ends the wait that was already listening there,
88
+ so arm one whenever you are unsure whether yours is still running. You never need to look for an old
89
+ wait or stop one first.
90
+
91
+ The wait that was ended returns at once with an empty `comments` array and `"replaced": true`:
92
+
93
+ ```json
94
+ {"ok":true,"comments":[],"branch":"add-invitations","replaced":true,"hint":"…"}
95
+ ```
96
+
97
+ `replaced` means a newer wait on this worktree is listening in its place. Leave the replaced wait
98
+ ended and say nothing to the user about it. Arming another one would only end the wait that took
99
+ over. An empty answer with no `replaced` field is a wait that ran out, and that one you do run again.
86
100
 
87
- Re-arm it as soon as it returns, before you handle what it returned, and keep it running while you
88
- work. A reviewer reads at their own pace, so comments arrive minutes apart, and the whole point is
101
+ Re-arm it as soon as it returns comments or runs out, before you handle what it returned, and keep
102
+ it running while you work. A reviewer reads at their own pace, so comments arrive minutes apart, and the whole point is
89
103
  that they reach you as events rather than by you asking. When you finish a piece of work, say you are
90
104
  still listening.
91
105
 
92
106
  A backgrounded wait that is killed rather than expiring is not the reviewer going quiet, and not a
93
107
  reason to stop listening. A kill loses nothing: taking is what records a comment as handed over, so a
94
- comment that arrived after the kill is still new to the next `--new` wait. Arm a new one.
108
+ comment that arrived after the kill is still new to the next wait. Arm a new one.
95
109
 
96
110
  ## Answering a comment
97
111
 
@@ -168,7 +182,7 @@ answer as many comments as it addresses. When a comment is a question rather tha
168
182
  it with `adiff comment answer` too; an answer written into a commit message never reaches the
169
183
  reviewer's screen.
170
184
 
171
- Handle every comment in the batch. The `--new` wait you re-armed does not hand them back, so a
185
+ Handle every comment in the batch. The wait you re-armed does not hand them back, so a
172
186
  comment you skip waits for your next plain take.
173
187
 
174
188
  ## Failure