@eliya-oss/agent-diff 0.1.0-alpha.11 → 0.1.0-alpha.13

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,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Reword or withdraw a staged comment, and see when a thread describes an older commit.
8
+
9
+ ## 0.1.0-alpha.12
10
+
11
+ ### Patch Changes
12
+
13
+ - An agent can answer a comment, and a reviewer can settle the thread.
14
+
3
15
  ## 0.1.0-alpha.11
4
16
 
5
17
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10795,7 +10795,8 @@ var StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
10795
10795
  const emptyBranchState = {
10796
10796
  vouches: {},
10797
10797
  consumed: 0,
10798
- pending: []
10798
+ pending: [],
10799
+ settled: {}
10799
10800
  };
10800
10801
  //#endregion
10801
10802
  //#region src/service/store/paths.ts
@@ -10804,6 +10805,7 @@ const slugOf = (worktreePath) => worktreePath.replace(NON_SLUG, "-");
10804
10805
  const defaultRoot = () => join(homedir(), ".adiff");
10805
10806
  const branchDir = (root, worktreePath) => join(root, "branches", slugOf(worktreePath));
10806
10807
  const inboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "inbox.jsonl");
10808
+ const outboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "outbox.jsonl");
10807
10809
  const statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
10808
10810
  const layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
10809
10811
  const reportsDir = (root) => join(root, "reports");
@@ -10831,6 +10833,7 @@ const readOptional = fn("Store.readOptional")(function* (path) {
10831
10833
  });
10832
10834
  const missing = succeed(none());
10833
10835
  const parseBatches = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
10836
+ const parseAnswers = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
10834
10837
  const parseState = (raw) => ({
10835
10838
  ...emptyBranchState,
10836
10839
  ...JSON.parse(raw)
@@ -10846,6 +10849,26 @@ const cursorOps = (state, saveState, inbox) => {
10846
10849
  });
10847
10850
  return pending;
10848
10851
  }),
10852
+ restage: fn("Store.restage")(function* (worktreePath, comment) {
10853
+ const current = yield* state(worktreePath);
10854
+ if (!current.pending.some((entry) => entry.id === comment.id)) return none();
10855
+ const pending = current.pending.map((entry) => entry.id === comment.id ? comment : entry);
10856
+ yield* saveState(worktreePath, {
10857
+ ...current,
10858
+ pending
10859
+ });
10860
+ return some(pending);
10861
+ }),
10862
+ unstage: fn("Store.unstage")(function* (worktreePath, id) {
10863
+ const current = yield* state(worktreePath);
10864
+ if (!current.pending.some((entry) => entry.id === id)) return none();
10865
+ const pending = current.pending.filter((entry) => entry.id !== id);
10866
+ yield* saveState(worktreePath, {
10867
+ ...current,
10868
+ pending
10869
+ });
10870
+ return some(pending);
10871
+ }),
10849
10872
  take: fn("Store.take")(function* (worktreePath) {
10850
10873
  const batches = yield* inbox(worktreePath);
10851
10874
  const current = yield* state(worktreePath);
@@ -10858,6 +10881,40 @@ const cursorOps = (state, saveState, inbox) => {
10858
10881
  })
10859
10882
  };
10860
10883
  };
