@eliya-oss/agent-diff 0.1.0-alpha.40 → 0.1.0-alpha.42

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,21 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.42
4
+
5
+ ### Minor Changes
6
+
7
+ - Renames on the merits, now that nothing depends on the old names: `comment threads` is `comment list`, `comment add` is `comment send`, `review submit` is `review send`, `file vouch` is `file review`, and `--asks` is `--question`. `comment drop` is gone, folded into `comment remove`. Every command that acts on a review now takes either `--worktree`, or `--repo` with `--branch`.
8
+
9
+ ### Patch Changes
10
+
11
+ - `--help` works on every command and every noun, the top-level list is grouped by what you are trying to do, a mistyped command names the one you meant, and a missing option says which command wanted it.
12
+
13
+ ## 0.1.0-alpha.41
14
+
15
+ ### Patch Changes
16
+
17
+ - Build the release binaries with a version of Bun that exists. The workflow asked for 1.4.0, which was never published, so every binary download answered 404. No release since the workflow landed has carried binaries or updated the Homebrew formula.
18
+
3
19
  ## 0.1.0-alpha.40
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -26,7 +26,7 @@ check so nothing is quietly left out of the story.
26
26
  You comment on a line:
27
27
 
28
28
  ```bash
29
- adiff comment add --repo . --branch add-teammate-invitations \
29
+ adiff comment send --repo . --branch add-teammate-invitations \
30
30
  --file src/api/invitations.ts --start 12 --end 13 \
31
31
  --body "Three status checks in a row. One error shape would do."
32
32
  ```
@@ -53,14 +53,17 @@ You see that answer under your own words the next time you read the branch, and
53
53
  there until you settle it with `d`:
54
54
 
55
55
  ```bash
56
- adiff comment threads --repo . --branch add-teammate-invitations
57
- {"ok":true,"threads":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","state":"answered",
56
+ adiff comment list --repo . --branch add-teammate-invitations
57
+ {"ok":true,"comments":[{"id":"1c43cb55-6a09-406d-95ad-f048c43e05f5","state":"answered",
58
58
  "stale":false,"answers":[{"body":"Folded them into one InviteRejected carrying the reason.",
59
59
  "asks":false}]}]}
60
60
  ```
61
61
 
62
- `--asks` on an answer marks the thread as waiting on you, for a decision the agent needs before it
63
- can carry on. Settling is yours alone: the agent that raised the answer cannot close the point.
62
+ `--question` on an answer marks the thread as waiting on you, for a decision the agent needs before
63
+ it can carry on. Settling is yours alone: the agent that raised the answer cannot close the point.
64
+
65
+ Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
66
+ `--branch <name>`, so the same command works from your checkout and from the agent's worktree.
64
67
 
65
68
  A comment is handed over exactly once, so a second `take` returns only what was written since. Add
66
69
  `--wait 300` and it blocks until something arrives, which costs nothing while it waits.
@@ -161,7 +164,7 @@ you quit. `pnpm simulate --probe` runs the whole round trip headless and prints
161
164
 