10884
+ const reportOps = (root) => fn("Store.saveReport")(function* (stamp, text) {
10885
+ const path = reportPath(root, stamp);
10886
+ yield* ensureDir(reportsDir(root));
10887
+ yield* tryPromise({
10888
+ try: () => writeFile(path, text, "utf8"),
10889
+ catch: (cause) => new StoreUnwritable({
10890
+ path,
10891
+ reason: String(cause)
10892
+ })
10893
+ });
10894
+ return path;
10895
+ });
10896
+ const answerOps = (root) => {
10897
+ return {
10898
+ answer: fn("Store.answer")(function* (worktreePath, entry) {
10899
+ const path = outboxPath(root, worktreePath);
10900
+ yield* ensureDir(branchDir(root, worktreePath));
10901
+ yield* tryPromise({
10902
+ try: () => appendFile(path, `${JSON.stringify(entry)}\n`, "utf8"),
10903
+ catch: (cause) => new StoreUnwritable({
10904
+ path,
10905
+ reason: String(cause)
10906
+ })
10907
+ });
10908
+ }),
10909
+ answers: fn("Store.answers")(function* (worktreePath) {
10910
+ const raw = yield* readOptional(outboxPath(root, worktreePath));
10911
+ return match$2(raw, {
10912
+ onNone: () => [],
10913
+ onSome: parseAnswers
10914
+ });
10915
+ })
10916
+ };
10917
+ };
10861
10918
  const layersOps = (root) => {
10862
10919
  return {
10863
10920
  layers: fn("Store.layers")(function* (worktreePath) {
@@ -10914,18 +10971,6 @@ const makeStore = (root) => {
10914
10971
  })
10915
10972
  });
10916
10973
  });
10917
- const saveReport = fn("Store.saveReport")(function* (stamp, text) {
10918
- const path = reportPath(root, stamp);
10919
- yield* ensureDir(reportsDir(root));
10920
- yield* tryPromise({
10921
- try: () => writeFile(path, text, "utf8"),
10922
- catch: (cause) => new StoreUnwritable({
10923
- path,
10924
- reason: String(cause)
10925
- })
10926
- });
10927
- return path;
10928
- });
10929
10974
  const cursors = cursorOps(state, saveState, inbox);
10930
10975
  return {
10931
10976
  root,
@@ -10933,7 +10978,8 @@ const makeStore = (root) => {
10933
10978
  inbox,
10934
10979
  state,
10935
10980
  saveState,
10936
- saveReport,
10981
+ saveReport: reportOps(root),
10982
+ ...answerOps(root),
10937
10983
  ...layersOps(root),
10938
10984
  ...cursors
10939
10985
  };
@@ -10944,6 +10990,7 @@ storeAt(defaultRoot());
10944
10990
  //#region src/cli/error.ts
10945
10991
  var UnknownBranch = class extends TaggedError("UnknownBranch") {};
10946
10992
  var UnknownFile = class extends TaggedError("UnknownFile") {};
10993
+ var UnknownComment = class extends TaggedError("UnknownComment") {};
10947
10994
  var UnselectableRange = class extends TaggedError("UnselectableRange") {};
10948
10995
  var UnknownCommand = class extends TaggedError("UnknownCommand") {};
10949
10996
  var MissingOption = class extends TaggedError("MissingOption") {};
@@ -11091,10 +11138,30 @@ const stageComment = fn("Cli.stageComment")(function* (request) {
11091
11138
  };
11092
11139
  return { pending: (yield* store.stage(worktree.path, entry)).length };
11093
11140
  });
11141
+ const editStaged = fn("Cli.editStaged")(function* (request) {
11142
+ const store = yield* Store;
11143
+ const worktree = yield* findBranch(request.repo, request.branch);
11144
+ const current = yield* store.state(worktree.path);
11145
+ const found = current.pending.find((entry) => entry.id === request.id);
11146
+ if (found === void 0) return yield* new UnknownComment({ id: request.id });
11147
+ const pending = yield* store.restage(worktree.path, {
11148
+ ...found,
11149
+ body: request.body
11150
+ });
11151
+ return { pending: getOrElse(pending, () => current.pending).length };
11152
+ });
11153
+ const dropStaged = fn("Cli.dropStaged")(function* (repo, branch, id) {
11154
+ const store = yield* Store;
11155
+ const worktree = yield* findBranch(repo, branch);
11156
+ const pending = yield* store.unstage(worktree.path, id);
11157
+ if (isNone(pending)) return yield* new UnknownComment({ id });
11158
+ return { pending: pending.value.length };
11159
+ });
11094
11160
  const listPending = fn("Cli.listPending")(function* (repo, branch) {
11095
11161
  const store = yield* Store;
11096
11162
  const worktree = yield* findBranch(repo, branch);
11097
11163
  return (yield* store.state(worktree.path)).pending.map((entry) => ({
11164
+ id: entry.id,
11098
11165
  file: entry.anchor.path,
11099
11166
  side: entry.anchor.side,
11100
11167
  start: entry.anchor.start,
@@ -11102,16 +11169,27 @@ const listPending = fn("Cli.listPending")(function* (repo, branch) {
11102
11169
  body: entry.body
11103
11170
  }));
11104
11171
  });
11105
- const listSent = fn("Cli.listSent")(function* (repo, branch) {
11106
- const store = yield* Store;
11107
- const worktree = yield* findBranch(repo, branch);
11108
- return flatten(yield* store.inbox(worktree.path)).map((comment) => ({
11172
+ const bodyOf = (entry) => entry.body;
11173
+ const sentOf = (comment, spoken, settled, head) => {
11174
+ const mine = spoken.filter((entry) => entry.comment === comment.id);
11175
+ return {
11109
11176
  file: comment.file,
11110
11177
  side: comment.side,
11111
11178
  start: comment.start,
11112
11179
  end: comment.end,
11113
- body: comment.body
11114
- }));
11180
+ body: comment.body,
11181
+ settled: Object.hasOwn(settled, comment.id),
11182
+ stale: comment.head !== head,
11183
+ asks: mine.at(-1)?.asks === true,
11184
+ answers: mine.map(bodyOf)
11185
+ };
11186
+ };
11187
+ const listSent = fn("Cli.listSent")(function* (repo, branch) {
11188
+ const store = yield* Store;
11189
+ const worktree = yield* findBranch(repo, branch);
11190
+ const spoken = yield* store.answers(worktree.path);
11191
+ const current = yield* store.state(worktree.path);
11192
+ return flatten(yield* store.inbox(worktree.path)).map((comment) => sentOf(comment, spoken, current.settled, worktree.head));
11115
11193
  });
11116
11194
  const submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
11117
11195
  const store = yield* Store;
@@ -11179,6 +11257,7 @@ const listPatches = fn("Cli.listPatches")(function* (repo, branch, context = CON
11179
11257
  return parsePatches(yield* git.diff(worktree, context));
11180
11258
  });
11181
11259
  const flatten = (batches) => batches.flatMap((batch) => batch.comments.map((comment) => ({
11260
+ id: comment.id,
11182
11261
  at: batch.at,
11183
11262
  head: batch.head,
11184
11263
  file: comment.anchor.path,
@@ -11472,6 +11551,76 @@ const listLayers = fn("Cli.listLayers")(function* (repo, branch) {
11472
11551
  };
11473
11552
  });
11474
11553
  //#endregion
11554
+ //#region src/cli/threads.ts
11555
+ const stateOf$1 = (answers, isSettled) => {
11556
+ if (isSettled) return "done";
11557
+ const last = answers.at(-1);
11558
+ if (last === void 0) return "submitted";
11559
+ return last.asks ? "question" : "answered";
11560
+ };
11561
+ const spoken$1 = (entry) => ({
11562
+ body: entry.body,
11563
+ at: entry.at,
11564
+ asks: entry.asks
11565
+ });
11566
+ const threadOf = (comment, batch, reading) => {
11567
+ const mine = reading.answers.filter((entry) => entry.comment === comment.id);
11568
+ return {
11569
+ id: comment.id,
11570
+ file: comment.anchor.path,
11571
+ side: comment.anchor.side,
11572
+ start: comment.anchor.start,
11573
+ end: comment.anchor.end,
11574
+ body: comment.body,
11575
+ state: stateOf$1(mine, Object.hasOwn(reading.settled, comment.id)),
11576
+ stale: batch.head !== reading.head,
11577
+ answers: mine.map(spoken$1)
11578
+ };
11579
+ };
11580
+ const threadsIn = (batches, reading) => batches.flatMap((batch) => batch.comments.map((comment) => threadOf(comment, batch, reading)));
11581
+ const idsIn = (batches) => batches.flatMap((batch) => batch.comments.map((comment) => comment.id));
11582
+ const isKnown = fn("Cli.isKnown")(function* (worktreePath, id) {
11583
+ const store = yield* Store;
11584
+ return idsIn(yield* store.inbox(worktreePath)).includes(id);
11585
+ });
11586
+ const listThreads = fn("Cli.listThreads")(function* (repo, branch) {
11587
+ const store = yield* Store;
11588
+ const worktree = yield* findBranch(repo, branch);
11589
+ const current = yield* store.state(worktree.path);
11590
+ return threadsIn(yield* store.inbox(worktree.path), {
11591
+ answers: yield* store.answers(worktree.path),
11592
+ settled: current.settled,
11593
+ head: worktree.head
11594
+ });
11595
+ });
11596
+ const answerComment = fn("Cli.answerComment")(function* (request) {
11597
+ const store = yield* Store;
11598
+ const worktree = yield* worktreeAt(request.worktree);
11599
+ if (!(yield* isKnown(worktree.path, request.id))) return yield* new UnknownComment({ id: request.id });
11600
+ yield* store.answer(worktree.path, {
11601
+ comment: request.id,
11602
+ body: request.body,
11603
+ head: worktree.head,
11604
+ asks: request.asks,
11605
+ at: request.at
11606
+ });
11607
+ return { answered: (yield* store.answers(worktree.path)).filter((entry) => entry.comment === request.id).length };
11608
+ });
11609
+ const settleThread = fn("Cli.settleThread")(function* (repo, branch, id, at) {
11610
+ const store = yield* Store;
11611
+ const worktree = yield* findBranch(repo, branch);
11612
+ if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
11613
+ const current = yield* store.state(worktree.path);
11614
+ yield* store.saveState(worktree.path, {
11615
+ ...current,
11616
+ settled: {
11617
+ ...current.settled,
11618
+ [id]: at
11619
+ }
11620
+ });
11621
+ return { settled: id };
11622
+ });
11623
+ //#endregion
11475
11624
  //#region src/cli/parse.ts
11476
11625
  const optionsFrom = (argv) => {
11477
11626
  const options = {};
@@ -11596,6 +11745,46 @@ const catalog = [
11596
11745
  dataKey: "pending",
11597
11746
  example: "adiff comment stage --repo . --branch cdr-1 --file src/api.ts --start 4 --end 4 --body \"why\""
11598
11747
  },
11748
+ {
11749
+ name: "comment edit",
11750
+ about: "Reword a staged comment. It keeps its id and the lines it was written against",
11751
+ safety: "write",
11752
+ options: [
11753
+ repo,
11754
+ branch,
11755
+ {
11756
+ name: "id",
11757
+ required: true,
11758
+ value: "id",
11759
+ about: "The staged comment, as `review progress` reported it"
11760
+ },
11761
+ {
11762
+ name: "body",
11763
+ required: true,
11764
+ value: "text",
11765
+ about: "What it should say instead"
11766
+ }
11767
+ ],
11768
+ dataKey: "pending",
11769
+ example: "adiff comment edit --repo . --branch add-teammate-invitations --id c1 --body \"why is this unused\""
11770
+ },
11771
+ {
11772
+ name: "comment drop",
11773
+ about: "Take a staged comment out of the review before it is sent",
11774
+ safety: "write",
11775
+ options: [
11776
+ repo,
11777
+ branch,
11778
+ {
11779
+ name: "id",
11780
+ required: true,
11781
+ value: "id",
11782
+ about: "The staged comment to withdraw"
11783
+ }
11784
+ ],
11785
+ dataKey: "pending",
11786
+ example: "adiff comment drop --repo . --branch add-teammate-invitations --id c1"
11787
+ },
11599
11788
  {
11600
11789
  name: "comment take",
11601
11790
  about: "Collect the comments this worktree has not been handed yet. Exactly-once",
@@ -11614,6 +11803,64 @@ const catalog = [
11614
11803
  dataKey: "comments",
11615
11804
  example: "adiff comment take --worktree . --wait 300"
11616
11805
  },
11806
+ {
11807
+ name: "comment answer",
11808
+ about: "Say what was done about a comment, or ask the reviewer something back",
11809
+ safety: "write",
11810
+ options: [
11811
+ {
11812
+ name: "worktree",
11813
+ required: true,
11814
+ value: "path",
11815
+ about: "The worktree the comment was written against"
11816
+ },
11817
+ {
11818
+ name: "id",
11819
+ required: true,
11820
+ value: "id",
11821
+ about: "The comment being answered, as `comment take` reported it"
11822
+ },
11823
+ {
11824
+ name: "body",
11825
+ required: true,
11826
+ value: "text",
11827
+ about: "What was done, or what is being asked"
11828
+ },
11829
+ {
11830
+ name: "asks",
11831
+ required: false,
11832
+ value: "flag",
11833
+ about: "The answer needs a reply before the work continues"
11834
+ }
11835
+ ],
11836
+ dataKey: "answered",
11837
+ example: "adiff comment answer --worktree . --id c1 --body \"dropped it, and the import with it\""
11838
+ },
11839
+ {
11840
+ name: "comment threads",
11841
+ about: "Every comment on a branch with its answers and whether it is settled",
11842
+ safety: "read",
11843
+ options: [repo, branch],
11844
+ dataKey: "threads",
11845
+ example: "adiff comment threads --repo . --branch add-teammate-invitations"
11846
+ },
11847
+ {
11848
+ name: "comment resolve",
11849
+ about: "Mark a comment settled. Only the reviewer who raised it can",
11850
+ safety: "write",
11851
+ options: [
11852
+ repo,
11853
+ branch,
11854
+ {
11855
+ name: "id",
11856
+ required: true,
11857
+ value: "id",
11858
+ about: "The comment to settle"
11859
+ }
11860
+ ],
11861
+ dataKey: "settled",
11862
+ example: "adiff comment resolve --repo . --branch add-teammate-invitations --id c1"
11863
+ },
11617
11864
  {
11618
11865
  name: "file vouch",
11619
11866
  about: "Toggle a file as reviewed. Lapses on its own when the file changes",
@@ -11738,6 +11985,11 @@ const ADVICE = {
11738
11985
  suggestion: "No layers has been written for this worktree. Write one with `adiff layers set`.",
11739
11986
  retriable: false
11740
11987
  },
11988
+ UnknownComment: {
11989
+ exit: 3,
11990
+ suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment threads` reports every id on a branch.",
11991
+ retriable: false
11992
+ },
11741
11993
  UnselectableRange: {
11742
11994
  exit: 2,
11743
11995
  suggestion: "Those lines are not in the diff. Check --side: new is the working tree, old is the version being replaced.",
@@ -12153,6 +12405,7 @@ const initialState = (branches) => ({
12153
12405
  pending: [],
12154
12406
  sent: [],
12155
12407
  pendingIndex: 0,
12408
+ editing: void 0,
12156
12409
  viewport: 20,
12157
12410
  context: 3,
12158
12411
  top: 0,
@@ -12326,7 +12579,13 @@ const lineOf = (row) => match$2(row.newLine, {
12326
12579
  onNone: () => "-",
12327
12580
  onSome: (line) => String(line)
12328
12581
  });
12582
+ const editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
12329
12583
  const composeTarget = (state) => {
12584
+ const edited = editedComment(state);
12585
+ if (edited !== void 0) {
12586
+ const span = edited.start === edited.end ? `${edited.start}` : `${edited.start}-${edited.end}`;
12587
+ return `Comment on ${edited.file}:${span}`;
12588
+ }
12330
12589
  const patch = selectedPatch(state);
12331
12590
  if (patch === void 0) return "";
12332
12591
  const [from, to] = selectionRange(state);
@@ -12703,6 +12962,22 @@ const commands = [
12703
12962
  hint: "send",
12704
12963
  listed: false
12705
12964
  }),
12965
+ command({
12966
+ action: "pending.edit",
12967
+ title: "Reword this comment",
12968
+ category: "Review",
12969
+ keys: ["e"],
12970
+ screens: ["pending"],
12971
+ hint: "reword"
12972
+ }),
12973
+ command({
12974
+ action: "pending.drop",
12975
+ title: "Withdraw this comment",
12976
+ category: "Review",
12977
+ keys: ["X"],
12978
+ screens: ["pending"],
12979
+ hint: "withdraw"
12980
+ }),
12706
12981
  command({
12707
12982
  action: "pending.next",
12708
12983
  title: "Next staged comment",
@@ -13026,6 +13301,8 @@ const transitions = {
13026
13301
  "compose.stage": (state) => state,
13027
13302
  "pending.open": (state) => state,
13028
13303
  "pending.submit": (state) => state,
13304
+ "pending.edit": (state) => state,
13305
+ "pending.drop": (state) => state,
13029
13306
  "pending.next": (state) => movePending(state, 1),
13030
13307
  "pending.prev": (state) => movePending(state, -1),
13031
13308
  "compose.newline": (state) => ({
@@ -13200,6 +13477,10 @@ const paletteClosed = (state) => ({
13200
13477
  screen: state.returnTo,
13201
13478
  query: ""
13202
13479
  });
13480
+ const withNoticeHere = (state, notice) => ({
13481
+ ...state,
13482
+ notice
13483
+ });
13203
13484
  const withNotice = (state, notice) => ({
13204
13485
  ...state,
13205
13486
  screen: "review",
@@ -13377,6 +13658,7 @@ const WASH = {
13377
13658
  }
13378
13659
  };
13379
13660
  const NOTE_MIN = 24;
13661
+ const ANSWER_MARK = "↳";
13380
13662
  const OVERSCAN = 2;
13381
13663
  const SIGN_WIDTH = 2;
13382
13664
  const SCROLL_ROWS = 3;
@@ -13606,7 +13888,23 @@ const wrap = (text, room) => {
13606
13888
  }
13607
13889
  return lines;
13608
13890
  };
13609
- const noteLines = (note, room) => [note.sent ? `${marks().sent} sent` : `${marks().staged} staged`, ...note.body.split("\n").flatMap((line) => wrap(line, room))];
13891
+ const headOf = (note) => {
13892
+ const moved = note.stale ? ", the branch moved on" : "";
13893
+ if (note.settled) return `${marks().sent} settled${moved}`;
13894
+ if (note.asks) return `${marks().staged} asked back${moved}`;
13895
+ if (note.answers.length > 0) return `${marks().sent} answered${moved}`;
13896
+ if (note.sent) return `${marks().sent} sent${moved}`;
13897
+ return `${marks().staged} staged`;
13898
+ };
13899
+ const spokenLines = (body, room) => {
13900
+ return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
13901
+ };
13902
+ const answerLines = (note, room) => note.answers.flatMap((body) => spokenLines(body, room));
13903
+ const noteLines = (note, room) => [
13904
+ headOf(note),
13905
+ ...note.body.split("\n").flatMap((line) => wrap(line, room)),
13906
+ ...answerLines(note, room)
13907
+ ];
13610
13908
  const noteRows = (note, row, room) => noteLines(note, room).map((line, index) => ({
13611
13909
  text: `${marks().rule} ${line}`,
13612
13910
  row,
@@ -13975,7 +14273,11 @@ const notesOf = (comments, path, sent) => comments.filter((entry) => entry.file
13975
14273
  side: entry.side,
13976
14274
  line: entry.end,
13977
14275
  body: entry.body,
13978
- sent
14276
+ sent,
14277
+ settled: entry.settled === true,
14278
+ stale: entry.stale === true,
14279
+ asks: entry.asks === true,
14280
+ answers: entry.answers ?? []
13979
14281
  }));
13980
14282
  const notesFor = (state, path) => [...notesOf(state.sent, path, true), ...notesOf(state.pending, path, false)];
13981
14283
  const keptWithin = (chunks, room) => {
@@ -14686,6 +14988,8 @@ var App = class {
14686
14988
  "file.vouch.next": () => this.vouch(true),
14687
14989
  "review.reload": () => this.reloadBranch(),
14688
14990
  "pending.open": () => this.openPending(),
14991
+ "pending.edit": () => this.editStagedComment(),
14992
+ "pending.drop": () => this.dropStagedComment(),
14689
14993
  "pending.submit": () => this.sendReview(),
14690
14994
  "report.open": () => this.commit(reduce(this.measured(), "report.open")),
14691
14995
  back: () => this.goBack(),
@@ -14814,6 +15118,8 @@ var App = class {
14814
15118
  };
14815
15119
  }
14816
15120
  async stage() {
15121
+ const editing = this.state.editing;
15122
+ if (editing !== void 0) return this.restage(editing);
14817
15123
  const request = this.request();
14818
15124
  if (request === void 0) return this.commit(withNotice(this.state, "nothing to stage"));
14819
15125
  await this.run(stageComment(request));
@@ -14822,6 +15128,23 @@ var App = class {
14822
15128
  const next = withPending(this.state, pending, "review");
14823
15129
  this.commit(withNotice(next, `${pending.length} staged`));
14824
15130
  }
15131
+ async restage(id) {
15132
+ const branch = selectedBranch(this.state);
15133
+ if (branch === void 0) return;
15134
+ await this.run(editStaged({
15135
+ repo: this.repo,
15136
+ branch: branch.branch,
15137
+ id,
15138
+ body: this.state.draft
15139
+ }));
15140
+ const pending = await this.run(listPending(this.repo, branch.branch));
15141
+ const next = withPending({
15142
+ ...this.state,
15143
+ editing: void 0,
15144
+ draft: ""
15145
+ }, pending, "pending");
15146
+ this.commit(withNoticeHere(next, "reworded"));
15147
+ }
14825
15148
  loadSent(branch) {
14826
15149
  return this.run(listSent(this.repo, branch));
14827
15150
  }
@@ -14857,6 +15180,30 @@ var App = class {
14857
15180
  if (pending.length === 0) return this.commit(withNotice(this.state, "nothing staged"));
14858
15181
  this.commit(withPending(this.state, pending, "pending"));
14859
15182
  }
15183
+ editStagedComment() {
15184
+ const entry = this.state.pending[this.state.pendingIndex];
15185
+ if (entry?.id === void 0) return;
15186
+ this.commit({
15187
+ ...this.state,
15188
+ screen: "compose",
15189
+ draft: entry.body,
15190
+ editing: entry.id
15191
+ });
15192
+ }
15193
+ async dropStagedComment() {
15194
+ const branch = selectedBranch(this.state);
15195
+ const entry = this.state.pending[this.state.pendingIndex];
15196
+ if (branch === void 0 || entry?.id === void 0) return;
15197
+ await this.run(dropStaged(this.repo, branch.branch, entry.id));
15198
+ const pending = await this.run(listPending(this.repo, branch.branch));
15199
+ const kept = withPending(this.state, pending, pending.length === 0 ? "review" : "pending");
15200
+ const at = Math.min(this.state.pendingIndex, Math.max(0, pending.length - 1));
15201
+ const said = pending.length === 0 ? "nothing staged" : `withdrawn — ${pending.length} left`;
15202
+ this.commit(withNoticeHere({
15203
+ ...kept,
15204
+ pendingIndex: at
15205
+ }, said));
15206
+ }
14860
15207
  async sendReview() {
14861
15208
  const branch = selectedBranch(this.state);
14862
15209
  if (branch === void 0) return;
@@ -14970,6 +15317,24 @@ const commentTake = fn("Main.commentTake")(function* (options) {
14970
15317
  const comments = wait > 0 ? yield* awaitComments(worktree, Date.now() + wait * WAIT_UNIT) : yield* takeComments(worktree);
14971
15318
  yield* answer(options, { comments });
14972
15319
  });
15320
+ const commentAnswer = fn("Main.commentAnswer")(function* (options) {
15321
+ const report = yield* answerComment({
15322
+ worktree: yield* required(options, "worktree"),
15323
+ id: yield* required(options, "id"),
15324
+ body: yield* required(options, "body"),
15325
+ asks: options["asks"] !== void 0,
15326
+ at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
15327
+ });
15328
+ yield* answer(options, { answered: report.answered });
15329
+ });
15330
+ const commentThreads = fn("Main.commentThreads")(function* (options) {
15331
+ const threads = yield* listThreads(yield* required(options, "repo"), yield* required(options, "branch"));
15332
+ yield* answer(options, { threads });
15333
+ });
15334
+ const commentResolve = fn("Main.commentResolve")(function* (options) {
15335
+ const report = yield* settleThread(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
15336
+ yield* answer(options, { settled: report.settled });
15337
+ });
14973
15338
  const commentStage = fn("Main.commentStage")(function* (options) {
14974
15339
  const report = yield* stageComment({
14975
15340
  repo: yield* required(options, "repo"),
@@ -14984,6 +15349,19 @@ const commentStage = fn("Main.commentStage")(function* (options) {
14984
15349
  });
14985
15350
  yield* answer(options, { pending: report.pending });
14986
15351
  });
15352
+ const commentEdit = fn("Main.commentEdit")(function* (options) {
15353
+ const report = yield* editStaged({
15354
+ repo: yield* required(options, "repo"),
15355
+ branch: yield* required(options, "branch"),
15356
+ id: yield* required(options, "id"),
15357
+ body: yield* required(options, "body")
15358
+ });
15359
+ yield* answer(options, { pending: report.pending });
15360
+ });
15361
+ const commentDrop = fn("Main.commentDrop")(function* (options) {
15362
+ const report = yield* dropStaged(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
15363
+ yield* answer(options, { pending: report.pending });
15364
+ });
14987
15365
  const reviewSubmit = fn("Main.reviewSubmit")(function* (options) {
14988
15366
  const report = yield* submitReview(yield* required(options, "repo"), yield* required(options, "branch"), options["id"] ?? randomUUID(), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14989
15367
  yield* answer(options, { submitted: report.submitted });
@@ -15017,7 +15395,12 @@ const routes = {
15017
15395
  "branch list": branchList,
15018
15396
  "comment add": commentAdd,
15019
15397
  "comment stage": commentStage,
15398
+ "comment edit": commentEdit,
15399
+ "comment drop": commentDrop,
15020
15400
  "comment take": commentTake,
15401
+ "comment answer": commentAnswer,
15402
+ "comment threads": commentThreads,
15403
+ "comment resolve": commentResolve,
15021
15404
  "review submit": reviewSubmit,
15022
15405
  "review progress": reviewStatus,
15023
15406
  "layers set": fn("Main.layersSet")(function* (options) {
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "bin": {
22
22
  "adiff": "./bin/adiff.js"
23
23
  },
24
- "version": "0.1.0-alpha.11",
24
+ "version": "0.1.0-alpha.13",
25
25
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -43,6 +43,33 @@ Re-arm it after each comment you handle, and keep it running while you work. A r
43
43
  their own pace, so comments arrive minutes apart, and the whole point is that they reach you as
44
44
  events rather than by you asking. When you finish a piece of work, say you are still listening.
45
45
 
46
+ ## Answering a comment
47
+
48
+ Say what you did, against the comment you were handed:
49
+
50
+ ```bash
51
+ adiff comment answer --worktree . --id <id> --body "Dropped it, and the import with it."
52
+ ```
53
+
54
+ The id comes from `comment take`. The reviewer sees the answer under their own words the next time
55
+ they read the branch, so this is how they learn a point was addressed rather than ignored.
56
+
57
+ Answer when the change alone does not carry the reasoning: what you did instead of what was asked,
58
+ what you found while doing it, or why the comment does not apply. A comment that asked a question
59
+ deserves an answer even when nothing changed.
60
+
61
+ Add `--asks` when you need the reviewer to decide before you continue:
62
+
63
+ ```bash
64
+ adiff comment answer --worktree . --id <id> --asks --body "Drop it, or keep it and map the error?"
65
+ ```
66
+
67
+ That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
68
+ the work genuinely stops without an answer.
69
+
70
+ Settling a thread is the reviewer's to do, not yours. They raised the point, so they decide it is
71
+ closed.
72
+
46
73
  ## Acting on a comment
47
74
 
48
75
  Read `snippet` before opening the file: the reviewer commented on the diff, and the file may have