162
165
  ```
163
166
  branches {"ok":true,"branches":[{"branch":"add-teammate-invitations","files":3,"added":27,"removed":2,"layers":2,...
164
- vouch {"ok":true,"vouched":["src/api/invitations.ts"],"total":3}
167
+ reviewed {"ok":true,"reviewed":["src/api/invitations.ts"],"total":3}
165
168
  agent takes {"ok":true,"comments":[{"id":"a83fc98c-8397-44f5-9c37-731a1cf3cb4c","file":"src/api/invitations.ts",
166
169
  "side":"new","start":12,"end":13,"snippet":" if (res.status === 409) throw new AlreadyInvited(email)...",
167
170
  "body":"Three status checks in a row. One error shape would do."}]}
package/dist/main.js CHANGED
@@ -8019,7 +8019,7 @@ var init_run = __esmMin((() => {
8019
8019
  }));
8020
8020
  //#endregion
8021
8021
  //#region src/service/git/service.ts
8022
- var GREP_CONTEXT, DEFAULT_BRANCH_CANDIDATES, STAT, Git, parseStat, readEntries, baseNames, mergeBases, findDefaultBranch, defaultBranch, mergeBaseOf, toWorktree, splitLines, absent, readText, settled, shape, GitLive;
8022
+ var GREP_CONTEXT, DEFAULT_BRANCH_CANDIDATES, STAT, Git, parseStat, readEntries, baseNames, mergeBases, findDefaultBranch, defaultBranch, mergeBaseOf, toWorktree, splitLines, absent, readText, settled, listWorktrees, readDiff, readStat, readSource, readGrep, shape, GitLive;
8023
8023
  var init_service$2 = __esmMin((() => {
8024
8024
  init_dist();
8025
8025
  init_error$3();
@@ -8112,57 +8112,70 @@ var init_service$2 = __esmMin((() => {
8112
8112
  }).pipe(map(some), catchTag("FileUnreadable", () => absent));
8113
8113
  });
8114
8114
  settled = (path) => promise(() => realpath(path).catch(() => resolve(path)));
8115
+ listWorktrees = fn("Git.worktrees")(function* (repo) {
8116
+ const porcelain = yield* gitOrEmpty(repo, [
8117
+ "worktree",
8118
+ "list",
8119
+ "--porcelain"
8120
+ ]);
8121
+ const base = yield* defaultBranch(repo);
8122
+ const entries = readEntries(porcelain);
8123
+ const opened = yield* settled(repo);
8124
+ const found = [];
8125
+ for (const entry of entries) {
8126
+ const path = yield* settled(entry.path);
8127
+ found.push(yield* toWorktree(entry, base, path === opened));
8128
+ }
8129
+ return found;
8130
+ });
8131
+ readDiff = fn("Git.diff")(function* (worktree, context) {
8132
+ const target = worktree.base.length > 0 ? worktree.base : "HEAD";
8133
+ return yield* gitOrEmpty(worktree.path, [
8134
+ "diff",
8135
+ `-U${context}`,
8136
+ target
8137
+ ]);
8138
+ });
8139
+ readStat = fn("Git.stat")(function* (worktree) {
8140
+ const raw = yield* gitOrEmpty(worktree.path, [
8141
+ "diff",
8142
+ "--shortstat",
8143
+ worktree.base
8144
+ ]);
8145
+ return parseStat(raw);
8146
+ });
8147
+ readSource = fn("Git.source")(function* (worktree, path) {
8148
+ const text = yield* readText(join(worktree.path, path), path);
8149
+ return map$4(text, splitLines);
8150
+ });
8151
+ readGrep = fn("Git.grep")(function* (worktree, term) {
8152
+ return yield* gitOrEmpty(worktree.path, [
8153
+ "grep",
8154
+ "--no-color",
8155
+ "-n",
8156
+ "-I",
8157
+ "-F",
8158
+ "-w",
8159
+ "-C",
8160
+ String(GREP_CONTEXT),
8161
+ "-e",
8162
+ term
8163
+ ]);
8164
+ });
8115
8165
  shape = {
8116
- worktrees: fn("Git.worktrees")(function* (repo) {
8117
- const porcelain = yield* gitOrEmpty(repo, [
8118
- "worktree",
8119
- "list",
8120
- "--porcelain"
8121
- ]);
8122
- const base = yield* defaultBranch(repo);
8123
- const entries = readEntries(porcelain);
8124
- const opened = yield* settled(repo);
8125
- const found = [];
8126
- for (const entry of entries) {
8127
- const path = yield* settled(entry.path);
8128
- found.push(yield* toWorktree(entry, base, path === opened));
8129
- }
8130
- return found;
8131
- }),
8132
- diff: fn("Git.diff")(function* (worktree, context) {
8133
- const target = worktree.base.length > 0 ? worktree.base : "HEAD";
8134
- return yield* gitOrEmpty(worktree.path, [
8135
- "diff",
8136
- `-U${context}`,
8137
- target
8138
- ]);
8139
- }),
8140
- stat: fn("Git.stat")(function* (worktree) {
8141
- const raw = yield* gitOrEmpty(worktree.path, [
8142
- "diff",
8143
- "--shortstat",
8144
- worktree.base
8145
- ]);
8146
- return parseStat(raw);
8166
+ worktrees: listWorktrees,
8167
+ repoOf: fn("Git.repoOf")(function* (worktree) {
8168
+ const trimmed = (yield* gitOrEmpty(worktree, [
8169
+ "rev-parse",
8170
+ "--path-format=absolute",
8171
+ "--git-common-dir"
8172
+ ])).trim();
8173
+ return trimmed.length === 0 ? resolve(worktree) : resolve(trimmed, "..");
8147
8174
  }),
8148
- source: fn("Git.source")(function* (worktree, path) {
8149
- const text = yield* readText(join(worktree.path, path), path);
8150
- return map$4(text, splitLines);
8151
- }),
8152
- grep: fn("Git.grep")(function* (worktree, term) {
8153
- return yield* gitOrEmpty(worktree.path, [
8154
- "grep",
8155
- "--no-color",
8156
- "-n",
8157
- "-I",
8158
- "-F",
8159
- "-w",
8160
- "-C",
8161
- String(GREP_CONTEXT),
8162
- "-e",
8163
- term
8164
- ]);
8165
- })
8175
+ diff: readDiff,
8176
+ stat: readStat,
8177
+ source: readSource,
8178
+ grep: readGrep
8166
8179
  };
8167
8180
  GitLive = succeed$1(Git)(shape);
8168
8181
  }));
@@ -8608,6 +8621,7 @@ var init_service$1 = __esmMin((() => {
8608
8621
  const cursors = cursorOps(state, saveState, inbox);
8609
8622
  return {
8610
8623
  root,
8624
+ branchAt: (worktreePath) => promise(() => headOf$1(worktreePath)),
8611
8625
  submit,
8612
8626
  inbox,
8613
8627
  state,
@@ -8650,7 +8664,7 @@ var init_error$1 = __esmMin((() => {
8650
8664
  }));
8651
8665
  //#endregion
8652
8666
  //#region src/cli/commands.ts
8653
- var CONTEXT, WHOLE_FILE$1, POLL, findBranch, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, anchorRequest, stageComment, editStaged, dropStaged, listPending, bodyOf, sentOf, listSent, submitReview, submitComment, listPatches, flatten, takeComments, awaitComments, saveReport, fileSource, saveWrap;
8667
+ var CONTEXT, WHOLE_FILE$1, POLL, findBranch, patchesOf, findPatch, rowsCovering, waitingOn, listBranches, blobOf, toggleVouch, reviewProgress, anchorRequest, stageComment, editStaged, dropStaged, listPending, bodyOf, sentOf, listSent, submitReview, submitComment, listPatches, flatten, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, saveWrap;
8654
8668
  var init_commands = __esmMin((() => {
8655
8669
  init_dist();
8656
8670
  init_patch();
@@ -8932,6 +8946,17 @@ var init_commands = __esmMin((() => {
8932
8946
  const resolved = yield* promise(() => realpath(worktree));
8933
8947
  return flatten(yield* store.take(resolved));
8934
8948
  });
8949
+ repoOf$1 = fn("Cli.repoOf")(function* (worktree) {
8950
+ return yield* (yield* Git).repoOf(worktree);
8951
+ });
8952
+ worktreeOf$1 = fn("Cli.worktreeOf")(function* (repo, branch) {
8953
+ return (yield* findBranch(repo, branch)).path;
8954
+ });
8955
+ branchAt = fn("Cli.branchAt")(function* (worktree) {
8956
+ const store = yield* Store;
8957
+ const resolved = yield* promise(() => realpath(worktree));
8958
+ return yield* store.branchAt(resolved);
8959
+ });
8935
8960
  awaitComments = (worktree, deadline) => takeComments(worktree).pipe(flatMap((comments) => comments.length > 0 || Date.now() >= deadline ? succeed(comments) : sleep(POLL).pipe(flatMap(() => awaitComments(worktree, deadline)))));
8936
8961
  saveReport = fn("Cli.saveReport")(function* (stamp, text) {
8937
8962
  return yield* (yield* Store).saveReport(stamp, text);
@@ -8970,7 +8995,7 @@ var init_init = __esmMin((() => {
8970
8995
  "When you hand work over, say it is ready and name the command that opens the review:",
8971
8996
  "`adiff review open --repo <repo>`, or `adiff review pane --repo <repo>` to open it alongside.",
8972
8997
  "Publish a reading order with `adiff layers set` only when you are asked for one.",
8973
- "`adiff describe` lists the rest.",
8998
+ "`adiff --help` lists the rest, and `adiff describe` answers the same as JSON.",
8974
8999
  END
8975
9000
  ].join("\n");
8976
9001
  IMPORT = [
@@ -9174,7 +9199,7 @@ var init_pane = __esmMin((() => {
9174
9199
  init_commands();
9175
9200
  init_init();
9176
9201
  init_pane();
9177
- var version$1 = "0.1.0-alpha.40";
9202
+ var version$1 = "0.1.0-alpha.42";
9178
9203
  //#endregion
9179
9204
  //#region src/cli/upgrade.ts
9180
9205
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, ran, here, statusOf$1, ranLine, failedLine, noteFor, offerFor, restOf, sayUpgrade, upgradeAdiff;
@@ -9314,12 +9339,12 @@ var init_upgrade$1 = __esmMin((() => {
9314
9339
  }));
9315
9340
  //#endregion
9316
9341
  //#region src/cli/search.ts
9317
- var HIT, NEAR, rowOf, readRows, near, byChangedFirst, searchBranch;
9342
+ var HIT, NEAR$1, rowOf, readRows, near, byChangedFirst, searchBranch;
9318
9343
  var init_search = __esmMin((() => {
9319
9344
  init_dist();
9320
9345
  init_git();
9321
9346
  HIT = /^(.+?):(\d+):(.*)$/;
9322
- NEAR = /^(.+?)-(\d+)-(.*)$/;
9347
+ NEAR$1 = /^(.+?)-(\d+)-(.*)$/;
9323
9348
  rowOf = (line) => {
9324
9349
  const hit = HIT.exec(line);
9325
9350
  if (hit !== null) return {
@@ -9328,7 +9353,7 @@ var init_search = __esmMin((() => {
9328
9353
  text: hit[3] ?? "",
9329
9354
  hit: true
9330
9355
  };
9331
- const near = NEAR.exec(line);
9356
+ const near = NEAR$1.exec(line);
9332
9357
  if (near === null) return void 0;
9333
9358
  return {
9334
9359
  path: near[1] ?? "",
@@ -9684,7 +9709,7 @@ var init_layers = __esmMin((() => {
9684
9709
  }));
9685
9710
  //#endregion
9686
9711
  //#region src/cli/threads.ts
9687
- var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread, removeComment, without, restoreComment;
9712
+ var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, stagedOf, listThreads, answerComment, settleThread, removeComment, without, restoreComment;
9688
9713
  var init_threads = __esmMin((() => {
9689
9714
  init_dist();
9690
9715
  init_store();
@@ -9695,7 +9720,7 @@ var init_threads = __esmMin((() => {
9695
9720
  if (isRemoved) return "removed";
9696
9721
  if (isSettled) return "done";
9697
9722
  const last = answers.at(-1);
9698
- if (last === void 0) return "submitted";
9723
+ if (last === void 0) return "sent";
9699
9724
  return last.asks ? "question" : "answered";
9700
9725
  };
9701
9726
  spoken$1 = (entry) => ({
@@ -9723,16 +9748,27 @@ var init_threads = __esmMin((() => {
9723
9748
  const store = yield* Store;
9724
9749
  return idsIn(yield* store.inbox(worktreePath)).includes(id);
9725
9750
  });
9751
+ stagedOf = (entry) => ({
9752
+ id: entry.id,
9753
+ file: entry.anchor.path,
9754
+ side: entry.anchor.side,
9755
+ start: entry.anchor.start,
9756
+ end: entry.anchor.end,
9757
+ body: entry.body,
9758
+ state: "staged",
9759
+ stale: false,
9760
+ answers: []
9761
+ });
9726
9762
  listThreads = fn("Cli.listThreads")(function* (repo, branch) {
9727
9763
  const store = yield* Store;
9728
9764
  const worktree = yield* findBranch(repo, branch);
9729
9765
  const current = yield* store.state(worktree.path);
9730
- return threadsIn(yield* store.inbox(worktree.path), {
9766
+ return [...threadsIn(yield* store.inbox(worktree.path), {
9731
9767
  answers: yield* store.answers(worktree.path),
9732
9768
  settled: current.settled,
9733
9769
  removed: current.removed,
9734
9770
  head: worktree.head
9735
- });
9771
+ }), ...current.pending.map(stagedOf)];
9736
9772
  });
9737
9773
  answerComment = fn("Cli.answerComment")(function* (request) {
9738
9774
  const store = yield* Store;
@@ -9764,8 +9800,16 @@ var init_threads = __esmMin((() => {
9764
9800
  removeComment = fn("Cli.removeComment")(function* (repo, branch, id, at) {
9765
9801
  const store = yield* Store;
9766
9802
  const worktree = yield* findBranch(repo, branch);
9767
- if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
9768
9803
  const current = yield* store.state(worktree.path);
9804
+ if (current.pending.some((entry) => entry.id === id)) {
9805
+ const pending = yield* store.unstage(worktree.path, id);
9806
+ if (isNone(pending)) return yield* new UnknownComment({ id });
9807
+ return {
9808
+ removed: id,
9809
+ staged: true
9810
+ };
9811
+ }
9812
+ if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
9769
9813
  yield* store.saveState(worktree.path, {
9770
9814
  ...current,
9771
9815
  removed: {
@@ -9773,7 +9817,10 @@ var init_threads = __esmMin((() => {
9773
9817
  [id]: at
9774
9818
  }
9775
9819
  });
9776
- return { removed: id };
9820
+ return {
9821
+ removed: id,
9822
+ staged: false
9823
+ };
9777
9824
  });
9778
9825
  without = (entries, id) => Object.fromEntries(Object.entries(entries).filter(([key]) => key !== id));
9779
9826
  restoreComment = fn("Cli.restoreComment")(function* (repo, branch, id) {
@@ -9819,19 +9866,36 @@ var init_parse = __esmMin((() => {
9819
9866
  }));
9820
9867
  //#endregion
9821
9868
  //#region src/cli/catalog.ts
9822
- var repo, branch, file, catalog, commandNames, findCommand;
9869
+ var worktreeOf, repoOf, branchOf, addressing, repo, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
9823
9870
  var init_catalog = __esmMin((() => {
9824
- repo = {
9871
+ worktreeOf = {
9872
+ name: "worktree",
9873
+ required: false,
9874
+ value: "path",
9875
+ about: "The worktree under review. Give this, or --repo with --branch"
9876
+ };
9877
+ repoOf = {
9825
9878
  name: "repo",
9826
- required: true,
9879
+ required: false,
9827
9880
  value: "path",
9828
- about: "Repository whose worktrees are reviewed"
9881
+ about: "Repository the worktree belongs to. Give this with --branch, or give --worktree"
9829
9882
  };
9830
- branch = {
9883
+ branchOf = {
9831
9884
  name: "branch",
9832
- required: true,
9885
+ required: false,
9833
9886
  value: "name",
9834
- about: "Branch to act on, as reported by `branch list`"
9887
+ about: "Branch to act on, as `branch list` reports it. Give this with --repo, or give --worktree"
9888
+ };
9889
+ addressing = [
9890
+ worktreeOf,
9891
+ repoOf,
9892
+ branchOf
9893
+ ];
9894
+ repo = {
9895
+ name: "repo",
9896
+ required: true,
9897
+ value: "path",
9898
+ about: "Repository whose worktrees are reviewed"
9835
9899
  };
9836
9900
  file = {
9837
9901
  name: "file",
@@ -9839,94 +9903,107 @@ var init_catalog = __esmMin((() => {
9839
9903
  value: "path",
9840
9904
  about: "File path as it appears in the diff"
9841
9905
  };
9906
+ range = [
9907
+ file,
9908
+ {
9909
+ name: "start",
9910
+ required: true,
9911
+ value: "line",
9912
+ about: "First line of the range"
9913
+ },
9914
+ {
9915
+ name: "end",
9916
+ required: true,
9917
+ value: "line",
9918
+ about: "Last line of the range"
9919
+ },
9920
+ {
9921
+ name: "body",
9922
+ required: true,
9923
+ value: "text",
9924
+ about: "What to tell the agent"
9925
+ },
9926
+ {
9927
+ name: "side",
9928
+ required: false,
9929
+ value: "new|old",
9930
+ about: "Which version the lines are on. Defaults to new"
9931
+ }
9932
+ ];
9933
+ READ_A_BRANCH = "Read a branch";
9934
+ WRITE_COMMENTS = "Write comments";
9935
+ ANSWER_COMMENTS = "Answer comments, in the worktree";
9936
+ FOLLOW_UP = "Follow up";
9937
+ SET_UP = "Set up";
9842
9938
  catalog = [
9843
9939
  {
9844
9940
  name: "branch list",
9845
9941
  about: "Branches with changes against their merge base, and how large each is",
9942
+ group: READ_A_BRANCH,
9943
+ addresses: "repo",
9846
9944
  safety: "read",
9847
9945
  options: [repo],
9848
9946
  dataKey: "branches",
9849
9947
  example: "adiff branch list --repo . --fields branch,files"
9850
9948
  },
9851
9949
  {
9852
- name: "comment add",
9853
- about: "File a comment against a line range, for the agent in that worktree",
9950
+ name: "review open",
9951
+ about: "Open the review terminal. The only command that does not answer in JSON",
9952
+ group: READ_A_BRANCH,
9953
+ addresses: "repo",
9954
+ safety: "read",
9955
+ options: [repo],
9956
+ dataKey: "",
9957
+ example: "adiff review open --repo ."
9958
+ },
9959
+ {
9960
+ name: "review pane",
9961
+ about: "Open the review beside the conversation, in whichever multiplexer is running. Answers with the command when none is",
9962
+ group: READ_A_BRANCH,
9963
+ addresses: "repo",
9964
+ safety: "read",
9965
+ options: [repo],
9966
+ dataKey: "pane",
9967
+ example: "adiff review pane --repo ."
9968
+ },
9969
+ {
9970
+ name: "file review",
9971
+ about: "Toggle a file as reviewed. Lapses on its own when the file changes",
9972
+ group: READ_A_BRANCH,
9973
+ addresses: "review",
9854
9974
  safety: "write",
9855
- options: [
9856
- repo,
9857
- branch,
9858
- file,
9859
- {
9860
- name: "start",
9861
- required: true,
9862
- value: "line",
9863
- about: "First line of the range"
9864
- },
9865
- {
9866
- name: "end",
9867
- required: true,
9868
- value: "line",
9869
- about: "Last line of the range"
9870
- },
9871
- {
9872
- name: "body",
9873
- required: true,
9874
- value: "text",
9875
- about: "What to tell the agent"
9876
- },
9877
- {
9878
- name: "side",
9879
- required: false,
9880
- value: "new|old",
9881
- about: "Which version the lines are on. Defaults to new"
9882
- }
9883
- ],
9884
- dataKey: "batch",
9885
- example: "adiff comment add --repo . --branch cdr-1 --file src/api.ts --start 4 --end 5 --body \"why\""
9975
+ options: [...addressing, file],
9976
+ dataKey: "reviewed",
9977
+ example: "adiff file review --worktree . --file src/api.ts"
9978
+ },
9979
+ {
9980
+ name: "review progress",
9981
+ about: "Which files of a review are marked reviewed, and how many there are",
9982
+ group: READ_A_BRANCH,
9983
+ addresses: "review",
9984
+ safety: "read",
9985
+ options: [...addressing],
9986
+ dataKey: "reviewed",
9987
+ example: "adiff review progress --repo . --branch cdr-1"
9886
9988
  },
9887
9989
  {
9888
9990
  name: "comment stage",
9889
- about: "Add a comment to the review without sending it yet",
9991
+ about: "Put a comment in the review, to go out when `review send` sends it",
9992
+ group: WRITE_COMMENTS,
9993
+ addresses: "review",
9890
9994
  safety: "write",
9891
- options: [
9892
- repo,
9893
- branch,
9894
- file,
9895
- {
9896
- name: "start",
9897
- required: true,
9898
- value: "line",
9899
- about: "First line of the range"
9900
- },
9901
- {
9902
- name: "end",
9903
- required: true,
9904
- value: "line",
9905
- about: "Last line of the range"
9906
- },
9907
- {
9908
- name: "body",
9909
- required: true,
9910
- value: "text",
9911
- about: "What to tell the agent"
9912
- },
9913
- {
9914
- name: "side",
9915
- required: false,
9916
- value: "new|old",
9917
- about: "Which version the lines are on. Defaults to new"
9918
- }
9919
- ],
9995
+ options: [...addressing, ...range],
9920
9996
  dataKey: "pending",
9921
9997
  example: "adiff comment stage --repo . --branch cdr-1 --file src/api.ts --start 4 --end 4 --body \"why\""
9922
9998
  },
9923
9999
  {
9924
10000
  name: "comment edit",
9925
10001
  about: "Reword a staged comment. It keeps its id and the lines it was written against",
10002
+ group: WRITE_COMMENTS,
10003
+ addresses: "review",
9926
10004
  safety: "write",
9927
10005
  options: [
9928
- repo,
9929
- branch,
10006
+ ...addressing,
9930
10007
  {
9931
10008
  name: "id",
9932
10009
  required: true,
@@ -9941,35 +10018,35 @@ var init_catalog = __esmMin((() => {
9941
10018
  }
9942
10019
  ],
9943
10020
  dataKey: "pending",
9944
- example: "adiff comment edit --repo . --branch add-teammate-invitations --id c1 --body \"why is this unused\""
10021
+ example: "adiff comment edit --repo . --branch cdr-1 --id c1 --body \"why is this unused\""
9945
10022
  },
9946
10023
  {
9947
- name: "comment drop",
9948
- about: "Take a staged comment out of the review before it is sent",
10024
+ name: "review send",
10025
+ about: "Send the staged comments as one review, so the agent wakes once",
10026
+ group: WRITE_COMMENTS,
10027
+ addresses: "review",
9949
10028
  safety: "write",
9950
- options: [
9951
- repo,
9952
- branch,
9953
- {
9954
- name: "id",
9955
- required: true,
9956
- value: "id",
9957
- about: "The staged comment to withdraw"
9958
- }
9959
- ],
9960
- dataKey: "pending",
9961
- example: "adiff comment drop --repo . --branch add-teammate-invitations --id c1"
10029
+ options: [...addressing],
10030
+ dataKey: "sent",
10031
+ example: "adiff review send --repo . --branch cdr-1"
10032
+ },
10033
+ {
10034
+ name: "comment send",
10035
+ about: "Send one comment against a line range now, without staging it first",
10036
+ group: WRITE_COMMENTS,
10037
+ addresses: "review",
10038
+ safety: "write",
10039
+ options: [...addressing, ...range],
10040
+ dataKey: "batch",
10041
+ example: "adiff comment send --repo . --branch cdr-1 --file src/api.ts --start 4 --end 5 --body \"why\""
9962
10042
  },
9963
10043
  {
9964
10044
  name: "comment take",
9965
- about: "Collect the comments this worktree has not been handed yet. Exactly-once",
10045
+ about: "Collect the comments this review has not handed over yet. Exactly-once",
10046
+ group: ANSWER_COMMENTS,
10047
+ addresses: "review",
9966
10048
  safety: "write",
9967
- options: [{
9968
- name: "worktree",
9969
- required: true,
9970
- value: "path",
9971
- about: "The worktree to collect for"
9972
- }, {
10049
+ options: [...addressing, {
9973
10050
  name: "wait",
9974
10051
  required: false,
9975
10052
  value: "seconds",
@@ -9981,14 +10058,11 @@ var init_catalog = __esmMin((() => {
9981
10058
  {
9982
10059
  name: "comment answer",
9983
10060
  about: "Say what was done about a comment, or ask the reviewer something back",
10061
+ group: ANSWER_COMMENTS,
10062
+ addresses: "review",
9984
10063
  safety: "write",
9985
10064
  options: [
9986
- {
9987
- name: "worktree",
9988
- required: true,
9989
- value: "path",
9990
- about: "The worktree the comment was written against"
9991
- },
10065
+ ...addressing,
9992
10066
  {
9993
10067
  name: "id",
9994
10068
  required: true,
@@ -10002,112 +10076,22 @@ var init_catalog = __esmMin((() => {
10002
10076
  about: "What was done, or what is being asked"
10003
10077
  },
10004
10078
  {
10005
- name: "asks",
10079
+ name: "question",
10006
10080
  required: false,
10007
10081
  value: "flag",
10008
- about: "The answer needs a reply before the work continues"
10082
+ about: "The answer is a question, and the work waits for a reply"
10009
10083
  }
10010
10084
  ],
10011
10085
  dataKey: "answered",
10012
10086
  example: "adiff comment answer --worktree . --id c1 --body \"dropped it, and the import with it\""
10013
10087
  },
10014
- {
10015
- name: "comment threads",
10016
- about: "Every comment on a branch with its answers and whether it is settled",
10017
- safety: "read",
10018
- options: [repo, branch],
10019
- dataKey: "threads",
10020
- example: "adiff comment threads --repo . --branch add-teammate-invitations"
10021
- },
10022
- {
10023
- name: "comment resolve",
10024
- about: "Mark a comment settled. Only the reviewer who raised it can",
10025
- safety: "write",
10026
- options: [
10027
- repo,
10028
- branch,
10029
- {
10030
- name: "id",
10031
- required: true,
10032
- value: "id",
10033
- about: "The comment to settle"
10034
- }
10035
- ],
10036
- dataKey: "settled",
10037
- example: "adiff comment resolve --repo . --branch add-teammate-invitations --id c1"
10038
- },
10039
- {
10040
- name: "comment remove",
10041
- about: "Take a comment out of the review. It stays in the record as removed",
10042
- safety: "write",
10043
- options: [
10044
- repo,
10045
- branch,
10046
- {
10047
- name: "id",
10048
- required: true,
10049
- value: "id",
10050
- about: "The comment to remove"
10051
- }
10052
- ],
10053
- dataKey: "removed",
10054
- example: "adiff comment remove --repo . --branch add-teammate-invitations --id c1"
10055
- },
10056
- {
10057
- name: "comment restore",
10058
- about: "Put a removed comment back into the review",
10059
- safety: "write",
10060
- options: [
10061
- repo,
10062
- branch,
10063
- {
10064
- name: "id",
10065
- required: true,
10066
- value: "id",
10067
- about: "The comment to restore"
10068
- }
10069
- ],
10070
- dataKey: "restored",
10071
- example: "adiff comment restore --repo . --branch add-teammate-invitations --id c1"
10072
- },
10073
- {
10074
- name: "file vouch",
10075
- about: "Toggle a file as reviewed. Lapses on its own when the file changes",
10076
- safety: "write",
10077
- options: [
10078
- repo,
10079
- branch,
10080
- file
10081
- ],
10082
- dataKey: "vouched",
10083
- example: "adiff file vouch --repo . --branch cdr-1 --file src/api.ts"
10084
- },
10085
- {
10086
- name: "review submit",
10087
- about: "Send every staged comment as one review, so the agent wakes once",
10088
- safety: "write",
10089
- options: [repo, branch],
10090
- dataKey: "submitted",
10091
- example: "adiff review submit --repo . --branch cdr-1"
10092
- },
10093
- {
10094
- name: "review progress",
10095
- about: "Which files of a branch are still vouched, and how many there are",
10096
- safety: "read",
10097
- options: [repo, branch],
10098
- dataKey: "vouched",
10099
- example: "adiff review progress --repo . --branch cdr-1"
10100
- },
10101
10088
  {
10102
10089
  name: "layers set",
10103
- about: "Write the reading order for this worktree's diff: ordered layers over spans of files",
10090
+ about: "Write the reading order for this review's diff: ordered layers over spans of files",
10091
+ group: ANSWER_COMMENTS,
10092
+ addresses: "review",
10104
10093
  safety: "write",
10105
- options: [{
10106
- name: "worktree",
10107
- required: true,
10108
- value: "path",
10109
- about: "The worktree the layers is about"
10110
- }, {
10094
+ options: [...addressing, {
10111
10095
  name: "json",
10112
10096
  required: true,
10113
10097
  value: "file|-",
@@ -10118,36 +10102,74 @@ var init_catalog = __esmMin((() => {
10118
10102
  },
10119
10103
  {
10120
10104
  name: "layers show",
10121
- about: "The layers of a worktree, with the hunks no layer claims",
10105
+ about: "The layers of a review, with the hunks no layer claims",
10106
+ group: ANSWER_COMMENTS,
10107
+ addresses: "review",
10122
10108
  safety: "read",
10123
- options: [{
10124
- name: "worktree",
10125
- required: true,
10126
- value: "path",
10127
- about: "The worktree to read"
10128
- }],
10109
+ options: [...addressing],
10129
10110
  dataKey: "layers",
10130
10111
  example: "adiff layers show --worktree . --fields layers,uncovered"
10131
10112
  },
10132
10113
  {
10133
- name: "review open",
10134
- about: "Open the review terminal. The only command that does not answer in JSON",
10114
+ name: "comment list",
10115
+ about: "Every comment on a review, with its answers and whether it is settled",
10116
+ group: FOLLOW_UP,
10117
+ addresses: "review",
10135
10118
  safety: "read",
10136
- options: [repo],
10137
- dataKey: "",
10138
- example: "adiff review open --repo ."
10119
+ options: [...addressing],
10120
+ dataKey: "comments",
10121
+ example: "adiff comment list --worktree . --fields id,body,settled"
10139
10122
  },
10140
10123
  {
10141
- name: "review pane",
10142
- about: "Open the review beside the conversation, in whichever multiplexer is running. Answers with the command when none is",
10143
- safety: "read",
10144
- options: [repo],
10145
- dataKey: "pane",
10146
- example: "adiff review pane --repo ."
10124
+ name: "comment resolve",
10125
+ about: "Mark a comment settled. Only the reviewer who raised it can",
10126
+ group: FOLLOW_UP,
10127
+ addresses: "review",
10128
+ safety: "write",
10129
+ options: [...addressing, {
10130
+ name: "id",
10131
+ required: true,
10132
+ value: "id",
10133
+ about: "The comment to settle"
10134
+ }],
10135
+ dataKey: "settled",
10136
+ example: "adiff comment resolve --repo . --branch cdr-1 --id c1"
10137
+ },
10138
+ {
10139
+ name: "comment remove",
10140
+ about: "Take a comment out of the review, whether it was staged or already sent",
10141
+ group: FOLLOW_UP,
10142
+ addresses: "review",
10143
+ safety: "write",
10144
+ options: [...addressing, {
10145
+ name: "id",
10146
+ required: true,
10147
+ value: "id",
10148
+ about: "The comment to withdraw"
10149
+ }],
10150
+ dataKey: "removed",
10151
+ example: "adiff comment remove --repo . --branch cdr-1 --id c1"
10152
+ },
10153
+ {
10154
+ name: "comment restore",
10155
+ about: "Put a removed comment back into the review",
10156
+ group: FOLLOW_UP,
10157
+ addresses: "review",
10158
+ safety: "write",
10159
+ options: [...addressing, {
10160
+ name: "id",
10161
+ required: true,
10162
+ value: "id",
10163
+ about: "The comment to restore"
10164
+ }],
10165
+ dataKey: "restored",
10166
+ example: "adiff comment restore --repo . --branch cdr-1 --id c1"
10147
10167
  },
10148
10168
  {
10149
10169
  name: "init",
10150
10170
  about: "Write the review loop into this repository's agent instructions, so an agent finds it unprompted",
10171
+ group: SET_UP,
10172
+ addresses: "repo",
10151
10173
  safety: "write",
10152
10174
  options: [
10153
10175
  {
@@ -10175,6 +10197,8 @@ var init_catalog = __esmMin((() => {
10175
10197
  {
10176
10198
  name: "upgrade",
10177
10199
  about: "Say whether a newer adiff is out and name the one command that installs it. Answers a person in plain text, and a caller in JSON with --json",
10200
+ group: SET_UP,
10201
+ addresses: "none",
10178
10202
  safety: "read",
10179
10203
  options: [{
10180
10204
  name: "run",
@@ -10193,6 +10217,8 @@ var init_catalog = __esmMin((() => {
10193
10217
  {
10194
10218
  name: "describe",
10195
10219
  about: "This catalog, as JSON",
10220
+ group: SET_UP,
10221
+ addresses: "none",
10196
10222
  safety: "read",
10197
10223
  options: [{
10198
10224
  name: "command",
@@ -10201,22 +10227,51 @@ var init_catalog = __esmMin((() => {
10201
10227
  about: "Describe one command only"
10202
10228
  }],
10203
10229
  dataKey: "commands",
10204
- example: "adiff describe --command 'comment add'"
10230
+ example: "adiff describe --command 'comment send'"
10205
10231
  }
10206
10232
  ];
10207
10233
  commandNames = catalog.map((command) => command.name);
10208
10234
  findCommand = (name) => catalog.find((command) => command.name === name);
10209
- })), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, failure;
10235
+ verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
10236
+ groups = [...new Set(catalog.map((command) => command.group))];
10237
+ NEAR = 3;
10238
+ distance = (left, right) => {
10239
+ const previous = Array.from({ length: right.length + 1 }, (_, at) => at);
10240
+ for (let row = 1; row <= left.length; row += 1) {
10241
+ let corner = previous[0] ?? 0;
10242
+ previous[0] = row;
10243
+ for (let column = 1; column <= right.length; column += 1) {
10244
+ const kept = previous[column] ?? 0;
10245
+ const cost = left[row - 1] === right[column - 1] ? 0 : 1;
10246
+ previous[column] = Math.min(kept + 1, (previous[column - 1] ?? 0) + 1, corner + cost);
10247
+ corner = kept;
10248
+ }
10249
+ }
10250
+ return previous[right.length] ?? 0;
10251
+ };
10252
+ NEAR_ENOUGH = 3;
10253
+ nearestCommand = (name) => {
10254
+ const noun = name.split(" ")[0] ?? "";
10255
+ const under = verbsUnder(noun);
10256
+ const candidates = under.length === 0 ? commandNames : under;
10257
+ const room = Math.max(NEAR, Math.floor(name.length / NEAR_ENOUGH));
10258
+ const scored = candidates.map((known) => ({
10259
+ known,
10260
+ gap: distance(name, known)
10261
+ })).toSorted((left, right) => left.gap - right.gap)[0];
10262
+ return scored !== void 0 && scored.gap <= room ? scored.known : void 0;
10263
+ };
10264
+ })), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, sharpen, failure;
10210
10265
  var init_report$1 = __esmMin((() => {
10211
10266
  ADVICE = {
10212
10267
  UnknownCommand: {
10213
10268
  exit: 2,
10214
- suggestion: "Run `adiff describe` for the commands this build exposes.",
10269
+ suggestion: "Run `adiff --help` for the commands this build exposes, or `adiff describe` for the same as JSON.",
10215
10270
  retriable: false
10216
10271
  },
10217
10272
  MissingOption: {
10218
10273
  exit: 2,
10219
- suggestion: "Run `adiff describe --command <name>` for the options it requires.",
10274
+ suggestion: "Run `adiff <command> --help` for the options it requires.",
10220
10275
  retriable: false
10221
10276
  },
10222
10277
  UnknownBranch: {
@@ -10251,7 +10306,7 @@ var init_report$1 = __esmMin((() => {
10251
10306
  },
10252
10307
  UnknownComment: {
10253
10308
  exit: 3,
10254
- 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.",
10309
+ 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.",
10255
10310
  retriable: false
10256
10311
  },
10257
10312
  InitUnwritable: {
@@ -10282,6 +10337,15 @@ var init_report$1 = __esmMin((() => {
10282
10337
  return raw === void 0 || raw === "true" ? [] : raw.split(",").map((field) => field.trim());
10283
10338
  };
10284
10339
  narrow = (value, fields) => fields.length === 0 ? value : project(value, fields);
10340
+ sharpen = (tag, detail, fallback) => {
10341
+ const meant = detail["didYouMean"];
10342
+ const named = detail["name"];
10343
+ const command = detail["command"];
10344
+ if (tag === "UnknownCommand" && typeof meant === "string") return `Run \`adiff ${meant} --help\` for what it needs, or \`adiff --help\` for every command.`;
10345
+ if (tag === "UnknownCommand" && Array.isArray(detail["verbs"]) && typeof named === "string") return `\`${named}\` needs a verb after it. Run \`adiff ${named} --help\` for the ones it has.`;
10346
+ if (tag === "MissingOption" && typeof command === "string") return `Run \`adiff ${command} --help\` for what it needs.`;
10347
+ return fallback;
10348
+ };
10285
10349
  failure = (cause) => {
10286
10350
  const tag = tagOf(cause);
10287
10351
  const advice = ADVICE[tag] ?? FALLBACK;
@@ -10293,7 +10357,7 @@ var init_report$1 = __esmMin((() => {
10293
10357
  ...detail,
10294
10358
  type: tag,
10295
10359
  retriable: advice.retriable,
10296
- suggestion: advice.suggestion
10360
+ suggestion: sharpen(tag, detail, advice.suggestion)
10297
10361
  }
10298
10362
  }),
10299
10363
  exit: advice.exit
@@ -10318,8 +10382,10 @@ var init_cli = __esmMin((() => {
10318
10382
  init_cli();
10319
10383
  init_catalog();
10320
10384
  const NAME_ROOM = 18;
10385
+ const OPTION_ROOM = 24;
10321
10386
  const version = () => version$1;
10322
- const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${command.about}`;
10387
+ const opening = (about) => about.split(". ")[0] ?? about;
10388
+ const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${opening(command.about)}`;
10323
10389
  const banner = () => [
10324
10390
  `adiff ${version()}`,
10325
10391
  "",
@@ -10340,28 +10406,76 @@ const banner = () => [
10340
10406
  "adiff --help lists every command. adiff describe answers the same as JSON,",
10341
10407
  "and describe --command 'comment take' answers for one."
10342
10408
  ].join("\n");
10409
+ const under = (group) => [
10410
+ group,
10411
+ ...catalog.filter((command) => command.group === group).map(line),
10412
+ ""
10413
+ ];
10343
10414
  const help = () => [
10344
- "adiff, for reviewing an agent's work in a worktree",
10415
+ `adiff ${version()}, for reviewing an agent's work in a worktree`,
10345
10416
  "",
10346
- "Commands:",
10347
- ...catalog.map(line),
10417
+ "Usage",
10418
+ " adiff <command> [options]",
10348
10419
  "",
10349
- "Run `adiff help <command>` for its options."
10420
+ ...groups.flatMap(under),
10421
+ "Run `adiff <command> --help` for what it needs, or `adiff describe` for the same as JSON."
10350
10422
  ].join("\n");
10351
- const option = (spec) => ` --${spec.name.padEnd(16)}${spec.about}${spec.required ? " (required)" : ""}`;
10423
+ const placeholder = (spec) => spec.value === "flag" ? `--${spec.name}` : `--${spec.name} <${spec.value}>`;
10424
+ const wanted = (spec) => spec.required ? placeholder(spec) : `[${placeholder(spec)}]`;
10425
+ const REVIEW = "(--worktree <path> | --repo <path> --branch <name>)";
10426
+ const addressed = (name) => addressing.some((spec) => spec.name === name);
10427
+ const usageOf = (command) => {
10428
+ const own = command.options.filter((spec) => !addressed(spec.name)).map(wanted);
10429
+ const parts = command.addresses === "review" ? [REVIEW, ...own] : own;
10430
+ return [`adiff ${command.name}`, ...parts].join(" ");
10431
+ };
10432
+ const FIELDS$1 = {
10433
+ name: "fields",
10434
+ required: false,
10435
+ value: "a,b",
10436
+ about: "Narrow the answer to these fields, at every level"
10437
+ };
10438
+ const option = (spec) => ` ${placeholder(spec).padEnd(OPTION_ROOM)}${spec.about}${spec.required ? " (required)" : ""}`;
10439
+ const answers$1 = (command) => command.dataKey === "" ? ["Answers by handing the terminal to the reviewer, not in JSON."] : [`Answers {"ok":true,"${command.dataKey}":…}`];
10352
10440
  const helpFor = (name) => {
10353
10441
  const command = findCommand(name);
10354
10442
  if (command === void 0) return void 0;
10355
- const options = command.options.length === 0 ? [] : [
10356
- "",
10357
- "Options:",
10358
- ...command.options.map(option)
10359
- ];
10443
+ const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS$1];
10360
10444
  return [
10361
10445
  `adiff ${command.name}`,
10362
10446
  "",
10363
10447
  command.about,
10364
- ...options
10448
+ "",
10449
+ "Usage",
10450
+ ` ${usageOf(command)}`,
10451
+ ...command.addresses === "review" ? ["", "Naming the review is required: give --worktree, or --repo with --branch."] : [],
10452
+ "",
10453
+ "Options",
10454
+ ...shown.map(option),
10455
+ "",
10456
+ "Example",
10457
+ ` ${command.example}`,
10458
+ "",
10459
+ ...answers$1(command)
10460
+ ].join("\n");
10461
+ };
10462
+ const verb = (name) => {
10463
+ const command = findCommand(name);
10464
+ return ` ${name.split(" ").slice(1).join(" ").padEnd(NAME_ROOM)}${opening(command?.about ?? "")}`;
10465
+ };
10466
+ const helpUnder = (noun) => {
10467
+ const verbs = verbsUnder(noun);
10468
+ if (verbs.length === 0) return void 0;
10469
+ return [
10470
+ `adiff ${noun}`,
10471
+ "",
10472
+ "Usage",
10473
+ ` adiff ${noun} <verb> [options]`,
10474
+ "",
10475
+ "Verbs",
10476
+ ...verbs.map(verb),
10477
+ "",
10478
+ `Run \`adiff ${noun} <verb> --help\` for what it needs.`
10365
10479
  ].join("\n");
10366
10480
  };
10367
10481
  //#endregion
@@ -14827,7 +14941,7 @@ const branchList = fn("Main.branchList")(function* (options) {
14827
14941
  const branches = yield* listBranches(yield* required(options, "repo"));
14828
14942
  yield* answer(options, { branches });
14829
14943
  });
14830
- const commentAdd = fn("Main.commentAdd")(function* (options) {
14944
+ const commentSend = fn("Main.commentSend")(function* (options) {
14831
14945
  const batch = yield* submitComment({
14832
14946
  repo: yield* required(options, "repo"),
14833
14947
  branch: yield* required(options, "branch"),
@@ -14849,6 +14963,7 @@ const commentTake = fn("Main.commentTake")(function* (options) {
14849
14963
  const hint = comments.length === 0 ? { hint: NOTHING_WAITING } : {};
14850
14964
  yield* answer(options, {
14851
14965
  comments,
14966
+ branch: yield* branchAt(worktree),
14852
14967
  ...hint
14853
14968
  });
14854
14969
  });
@@ -14857,14 +14972,14 @@ const commentAnswer = fn("Main.commentAnswer")(function* (options) {
14857
14972
  worktree: yield* required(options, "worktree"),
14858
14973
  id: yield* required(options, "id"),
14859
14974
  body: yield* required(options, "body"),
14860
- asks: options["asks"] !== void 0,
14975
+ asks: options["question"] !== void 0,
14861
14976
  at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
14862
14977
  });
14863
14978
  yield* answer(options, { answered: report.answered });
14864
14979
  });
14865
- const commentThreads = fn("Main.commentThreads")(function* (options) {
14866
- const threads = yield* listThreads(yield* required(options, "repo"), yield* required(options, "branch"));
14867
- yield* answer(options, { threads });
14980
+ const commentList = fn("Main.commentList")(function* (options) {
14981
+ const comments = yield* listThreads(yield* required(options, "repo"), yield* required(options, "branch"));
14982
+ yield* answer(options, { comments });
14868
14983
  });
14869
14984
  const commentResolve = fn("Main.commentResolve")(function* (options) {
14870
14985
  const report = yield* settleThread(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
@@ -14872,7 +14987,10 @@ const commentResolve = fn("Main.commentResolve")(function* (options) {
14872
14987
  });
14873
14988
  const commentRemove = fn("Main.commentRemove")(function* (options) {
14874
14989
  const report = yield* removeComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14875
- yield* answer(options, { removed: report.removed });
14990
+ yield* answer(options, {
14991
+ removed: report.removed,
14992
+ staged: report.staged
14993
+ });
14876
14994
  });
14877
14995
  const commentRestore = fn("Main.commentRestore")(function* (options) {
14878
14996
  const report = yield* restoreComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
@@ -14901,29 +15019,25 @@ const commentEdit = fn("Main.commentEdit")(function* (options) {
14901
15019
  });
14902
15020
  yield* answer(options, { pending: report.pending });
14903
15021
  });
14904
- const commentDrop = fn("Main.commentDrop")(function* (options) {
14905
- const report = yield* dropStaged(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
14906
- yield* answer(options, { pending: report.pending });
14907
- });
14908
- const reviewSubmit = fn("Main.reviewSubmit")(function* (options) {
15022
+ const reviewSend = fn("Main.reviewSend")(function* (options) {
14909
15023
  const report = yield* submitReview(yield* required(options, "repo"), yield* required(options, "branch"), options["id"] ?? randomUUID(), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14910
- yield* answer(options, { submitted: report.submitted });
15024
+ yield* answer(options, { sent: report.submitted });
14911
15025
  });
14912
- const fileVouch = fn("Main.fileVouch")(function* (options) {
15026
+ const fileReview = fn("Main.fileReview")(function* (options) {
14913
15027
  const report = yield* toggleVouch({
14914
15028
  repo: yield* required(options, "repo"),
14915
15029
  branch: yield* required(options, "branch"),
14916
15030
  file: yield* required(options, "file")
14917
15031
  });
14918
15032
  yield* answer(options, {
14919
- vouched: report.vouched,
15033
+ reviewed: report.vouched,
14920
15034
  total: report.total
14921
15035
  });
14922
15036
  });
14923
15037
  const reviewStatus = fn("Main.reviewStatus")(function* (options) {
14924
15038
  const report = yield* reviewProgress(yield* required(options, "repo"), yield* required(options, "branch"));
14925
15039
  yield* answer(options, {
14926
- vouched: report.vouched,
15040
+ reviewed: report.vouched,
14927
15041
  total: report.total,
14928
15042
  pending: report.pending
14929
15043
  });
@@ -14956,17 +15070,16 @@ const init = fn("Main.init")(function* (options) {
14956
15070
  });
14957
15071
  const routes = {
14958
15072
  "branch list": branchList,
14959
- "comment add": commentAdd,
15073
+ "comment send": commentSend,
14960
15074
  "comment stage": commentStage,
14961
15075
  "comment edit": commentEdit,
14962
- "comment drop": commentDrop,
14963
15076
  "comment take": commentTake,
14964
15077
  "comment answer": commentAnswer,
14965
- "comment threads": commentThreads,
15078
+ "comment list": commentList,
14966
15079
  "comment resolve": commentResolve,
14967
15080
  "comment remove": commentRemove,
14968
15081
  "comment restore": commentRestore,
14969
- "review submit": reviewSubmit,
15082
+ "review send": reviewSend,
14970
15083
  "review pane": fn("Main.reviewPane")(function* (options) {
14971
15084
  const report = yield* openPane(yield* required(options, "repo"));
14972
15085
  yield* answer(options, {
@@ -14989,30 +15102,73 @@ const routes = {
14989
15102
  const wanted = options["command"];
14990
15103
  const asked = wanted === void 0 || wanted === "true" ? void 0 : wanted;
14991
15104
  const found = asked === void 0 ? void 0 : findCommand(asked);
14992
- if (asked !== void 0 && found === void 0) return yield* new UnknownCommand({
14993
- name: asked,
14994
- known: commandNames
14995
- });
15105
+ if (asked !== void 0 && found === void 0) return yield* unknown(asked);
14996
15106
  return yield* answer(options, { commands: found === void 0 ? catalog : [found] });
14997
15107
  })
14998
15108
  };
14999
- const run = fn("Main.run")(function* (name, options) {
15109
+ const unknown = (name) => {
15110
+ const verbs = verbsUnder(name);
15111
+ if (verbs.length > 0) return new UnknownCommand({
15112
+ name,
15113
+ verbs
15114
+ });
15115
+ const didYouMean = nearestCommand(name);
15116
+ return didYouMean === void 0 ? new UnknownCommand({ name }) : new UnknownCommand({
15117
+ name,
15118
+ didYouMean
15119
+ });
15120
+ };
15121
+ const byBranch = fn("Main.byBranch")(function* (options, repo, branch) {
15122
+ return options["worktree"] !== void 0 ? options : {
15123
+ ...options,
15124
+ worktree: yield* worktreeOf$1(repo, branch)
15125
+ };
15126
+ });
15127
+ const byWorktree = fn("Main.byWorktree")(function* (options, worktree) {
15128
+ return {
15129
+ ...options,
15130
+ repo: yield* repoOf$1(worktree),
15131
+ branch: yield* branchAt(worktree)
15132
+ };
15133
+ });
15134
+ const addressOf = fn("Main.addressOf")(function* (name, options) {
15135
+ if (findCommand(name)?.addresses !== "review") return options;
15136
+ const repo = options["repo"];
15137
+ const branch = options["branch"];
15138
+ if (repo !== void 0 && branch !== void 0) return yield* byBranch(options, repo, branch);
15139
+ const worktree = options["worktree"];
15140
+ if (worktree !== void 0) return yield* byWorktree(options, worktree);
15141
+ return yield* new MissingOption({ option: addressing[0]?.name ?? "worktree" });
15142
+ });
15143
+ const dispatch = fn("Main.dispatch")(function* (name, given) {
15144
+ const options = yield* addressOf(name, given);
15000
15145
  const route = Object.hasOwn(routes, name) ? routes[name] : void 0;
15001
15146
  if (route !== void 0) return yield* route(options);
15002
- if (name === "file vouch") return yield* fileVouch(options);
15147
+ if (name === "file review") return yield* fileReview(options);
15003
15148
  if (name === "review open") {
15004
15149
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
15005
15150
  return yield* runTui(yield* required(options, "repo"), process.env["ADIFF_SESSION"]);
15006
15151
  }
15007
- return yield* new UnknownCommand({
15008
- name,
15009
- known: commandNames
15010
- });
15152
+ return yield* unknown(name);
15011
15153
  });
15154
+ const wanting = (name) => (error) => {
15155
+ const command = findCommand(name);
15156
+ return command === void 0 ? fail(error) : fail(new MissingOption({
15157
+ option: error.option,
15158
+ command: command.name,
15159
+ usage: usageOf(command)
15160
+ }));
15161
+ };
15162
+ const run = (name, options) => dispatch(name, options).pipe(catchTag("MissingOption", wanting(name)));
15163
+ const leading = (argv) => {
15164
+ const stop = argv.findIndex((token) => token.startsWith("-"));
15165
+ return stop === -1 ? argv : argv.slice(0, stop);
15166
+ };
15012
15167
  const nameOf = (argv) => {
15013
- const words = argv.filter((token) => !token.startsWith("--"));
15168
+ const words = leading(argv);
15014
15169
  const pair = words.slice(0, 2).join(" ");
15015
- return findCommand(pair) === void 0 ? words[0] ?? "" : pair;
15170
+ if (findCommand(pair) !== void 0) return pair;
15171
+ return words.length > 1 ? pair : words[0] ?? "";
15016
15172
  };
15017
15173
  const argv = process.argv.slice(2);
15018
15174
  const ASKS = {
@@ -15021,13 +15177,19 @@ const ASKS = {
15021
15177
  "--help": help,
15022
15178
  "-h": help
15023
15179
  };
15024
- const spoken = (words) => {
15180
+ const about = (words) => {
15181
+ const noun = words[0] ?? "";
15182
+ return helpFor(words.slice(0, 2).join(" ")) ?? helpUnder(noun) ?? help();
15183
+ };
15184
+ const spoken = (given) => {
15185
+ const words = leading(given);
15186
+ if (words.length === 0) {
15187
+ const asked = ASKS[given[0] ?? ""];
15188
+ return asked === void 0 ? banner() : asked();
15189
+ }
15025
15190
  const [first, ...rest] = words;
15026
- if (first === void 0) return banner();
15027
- const asked = ASKS[first];
15028
- if (asked !== void 0) return asked();
15029
- if (first !== "help") return void 0;
15030
- return rest.length === 0 ? help() : helpFor(rest.join(" ")) ?? help();
15191
+ if (first === "help") return rest.length === 0 ? help() : about(rest);
15192
+ return given.some((token) => token === "--help" || token === "-h") ? about(words) : void 0;
15031
15193
  };
15032
15194
  const said = spoken(argv);
15033
15195
  if (said !== void 0) {
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.40",
26
+ "version": "0.1.0-alpha.42",
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": {
@@ -58,10 +58,10 @@ Answer when the change alone does not carry the reasoning: what you did instead
58
58
  what you found while doing it, or why the comment does not apply. A comment that asked a question
59
59
  deserves an answer even when nothing changed.
60
60
 
61
- Add `--asks` when you need the reviewer to decide before you continue:
61
+ Add `--question` when you need the reviewer to decide before you continue:
62
62
 
63
63
  ```bash
64
- adiff comment answer --worktree . --id <id> --asks --body "Drop it, or keep it and map the error?"
64
+ adiff comment answer --worktree . --id <id> --question --body "Drop it, or keep it and map the error?"
65
65
  ```
66
66
 
67
67
  That marks the thread as waiting on them rather than on you. Do not use it to check in; use it when
@@ -89,6 +89,9 @@ Failures go to **stderr**, never stdout, so stdout is always safe to parse. The
89
89
  what kind of problem it is: `2` the request was malformed, `3` the branch or file does not exist,
90
90
  `1` something unexpected.
91
91
 
92
+ Every command that acts on a review takes either `--worktree <path>` or `--repo <path>` with
93
+ `--branch <name>`. Standing in the worktree, `--worktree .` is always enough.
94
+
92
95
  Read `suggestion` before doing anything else — it names the command that resolves the failure.
93
96
  Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
94
97
  about, because the reviewer has not opened it; report that rather than looping.
@@ -215,8 +218,9 @@ inside a layer.
215
218
  adiff describe
216
219
  ```
217
220
 
218
- Returns every command with its options, which are required, and where its payload sits. Use it
219
- instead of guessing, and use `--fields` to keep answers small:
221
+ Returns every command with its options, which are required, which part of the loop it belongs to,
222
+ and where its payload sits. `adiff <command> --help` says the same for one command in plain text.
223
+ Use either instead of guessing, and use `--fields` to keep answers small:
220
224
 
221
225
  ```bash
222
226
  adiff branch list --repo . --fields branch,files