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

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/dist/main.js CHANGED
@@ -4,8 +4,8 @@ import { text } from "node:stream/consumers";
4
4
  import { execFile, spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { existsSync, mkdirSync, watch } from "node:fs";
7
+ import { dirname, join, resolve } from "node:path";
7
8
  import { createInterface } from "node:readline";
8
- import { join, resolve } from "node:path";
9
9
  import { promisify } from "node:util";
10
10
  import { homedir, hostname, platform } from "node:os";
11
11
  import { Language, Parser } from "web-tree-sitter";
@@ -10114,10 +10114,10 @@ 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.206";
10117
+ var version$1 = "0.1.0-alpha.207";
10118
10118
  //#endregion
10119
10119
  //#region src/cli/error.ts
10120
- var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
10120
+ var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, UnexpectedArgument, SeveralIds, IdGivenTwice, BadOption, RegistryUnanswered, NotServed, BadRequest;
10121
10121
  var init_error$6 = __esmMin((() => {
10122
10122
  init_dist();
10123
10123
  UnknownCommand = class extends TaggedError("UnknownCommand") {};
@@ -10125,6 +10125,9 @@ var init_error$6 = __esmMin((() => {
10125
10125
  UnknownField = class extends TaggedError("UnknownField") {};
10126
10126
  UnknownOption = class extends TaggedError("UnknownOption") {};
10127
10127
  RemovedOption = class extends TaggedError("RemovedOption") {};
10128
+ UnexpectedArgument = class extends TaggedError("UnexpectedArgument") {};
10129
+ SeveralIds = class extends TaggedError("SeveralIds") {};
10130
+ IdGivenTwice = class extends TaggedError("IdGivenTwice") {};
10128
10131
  BadOption = class extends TaggedError("BadOption") {};
10129
10132
  RegistryUnanswered = class extends TaggedError("RegistryUnanswered") {};
10130
10133
  NotServed = class extends TaggedError("NotServed") {};
@@ -10323,14 +10326,15 @@ var init_upgrade$1 = __esmMin((() => {
10323
10326
  }));
10324
10327
  //#endregion
10325
10328
  //#region src/cli/catalog.ts
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;
10329
+ var WAIT_MOST, DOING_BY_DEFAULT, 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, ANSWERS_JSON, takesJson, retiredOf, removedIn, retiredIn, renamedIn, renamedFrom, knownIn, takesId, optionsOf, verbsUnder, groups, MIN_EDITS, distance, CHARS_PER_EDIT, SAME_VERB, sameVerb, nearest, nearestCommand, SAME_OPTION, OPTION_EDITS, nearestOption;
10327
10330
  var init_catalog = __esmMin((() => {
10328
10331
  WAIT_MOST = 86400;
10332
+ DOING_BY_DEFAULT = "Working on it";
10329
10333
  worktreeOf$1 = {
10330
10334
  name: "worktree",
10331
10335
  required: false,
10332
10336
  value: "path",
10333
- about: "The worktree under review. Give this, or --repo with --branch"
10337
+ about: "The worktree under review. Give this, or --repo with --branch, or neither from inside the worktree"
10334
10338
  };
10335
10339
  repoOf$1 = {
10336
10340
  name: "repo",
@@ -10432,6 +10436,7 @@ var init_catalog = __esmMin((() => {
10432
10436
  commands$1 = [
10433
10437
  {
10434
10438
  name: "branch list",
10439
+ audience: "anyone",
10435
10440
  about: "Branches with changes against their merge base, and how large each is",
10436
10441
  group: READ_A_BRANCH,
10437
10442
  addresses: "repo",
@@ -10442,6 +10447,7 @@ var init_catalog = __esmMin((() => {
10442
10447
  },
10443
10448
  {
10444
10449
  name: "review open",
10450
+ audience: "reviewer",
10445
10451
  about: "Open the review terminal. With --branch it opens on that branch rather than the worktree list. The only command that does not answer in JSON",
10446
10452
  group: READ_A_BRANCH,
10447
10453
  addresses: "repo",
@@ -10456,6 +10462,7 @@ var init_catalog = __esmMin((() => {
10456
10462
  },
10457
10463
  {
10458
10464
  name: "review pane",
10465
+ audience: "reviewer",
10459
10466
  about: "Open the review beside the conversation, in whichever multiplexer is running. With --branch it opens on that branch. Answers with the command when none is",
10460
10467
  group: READ_A_BRANCH,
10461
10468
  addresses: "repo",
@@ -10470,6 +10477,7 @@ var init_catalog = __esmMin((() => {
10470
10477
  },
10471
10478
  {
10472
10479
  name: "pull show",
10480
+ audience: "anyone",
10473
10481
  about: "The pull request opened from a branch: its address, its state, and whether somebody else opened it",
10474
10482
  group: READ_A_BRANCH,
10475
10483
  addresses: "review",
@@ -10480,6 +10488,7 @@ var init_catalog = __esmMin((() => {
10480
10488
  },
10481
10489
  {
10482
10490
  name: "base list",
10491
+ audience: "anyone",
10483
10492
  about: "The refs worth comparing a branch against: its last few commits, then every other ref",
10484
10493
  group: READ_A_BRANCH,
10485
10494
  addresses: "review",
@@ -10490,6 +10499,7 @@ var init_catalog = __esmMin((() => {
10490
10499
  },
10491
10500
  {
10492
10501
  name: "branch search",
10502
+ audience: "anyone",
10493
10503
  about: "Search a branch's files, changed files first and declarations before uses",
10494
10504
  group: READ_A_BRANCH,
10495
10505
  addresses: "review",
@@ -10505,6 +10515,7 @@ var init_catalog = __esmMin((() => {
10505
10515
  },
10506
10516
  {
10507
10517
  name: "patch show",
10518
+ audience: "anyone",
10508
10519
  about: "A branch's diff as rows with line numbers on both sides, read from the same parse the terminal draws, with the scope each line of a file sits in. Binary and generated files are listed and flagged",
10509
10520
  group: READ_A_BRANCH,
10510
10521
  addresses: "review",
@@ -10529,6 +10540,7 @@ var init_catalog = __esmMin((() => {
10529
10540
  },
10530
10541
  {
10531
10542
  name: "patch since",
10543
+ audience: "anyone",
10532
10544
  about: "One file's diff from the version the reviewer marked reviewed to the file now, in the shape of one file of `patch show`. The old side counts the marked version's lines",
10533
10545
  group: READ_A_BRANCH,
10534
10546
  addresses: "review",
@@ -10548,6 +10560,7 @@ var init_catalog = __esmMin((() => {
10548
10560
  },
10549
10561
  {
10550
10562
  name: "file review",
10563
+ audience: "reviewer",
10551
10564
  about: "Toggle a file as reviewed. Lapses on its own when the file changes",
10552
10565
  group: READ_A_BRANCH,
10553
10566
  addresses: "review",
@@ -10573,6 +10586,7 @@ var init_catalog = __esmMin((() => {
10573
10586
  },
10574
10587
  {
10575
10588
  name: "base set",
10589
+ audience: "reviewer",
10576
10590
  about: "Remember the ref this branch is diffed against, so it is not retyped on every command",
10577
10591
  group: READ_A_BRANCH,
10578
10592
  addresses: "review",
@@ -10588,6 +10602,7 @@ var init_catalog = __esmMin((() => {
10588
10602
  },
10589
10603
  {
10590
10604
  name: "base clear",
10605
+ audience: "reviewer",
10591
10606
  about: "Forget a remembered base, so the branch goes back to using the one it is stacked on",
10592
10607
  group: READ_A_BRANCH,
10593
10608
  addresses: "review",
@@ -10598,6 +10613,7 @@ var init_catalog = __esmMin((() => {
10598
10613
  },
10599
10614
  {
10600
10615
  name: "review progress",
10616
+ audience: "anyone",
10601
10617
  about: "Which files of a review are marked reviewed, which changed since they were marked and by how much, and how many files there are",
10602
10618
  group: READ_A_BRANCH,
10603
10619
  addresses: "review",
@@ -10608,6 +10624,7 @@ var init_catalog = __esmMin((() => {
10608
10624
  },
10609
10625
  {
10610
10626
  name: "comment send",
10627
+ audience: "reviewer",
10611
10628
  about: "Send one comment against a line range, straight to the agent. Name the range with --start and --end, or with the rows a reader picked, --from and --to",
10612
10629
  group: WRITE_COMMENTS,
10613
10630
  addresses: "review",
@@ -10618,6 +10635,7 @@ var init_catalog = __esmMin((() => {
10618
10635
  },
10619
10636
  {
10620
10637
  name: "comment reply",
10638
+ audience: "reviewer",
10621
10639
  about: "Write back to a comment already sent, continuing its thread",
10622
10640
  group: WRITE_COMMENTS,
10623
10641
  addresses: "review",
@@ -10642,6 +10660,7 @@ var init_catalog = __esmMin((() => {
10642
10660
  },
10643
10661
  {
10644
10662
  name: "comment take",
10663
+ audience: "agent",
10645
10664
  about: "Collect the comments this review is still owed an answer on. Repeats until answered",
10646
10665
  group: ANSWER_COMMENTS,
10647
10666
  addresses: "review",
@@ -10657,6 +10676,7 @@ var init_catalog = __esmMin((() => {
10657
10676
  },
10658
10677
  {
10659
10678
  name: "comment answer",
10679
+ audience: "agent",
10660
10680
  about: "Say what was done about a comment, or ask the reviewer something back",
10661
10681
  group: ANSWER_COMMENTS,
10662
10682
  addresses: "review",
@@ -10693,6 +10713,7 @@ var init_catalog = __esmMin((() => {
10693
10713
  },
10694
10714
  {
10695
10715
  name: "comment doing",
10716
+ audience: "agent",
10696
10717
  about: "Say in one line what you are doing on a comment you took. Replaces the last line; an answer clears it",
10697
10718
  group: ANSWER_COMMENTS,
10698
10719
  addresses: "review",
@@ -10707,31 +10728,33 @@ var init_catalog = __esmMin((() => {
10707
10728
  },
10708
10729
  {
10709
10730
  name: "body",
10710
- required: true,
10731
+ required: false,
10711
10732
  value: "text",
10712
- about: "One short line, such as Editing driver.ts"
10733
+ about: `One short line, such as Editing driver.ts. Without it the line reads ${DOING_BY_DEFAULT}`
10713
10734
  }
10714
10735
  ],
10715
10736
  dataKey: "doing",
10716
- example: "adiff comment doing --worktree . --id c1 --body \"Editing driver.ts\""
10737
+ example: "adiff comment doing c1 --body \"Editing driver.ts\""
10717
10738
  },
10718
10739
  {
10719
10740
  name: "layers set",
10741
+ audience: "agent",
10720
10742
  about: "Write the reading order for this review's diff: ordered layers over spans of files",
10721
10743
  group: ANSWER_COMMENTS,
10722
10744
  addresses: "review",
10723
10745
  safety: "write",
10724
10746
  options: [...based, {
10725
- name: "json",
10747
+ name: "file",
10726
10748
  required: true,
10727
- value: "file|-",
10749
+ value: "path|-",
10728
10750
  about: "The document, as a file path or - to read stdin: {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"note\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}. A layer may carry blocks instead of spans, interleaving {\"kind\":\"prose\",\"markdown\":\"…\"} with {\"kind\":\"code\",\"path\":\"…\",\"start\":1,\"end\":9}"
10729
10751
  }],
10730
10752
  dataKey: "layers",
10731
- example: "adiff layers set --worktree . --json -"
10753
+ example: "adiff layers set --file -"
10732
10754
  },
10733
10755
  {
10734
10756
  name: "layers show",
10757
+ audience: "anyone",
10735
10758
  about: "The layers of a review, with the hunks no layer claims",
10736
10759
  group: ANSWER_COMMENTS,
10737
10760
  addresses: "review",
@@ -10742,6 +10765,7 @@ var init_catalog = __esmMin((() => {
10742
10765
  },
10743
10766
  {
10744
10767
  name: "layers ask",
10768
+ audience: "reviewer",
10745
10769
  about: "Ask the agent for a reading order, or a new one, as `L` does in the terminal",
10746
10770
  group: WRITE_COMMENTS,
10747
10771
  addresses: "review",
@@ -10752,6 +10776,7 @@ var init_catalog = __esmMin((() => {
10752
10776
  },
10753
10777
  {
10754
10778
  name: "draft list",
10779
+ audience: "anyone",
10755
10780
  about: "The comments held for this pull request, in the order they were written",
10756
10781
  group: DRAFTS,
10757
10782
  addresses: "review",
@@ -10762,6 +10787,7 @@ var init_catalog = __esmMin((() => {
10762
10787
  },
10763
10788
  {
10764
10789
  name: "draft add",
10790
+ audience: "anyone",
10765
10791
  about: "Hold one comment against a line range, to be sent with the rest. Name the range with --start and --end, or with the rows a reader picked, --from and --to",
10766
10792
  group: DRAFTS,
10767
10793
  addresses: "review",
@@ -10772,6 +10798,7 @@ var init_catalog = __esmMin((() => {
10772
10798
  },
10773
10799
  {
10774
10800
  name: "draft edit",
10801
+ audience: "anyone",
10775
10802
  about: "Rewrite a held comment before it is sent",
10776
10803
  group: DRAFTS,
10777
10804
  addresses: "review",
@@ -10796,6 +10823,7 @@ var init_catalog = __esmMin((() => {
10796
10823
  },
10797
10824
  {
10798
10825
  name: "draft drop",
10826
+ audience: "anyone",
10799
10827
  about: "Throw away a held comment rather than sending it",
10800
10828
  group: DRAFTS,
10801
10829
  addresses: "review",
@@ -10811,6 +10839,7 @@ var init_catalog = __esmMin((() => {
10811
10839
  },
10812
10840
  {
10813
10841
  name: "draft send",
10842
+ audience: "reviewer",
10814
10843
  about: "Send every held comment to the pull request, as one review",
10815
10844
  group: DRAFTS,
10816
10845
  addresses: "review",
@@ -10821,6 +10850,7 @@ var init_catalog = __esmMin((() => {
10821
10850
  },
10822
10851
  {
10823
10852
  name: "comment list",
10853
+ audience: "anyone",
10824
10854
  about: "Every comment on a review, with its answers and whether it is settled",
10825
10855
  group: FOLLOW_UP,
10826
10856
  addresses: "review",
@@ -10831,6 +10861,7 @@ var init_catalog = __esmMin((() => {
10831
10861
  },
10832
10862
  {
10833
10863
  name: "remark list",
10864
+ audience: "anyone",
10834
10865
  about: "Every remark on the branch's pull request, with who left it and whether it is triaged",
10835
10866
  group: FOLLOW_UP,
10836
10867
  addresses: "review",
@@ -10841,6 +10872,7 @@ var init_catalog = __esmMin((() => {
10841
10872
  },
10842
10873
  {
10843
10874
  name: "remark accept",
10875
+ audience: "reviewer",
10844
10876
  about: "Take a remark on as your own comment, so the agent picks it up",
10845
10877
  group: FOLLOW_UP,
10846
10878
  addresses: "review",
@@ -10865,6 +10897,7 @@ var init_catalog = __esmMin((() => {
10865
10897
  },
10866
10898
  {
10867
10899
  name: "remark reply",
10900
+ audience: "reviewer",
10868
10901
  about: "Answer a remark in its thread on the pull request",
10869
10902
  group: FOLLOW_UP,
10870
10903
  addresses: "review",
@@ -10889,6 +10922,7 @@ var init_catalog = __esmMin((() => {
10889
10922
  },
10890
10923
  {
10891
10924
  name: "remark dismiss",
10925
+ audience: "reviewer",
10892
10926
  about: "Take a remark out of this review. It stays on the pull request",
10893
10927
  group: FOLLOW_UP,
10894
10928
  addresses: "review",
@@ -10904,6 +10938,7 @@ var init_catalog = __esmMin((() => {
10904
10938
  },
10905
10939
  {
10906
10940
  name: "remark restore",
10941
+ audience: "reviewer",
10907
10942
  about: "Put a dismissed remark back into this review",
10908
10943
  group: FOLLOW_UP,
10909
10944
  addresses: "review",
@@ -10919,6 +10954,7 @@ var init_catalog = __esmMin((() => {
10919
10954
  },
10920
10955
  {
10921
10956
  name: "comment resolve",
10957
+ audience: "reviewer",
10922
10958
  about: "Mark a comment settled. Only the reviewer who raised it can",
10923
10959
  group: FOLLOW_UP,
10924
10960
  addresses: "review",
@@ -10943,6 +10979,7 @@ var init_catalog = __esmMin((() => {
10943
10979
  },
10944
10980
  {
10945
10981
  name: "comment read",
10982
+ audience: "reviewer",
10946
10983
  about: "Mark the answers on a comment read, as reading them in the terminal does",
10947
10984
  group: FOLLOW_UP,
10948
10985
  addresses: "review",
@@ -10958,6 +10995,7 @@ var init_catalog = __esmMin((() => {
10958
10995
  },
10959
10996
  {
10960
10997
  name: "comment remove",
10998
+ audience: "reviewer",
10961
10999
  about: "Take a comment out of the review, leaving what was already delivered on the record",
10962
11000
  group: FOLLOW_UP,
10963
11001
  addresses: "review",
@@ -10973,6 +11011,7 @@ var init_catalog = __esmMin((() => {
10973
11011
  },
10974
11012
  {
10975
11013
  name: "comment restore",
11014
+ audience: "reviewer",
10976
11015
  about: "Put a removed comment back into the review",
10977
11016
  group: FOLLOW_UP,
10978
11017
  addresses: "review",
@@ -10988,6 +11027,7 @@ var init_catalog = __esmMin((() => {
10988
11027
  },
10989
11028
  {
10990
11029
  name: "comment reopen",
11030
+ audience: "reviewer",
10991
11031
  about: "Take a settled comment back into the review, so the agent is owed an answer again",
10992
11032
  group: FOLLOW_UP,
10993
11033
  addresses: "review",
@@ -11003,6 +11043,7 @@ var init_catalog = __esmMin((() => {
11003
11043
  },
11004
11044
  {
11005
11045
  name: "config list",
11046
+ audience: "anyone",
11006
11047
  about: "Every preference adiff keeps, with its value and what it does",
11007
11048
  group: SET_UP,
11008
11049
  addresses: "none",
@@ -11013,6 +11054,7 @@ var init_catalog = __esmMin((() => {
11013
11054
  },
11014
11055
  {
11015
11056
  name: "config get",
11057
+ audience: "anyone",
11016
11058
  about: "What one preference is set to",
11017
11059
  group: SET_UP,
11018
11060
  addresses: "none",
@@ -11028,6 +11070,7 @@ var init_catalog = __esmMin((() => {
11028
11070
  },
11029
11071
  {
11030
11072
  name: "config set",
11073
+ audience: "reviewer",
11031
11074
  about: "Turn one preference on or off, for every repository on this machine",
11032
11075
  group: SET_UP,
11033
11076
  addresses: "none",
@@ -11048,6 +11091,7 @@ var init_catalog = __esmMin((() => {
11048
11091
  },
11049
11092
  {
11050
11093
  name: "upgrade",
11094
+ audience: "reviewer",
11051
11095
  about: "Upgrade this install to the newest build, using whatever installed it. Answers a person in plain text, and a caller in JSON with --json",
11052
11096
  group: SET_UP,
11053
11097
  addresses: "none",
@@ -11061,13 +11105,14 @@ var init_catalog = __esmMin((() => {
11061
11105
  name: "json",
11062
11106
  required: false,
11063
11107
  value: "flag",
11064
- about: "Answer with the usual envelope instead of plain text. This is the only command that needs it"
11108
+ about: "Answer with the usual envelope instead of plain text. This is the only command that takes it"
11065
11109
  }],
11066
11110
  dataKey: "upgrade",
11067
11111
  example: "adiff upgrade --check --json --fields route,latest,current"
11068
11112
  },
11069
11113
  {
11070
11114
  name: "serve",
11115
+ audience: "anyone",
11071
11116
  about: "Answer commands one JSON line at a time on stdin and stdout, and report changes to the reviews a client watches. For a program that asks adiff often, such as a review page",
11072
11117
  group: SET_UP,
11073
11118
  addresses: "repo",
@@ -11078,6 +11123,7 @@ var init_catalog = __esmMin((() => {
11078
11123
  },
11079
11124
  {
11080
11125
  name: "resume",
11126
+ audience: "reviewer",
11081
11127
  about: "Open the review you left last in this repository. Opens the terminal, like `review open`, on the branch it was opened on most recently",
11082
11128
  group: SET_UP,
11083
11129
  addresses: "none",
@@ -11098,6 +11144,7 @@ var init_catalog = __esmMin((() => {
11098
11144
  },
11099
11145
  {
11100
11146
  name: "describe",
11147
+ audience: "anyone",
11101
11148
  about: "This catalog, as JSON",
11102
11149
  group: SET_UP,
11103
11150
  addresses: "none",
@@ -11123,26 +11170,51 @@ var init_catalog = __esmMin((() => {
11123
11170
  KNOWN_ANYWHERE = [
11124
11171
  ...VALUED_ANYWHERE,
11125
11172
  "help",
11126
- "json",
11127
11173
  "run",
11128
11174
  "quiet"
11129
11175
  ];
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] ?? {};
11176
+ valuedIn = (name) => /* @__PURE__ */ new Set([
11177
+ ...VALUED_ANYWHERE,
11178
+ ...renamedFrom(name),
11179
+ ...(findCommand(name)?.options ?? []).filter((option) => option.value !== "flag").map((option) => option.name)
11180
+ ]);
11181
+ RETIRED = {
11182
+ "comment take": { new: {
11183
+ 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.",
11184
+ meantWith: "wait"
11185
+ } },
11186
+ "layers set": { json: {
11187
+ reason: "layers set reads its document from --file: give --file <path>, or --file - to read stdin.",
11188
+ meantWith: "file",
11189
+ renamedTo: "file"
11190
+ } }
11191
+ };
11192
+ ANSWERS_JSON = {
11193
+ reason: "This command answers in JSON with or without --json. Run it again without --json.",
11194
+ meantWith: ""
11195
+ };
11196
+ takesJson = (name) => (findCommand(name)?.options ?? []).some((option) => option.name === "json");
11197
+ retiredOf = (name) => ({
11198
+ ...takesJson(name) ? {} : { json: ANSWERS_JSON },
11199
+ ...RETIRED[name]
11200
+ });
11136
11201
  removedIn = (name, given) => {
11137
11202
  const retired = retiredOf(name);
11138
- const option = given.find((one) => Object.hasOwn(retired, one) && !given.includes(retired[one]?.meantWith ?? ""));
11203
+ const option = given.find((one) => Object.hasOwn(retired, one) && retired[one]?.renamedTo === void 0 && !given.includes(retired[one]?.meantWith ?? ""));
11139
11204
  return option === void 0 ? void 0 : {
11140
11205
  option,
11141
11206
  reason: retired[option]?.reason ?? ""
11142
11207
  };
11143
11208
  };
11144
11209
  retiredIn = (name, given) => given.filter((one) => Object.hasOwn(retiredOf(name), one));
11210
+ renamedIn = (name, given) => Object.fromEntries(given.flatMap((one) => {
11211
+ const to = retiredOf(name)[one]?.renamedTo;
11212
+ return to === void 0 || given.includes(to) ? [] : [[one, to]];
11213
+ }));
11214
+ renamedFrom = (name) => Object.entries(RETIRED[name] ?? {}).filter(([, retired]) => retired.renamedTo !== void 0).map(([old]) => old);
11145
11215
  knownIn = (name) => /* @__PURE__ */ new Set([...KNOWN_ANYWHERE, ...(findCommand(name)?.options ?? []).map((option) => option.name)]);
11216
+ takesId = (command) => command.options.some((option) => option.name === "id");
11217
+ optionsOf = (command) => [...command.options.map((option) => option.name), "help"];
11146
11218
  verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
11147
11219
  groups = [...new Set(catalog.map((command) => command.group))];
11148
11220
  MIN_EDITS = 3;
@@ -11161,21 +11233,48 @@ var init_catalog = __esmMin((() => {
11161
11233
  return previous[right.length] ?? 0;
11162
11234
  };
11163
11235
  CHARS_PER_EDIT = 3;
11236
+ SAME_VERB = {
11237
+ get: ["show", "list"],
11238
+ view: ["show", "list"],
11239
+ ls: ["list"],
11240
+ delete: ["remove", "drop"],
11241
+ rm: ["remove", "drop"]
11242
+ };
11243
+ sameVerb = (name, under) => {
11244
+ const [noun = "", verb = ""] = name.split(" ");
11245
+ return (SAME_VERB[verb] ?? []).map((same) => `${noun} ${same}`).find((known) => under.includes(known));
11246
+ };
11247
+ nearest = (given, candidates, room) => {
11248
+ const scored = candidates.map((known) => ({
11249
+ known,
11250
+ gap: distance(given, known)
11251
+ })).toSorted((left, right) => left.gap - right.gap)[0];
11252
+ return scored !== void 0 && scored.gap <= room ? scored.known : void 0;
11253
+ };
11164
11254
  nearestCommand = (name) => {
11165
11255
  const noun = name.split(" ")[0] ?? "";
11166
11256
  const under = verbsUnder(noun);
11167
11257
  const candidates = under.length === 0 ? commandNames : under;
11168
11258
  const room = Math.max(MIN_EDITS, Math.floor(name.length / CHARS_PER_EDIT));
11169
- const scored = candidates.map((known) => ({
11170
- known,
11171
- gap: distance(name, known)
11172
- })).toSorted((left, right) => left.gap - right.gap)[0];
11173
- return scored !== void 0 && scored.gap <= room ? scored.known : void 0;
11259
+ return sameVerb(name, under) ?? nearest(name, candidates, room);
11260
+ };
11261
+ SAME_OPTION = {
11262
+ comment: ["id"],
11263
+ "comment-id": ["id"],
11264
+ thread: ["id"],
11265
+ message: ["body"],
11266
+ text: ["body"],
11267
+ path: ["file", "worktree"]
11268
+ };
11269
+ OPTION_EDITS = 2;
11270
+ nearestOption = (command, given) => {
11271
+ const taken = command.options.map((option) => option.name);
11272
+ return (SAME_OPTION[given] ?? []).find((known) => taken.includes(known)) ?? nearest(given, taken, Math.min(OPTION_EDITS, Math.floor(given.length / 2)));
11174
11273
  };
11175
11274
  }));
11176
11275
  //#endregion
11177
11276
  //#region src/cli/parse.ts
11178
- var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, STDIN, text$1, numeric, SPOT, spot, WHOLE, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11277
+ var FLAG, REPEATED, MANY, withValue, flagOn, tokenOn, takenFrom, optionsFrom, bareIn, onlyKnown, oneOf, required, STDIN, text$1, numeric, SPOT, spot, WHOLE, around$1, seconds, many, CHOICES_FEWEST, CHOICES_MOST, choices, oneLine;
11179
11278
  var init_parse$1 = __esmMin((() => {
11180
11279
  init_dist();
11181
11280
  init_catalog();
@@ -11196,39 +11295,46 @@ var init_parse$1 = __esmMin((() => {
11196
11295
  };
11197
11296
  flagOn = (taken, token, valued) => {
11198
11297
  const found = FLAG.exec(token)?.groups;
11199
- if (found === void 0) return taken;
11298
+ if (found === void 0) return {
11299
+ ...taken,
11300
+ bare: [...taken.bare, token]
11301
+ };
11200
11302
  const name = found["name"] ?? "";
11201
11303
  const value = found["value"];
11202
11304
  if (value !== void 0) return {
11203
- options: withValue(taken.options, name, value),
11204
- held: void 0
11305
+ ...taken,
11306
+ options: withValue(taken.options, name, value)
11205
11307
  };
11206
11308
  if (valued.has(name)) return {
11207
- options: taken.options,
11309
+ ...taken,
11208
11310
  held: name
11209
11311
  };
11210
11312
  return {
11313
+ ...taken,
11211
11314
  options: {
11212
11315
  ...taken.options,
11213
11316
  [name]: "true"
11214
- },
11215
- held: void 0
11317
+ }
11216
11318
  };
11217
11319
  };
11218
11320
  tokenOn = (taken, token, valued) => taken.held === void 0 ? flagOn(taken, token, valued) : {
11321
+ ...taken,
11219
11322
  options: withValue(taken.options, taken.held, token),
11220
11323
  held: void 0
11221
11324
  };
11325
+ takenFrom = (argv, valued) => argv.reduce((held, token) => tokenOn(held, token, valued), {
11326
+ options: {},
11327
+ held: void 0,
11328
+ bare: []
11329
+ });
11222
11330
  optionsFrom = (argv, valued = /* @__PURE__ */ new Set()) => {
11223
- const taken = argv.reduce((held, token) => tokenOn(held, token, valued), {
11224
- options: {},
11225
- held: void 0
11226
- });
11331
+ const taken = takenFrom(argv, valued);
11227
11332
  return taken.held === void 0 ? taken.options : {
11228
11333
  ...taken.options,
11229
11334
  [taken.held]: ""
11230
11335
  };
11231
11336
  };
11337
+ bareIn = (argv, valued = /* @__PURE__ */ new Set()) => takenFrom(argv, valued).bare;
11232
11338
  onlyKnown = (options, known) => {
11233
11339
  const strange = Object.keys(options).find((name) => !known.has(name));
11234
11340
  return strange === void 0 ? succeed$1(options) : fail(new UnknownOption({
@@ -11331,7 +11437,7 @@ var init_parse$1 = __esmMin((() => {
11331
11437
  allowed: ["one line of text, not empty"]
11332
11438
  });
11333
11439
  });
11334
- })), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, keysIn, strangeField, sharpen, failure;
11440
+ })), ADVICE, FALLBACK, tagOf, project, fieldsOf, OK, beyondOk, onlyOk, narrow, keysIn, strangeField, wordIn, unknownCommand, unknownOption, naming, SHARPER, sharpen, failure;
11335
11441
  var init_report$1 = __esmMin((() => {
11336
11442
  ADVICE = {
11337
11443
  UnknownCommand: {
@@ -11371,7 +11477,7 @@ var init_report$1 = __esmMin((() => {
11371
11477
  },
11372
11478
  UnknownWorktree: {
11373
11479
  exit: 3,
11374
- suggestion: "--worktree takes the path of a worktree of the repository under review. The error lists the ones that exist; pass one of those, or run the command from inside it with `--worktree .`.",
11480
+ suggestion: "--worktree takes the path of a worktree of the repository under review. The error lists the ones that exist; pass one of those, or run the command from inside the worktree with no --worktree.",
11375
11481
  retriable: false
11376
11482
  },
11377
11483
  MalformedLayers: {
@@ -11444,6 +11550,26 @@ var init_report$1 = __esmMin((() => {
11444
11550
  suggestion: "This command no longer takes that option. Run it again without the option; the reason is named above.",
11445
11551
  retriable: false
11446
11552
  },
11553
+ UnexpectedArgument: {
11554
+ exit: 2,
11555
+ suggestion: "This command takes options only, each written as --name. Run `adiff <command> --help` for the ones it takes.",
11556
+ retriable: false
11557
+ },
11558
+ SeveralIds: {
11559
+ exit: 2,
11560
+ suggestion: "This command takes one id. Run it once for each id.",
11561
+ retriable: false
11562
+ },
11563
+ IdGivenTwice: {
11564
+ exit: 2,
11565
+ suggestion: "The id was given twice, once bare and once with --id. Give it one way.",
11566
+ retriable: false
11567
+ },
11568
+ AmbiguousId: {
11569
+ exit: 2,
11570
+ suggestion: "Several ids start that way. They are listed under matches; give enough of one to tell it apart.",
11571
+ retriable: false
11572
+ },
11447
11573
  BadOption: {
11448
11574
  exit: 2,
11449
11575
  suggestion: "That value is not one the option allows. The allowed ones are named above.",
@@ -11536,7 +11662,10 @@ var init_report$1 = __esmMin((() => {
11536
11662
  const raw = options["fields"];
11537
11663
  return raw === void 0 || raw === "true" ? [] : raw.split(",").map((field) => field.trim());
11538
11664
  };
11539
- narrow = (value, fields) => fields.length === 0 ? value : project(value, fields);
11665
+ OK = "ok";
11666
+ beyondOk = (fields) => fields.filter((field) => field !== OK);
11667
+ onlyOk = (fields) => fields.length > 0 && beyondOk(fields).length === 0;
11668
+ narrow = (value, fields) => fields.length === 0 ? value : project(value, beyondOk(fields));
11540
11669
  keysIn = (value) => {
11541
11670
  if (Array.isArray(value)) return value.flatMap((one) => keysIn(one));
11542
11671
  if (typeof value !== "object" || value === null) return [];
@@ -11546,21 +11675,40 @@ var init_report$1 = __esmMin((() => {
11546
11675
  if (fields.length === 0) return void 0;
11547
11676
  const known = [...new Set(Object.values(body).flatMap((value) => keysIn(value)))];
11548
11677
  if (known.length === 0) return void 0;
11549
- const field = fields.find((one) => !known.includes(one));
11678
+ const field = beyondOk(fields).find((one) => !known.includes(one));
11550
11679
  return field === void 0 ? void 0 : {
11551
11680
  field,
11552
11681
  known: known.toSorted()
11553
11682
  };
11554
11683
  };
11555
- sharpen = (tag, detail, fallback) => {
11556
- const meant = detail["didYouMean"];
11557
- const named = detail["name"];
11558
- const command = detail["command"];
11559
- if (tag === "UnknownCommand" && typeof meant === "string") return `Run \`adiff ${meant} --help\` for what it needs, or \`adiff --help\` for every command.`;
11560
- 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.`;
11561
- if (tag === "MissingOption" && typeof command === "string") return `Run \`adiff ${command} --help\` for what it needs.`;
11562
- return fallback;
11684
+ wordIn = (detail, key) => {
11685
+ const found = detail[key];
11686
+ return typeof found === "string" ? found : void 0;
11687
+ };
11688
+ unknownCommand = (detail) => {
11689
+ const meant = wordIn(detail, "didYouMean");
11690
+ const named = wordIn(detail, "name");
11691
+ if (meant !== void 0) return `Did you mean \`adiff ${meant}\`? Run \`adiff ${meant} --help\` for what it needs, or \`adiff --help\` for every command.`;
11692
+ return Array.isArray(detail["verbs"]) && named !== void 0 ? `\`${named}\` needs a verb after it. Run \`adiff ${named} --help\` for the ones it has.` : void 0;
11693
+ };
11694
+ unknownOption = (detail) => {
11695
+ const command = wordIn(detail, "command");
11696
+ const meant = wordIn(detail, "didYouMean");
11697
+ if (command === void 0) return void 0;
11698
+ if (meant !== void 0) return `Did you mean \`--${meant}\`? The options \`${command}\` takes are listed under known.`;
11699
+ return `The options \`${command}\` takes are listed under known. Run \`adiff ${command} --help\` for what each one does.`;
11563
11700
  };
11701
+ naming = (write) => (detail) => {
11702
+ const command = wordIn(detail, "command");
11703
+ return command === void 0 ? void 0 : write(command);
11704
+ };
11705
+ SHARPER = {
11706
+ UnknownCommand: unknownCommand,
11707
+ UnknownOption: unknownOption,
11708
+ SeveralIds: naming((command) => `\`${command}\` takes one id. Run it once for each id.`),
11709
+ MissingOption: naming((command) => `Run \`adiff ${command} --help\` for what it needs.`)
11710
+ };
11711
+ sharpen = (tag, detail, fallback) => SHARPER[tag]?.(detail) ?? fallback;
11564
11712
  failure = (cause) => {
11565
11713
  const tag = tagOf(cause);
11566
11714
  const advice = ADVICE[tag] ?? FALLBACK;
@@ -11581,14 +11729,24 @@ var init_report$1 = __esmMin((() => {
11581
11729
  };
11582
11730
  }));
11583
11731
  //#endregion
11732
+ //#region src/cli/standing.ts
11733
+ var holdsGit, worktreeAbove;
11734
+ var init_standing = __esmMin((() => {
11735
+ holdsGit = (folder) => existsSync(join(folder, ".git"));
11736
+ worktreeAbove = (from) => {
11737
+ const folder = resolve(from);
11738
+ if (holdsGit(folder)) return folder;
11739
+ const parent = dirname(folder);
11740
+ return parent === folder ? void 0 : worktreeAbove(parent);
11741
+ };
11742
+ }));
11743
+ //#endregion
11584
11744
  //#region src/cli/serve.ts
11585
11745
  var Replies, toStdout, NOT_SERVED, SETTLE_MS$1, refused, write, answering, KIND_OF, heldOpen, kindOf, settled$1, watching, unwatching, readRequest, handled, listen, serve;
11586
11746
  var init_serve = __esmMin((() => {
11587
11747
  init_dist();
11588
11748
  init_error$6();
11589
11749
  init_report$1();
11590
- init_parse$1();
11591
- init_catalog();
11592
11750
  Replies = class extends Service()("adiff/Replies") {};
11593
11751
  toStdout = succeed$2(Replies)({ say: (line) => sync(() => void process.stdout.write(`${line}\n`)) });
11594
11752
  NOT_SERVED = /* @__PURE__ */ new Set([
@@ -11613,7 +11771,7 @@ var init_serve = __esmMin((() => {
11613
11771
  const name = serving.nameOf(args);
11614
11772
  if (NOT_SERVED.has(name)) return succeed$1(refused(new NotServed({ command: name })));
11615
11773
  const heard = [];
11616
- return serving.run(name, optionsFrom(args, valuedIn(name))).pipe(provideService(Replies, { say: (line) => sync(() => void heard.push(line)) }), map$1(() => ({
11774
+ return serving.run(name, args).pipe(provideService(Replies, { say: (line) => sync(() => void heard.push(line)) }), map$1(() => ({
11617
11775
  exit: 0,
11618
11776
  answer: JSON.parse(heard.at(-1) ?? "{}")
11619
11777
  })), catchCause((cause) => succeed$1(refused(squash(cause)))));
@@ -11650,7 +11808,7 @@ var init_serve = __esmMin((() => {
11650
11808
  watcher.on("error", () => void 0);
11651
11809
  return watcher;
11652
11810
  };
11653
- watching = (serving, request, watchers) => serving.folderOf(optionsFrom(request.watch ?? [], valuedIn("comment list"))).pipe(map$1((folder) => {
11811
+ watching = (serving, request, watchers) => serving.folderOf(request.watch ?? []).pipe(map$1((folder) => {
11654
11812
  watchers.get(request.id)?.close();
11655
11813
  watchers.set(request.id, settled$1(folder, (what) => write({
11656
11814
  id: request.id,
@@ -11727,6 +11885,7 @@ var init_cli = __esmMin((() => {
11727
11885
  init_parse$1();
11728
11886
  init_catalog();
11729
11887
  init_report$1();
11888
+ init_standing();
11730
11889
  init_error$6();
11731
11890
  init_serve();
11732
11891
  }));
@@ -13396,7 +13555,7 @@ var init_store = __esmMin((() => {
13396
13555
  }));
13397
13556
  //#endregion
13398
13557
  //#region src/review/error.ts
13399
- var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13558
+ var UnknownBranch, BranchMoved, UnknownBase, UnknownFile, NotVouched, VouchedVersionGone, UnknownComment, AmbiguousId, UnknownRemark, NothingSaid, ThreadOpen, RemarkTaken, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PartlySent, PullMoved, NoLayers, NoPull, UnknownLayer;
13400
13559
  var init_error$3 = __esmMin((() => {
13401
13560
  init_dist();
13402
13561
  UnknownBranch = class extends TaggedError("UnknownBranch") {};
@@ -13406,6 +13565,7 @@ var init_error$3 = __esmMin((() => {
13406
13565
  NotVouched = class extends TaggedError("NotVouched") {};
13407
13566
  VouchedVersionGone = class extends TaggedError("VouchedVersionGone") {};
13408
13567
  UnknownComment = class extends TaggedError("UnknownComment") {};
13568
+ AmbiguousId = class extends TaggedError("AmbiguousId") {};
13409
13569
  UnknownRemark = class extends TaggedError("UnknownRemark") {};
13410
13570
  NothingSaid = class extends TaggedError("NothingSaid") {};
13411
13571
  ThreadOpen = class extends TaggedError("ThreadOpen") {};
@@ -14561,6 +14721,21 @@ var init_comments$1 = __esmMin((() => {
14561
14721
  });
14562
14722
  }));
14563
14723
  //#endregion
14724
+ //#region src/review/ids.ts
14725
+ var startingWith;
14726
+ var init_ids = __esmMin((() => {
14727
+ init_dist();
14728
+ init_error$3();
14729
+ startingWith = (ids, given) => {
14730
+ if (given.length === 0 || ids.includes(given)) return succeed$1(given);
14731
+ const matches = ids.filter((id) => id.startsWith(given));
14732
+ return matches.length > 1 ? fail(new AmbiguousId({
14733
+ id: given,
14734
+ matches
14735
+ })) : succeed$1(matches[0] ?? given);
14736
+ };
14737
+ }));
14738
+ //#endregion
14564
14739
  //#region src/domain/review/vouch.ts
14565
14740
  var SHORTEST_BLOB, sameBlob, isVouched, vouch$1, partOf, isPartVouched, vouchPart$1;
14566
14741
  var init_vouch = __esmMin((() => {
@@ -14628,11 +14803,12 @@ var init_review$1 = __esmMin((() => {
14628
14803
  }));
14629
14804
  //#endregion
14630
14805
  //#region src/review/threads.ts
14631
- var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf, threadsIn$1, idsIn, rootIn, rootOf, isKnown, known, list$3, clearDoing, doing, answer$3, repliesTo, settle, without$1, unsettle, remove, restore$1, settleRead, countsOf, loudestOf, drawnOnALine, settledOnALine, fileThreads, byFile$1, lineThreads, byLine;
14806
+ var ASK_LEAD, stateOf$2, choicesOf, answerOf, turnsOf, judged, factsOf, threadOf, threadsIn$1, idsIn, rootIn, rootOf, idStarting$2, isKnown, known, list$3, clearDoing, doing, answer$3, repliesTo, settle, without$1, unsettle, remove, restore$1, settleRead, countsOf, loudestOf, drawnOnALine, settledOnALine, fileThreads, byFile$1, lineThreads, byLine;
14632
14807
  var init_threads$1 = __esmMin((() => {
14633
14808
  init_dist();
14634
14809
  init_store();
14635
14810
  init_error$3();
14811
+ init_ids();
14636
14812
  init_placing();
14637
14813
  init_review$1();
14638
14814
  ASK_LEAD = "About this branch, not about this line.";
@@ -14761,6 +14937,10 @@ var init_threads$1 = __esmMin((() => {
14761
14937
  const root = rootIn(yield* store.inbox(worktree.path), id);
14762
14938
  return root === void 0 ? yield* new UnknownComment({ id }) : root;
14763
14939
  });
14940
+ idStarting$2 = fn("Review.Thread.idStarting")(function* (worktree, given) {
14941
+ const store = yield* Store;
14942
+ return yield* startingWith(idsIn(yield* store.inbox(worktree.path)), given);
14943
+ });
14764
14944
  isKnown = fn("Review.Thread.isKnown")(function* (worktree, id) {
14765
14945
  const store = yield* Store;
14766
14946
  return idsIn(yield* store.inbox(worktree.path)).includes(id);
@@ -14970,7 +15150,7 @@ var init_error$2 = __esmMin((() => {
14970
15150
  }));
14971
15151
  //#endregion
14972
15152
  //#region src/service/forge/service.ts
14973
- var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask$1, show$2, whoseOf, pullOf, read$2, viewerOf, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$2, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked$1, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, address, ForgeLive;
15153
+ var Forge, LIMIT, TIMEOUT_MS, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS, Author, Row, Viewer, readViewer, decode$1, SAID, stateOf$1, ended, ask$1, show$2, whoseOf, pullOf, read$2, viewerOf, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named$2, head, sideName, commentBody, bodyFor, Landed, readLanded, jsonOf$1, keyOf$2, counted$2, acknowledged, landedIn, THREADS, Said, Thread, Page, Held$1, Threads, readThreads, ANONYMOUS, heardFrom$1, someLine, hasNoLine, quotedIn, spanIn, remarkOf, ownerOf, HERE, asked, whereOf, threadsIn, unresolved, PAGES, everyThread, answer$2, remarks, review, address, ForgeLive;
14974
15154
  var init_service$1 = __esmMin((() => {
14975
15155
  init_dist();
14976
15156
  init_error$2();
@@ -14979,7 +15159,7 @@ var init_service$1 = __esmMin((() => {
14979
15159
  TIMEOUT_MS = 4e3;
14980
15160
  SEND_TIMEOUT_MS = 2e4;
14981
15161
  MOST_OUTPUT = 4194304;
14982
- FIELDS$1 = "headRefName,state,isDraft,author";
15162
+ FIELDS = "headRefName,state,isDraft,author";
14983
15163
  Author = Struct({
14984
15164
  login: String$1,
14985
15165
  is_bot: optionalKey(Boolean)
@@ -15018,7 +15198,7 @@ var init_service$1 = __esmMin((() => {
15018
15198
  "--limit",
15019
15199
  LIMIT,
15020
15200
  "--json",
15021
- FIELDS$1
15201
+ FIELDS
15022
15202
  ], {
15023
15203
  cwd: repo,
15024
15204
  timeout: TIMEOUT_MS,
@@ -15296,7 +15476,7 @@ var init_service$1 = __esmMin((() => {
15296
15476
  "-F",
15297
15477
  "name={repo}"
15298
15478
  ];
15299
- asked$1 = (repo, branch, after) => gh(repo, [
15479
+ asked = (repo, branch, after) => gh(repo, [
15300
15480
  "api",
15301
15481
  "graphql",
15302
15482
  "-f",
@@ -15337,7 +15517,7 @@ var init_service$1 = __esmMin((() => {
15337
15517
  const held = [];
15338
15518
  let after;
15339
15519
  for (let page = 0; page < PAGES; page += 1) {
15340
- const raw = yield* asked$1(repo, branch, after);
15520
+ const raw = yield* asked(repo, branch, after);
15341
15521
  const found = yield* threadsIn(repo, raw);
15342
15522
  if (found === void 0) return held;
15343
15523
  held.push(...found.nodes);
@@ -15421,13 +15601,14 @@ var init_service$1 = __esmMin((() => {
15421
15601
  var init_forge = __esmMin((() => {
15422
15602
  init_service$1();
15423
15603
  init_error$2();
15424
- })), VERSION, OPENING, CLOSING, heldOf$1, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
15604
+ })), VERSION, OPENING, CLOSING, heldOf$1, bared, dropped, quotedCode, snippetOf$1, spokenWithout, spanOf, showsLine, placedNow, stateOf, heldPair, accepted, shownOf$1, fetch$1, held$1, against, list$2, idStarting$1, named$1, without, notTaken, dismiss, restore, quoted, anchorFrom, takingOn, accept, answer$1;
15425
15605
  var init_remarks$1 = __esmMin((() => {
15426
15606
  init_dist();
15427
15607
  init_patch();
15428
15608
  init_forge();
15429
15609
  init_store();
15430
15610
  init_error$3();
15611
+ init_ids();
15431
15612
  VERSION = 1;
15432
15613
  OPENING = /^```suggestion[^\n]*\n?/gm;
15433
15614
  CLOSING = /^```[ \t]*$/gm;
@@ -15557,6 +15738,10 @@ var init_remarks$1 = __esmMin((() => {
15557
15738
  list$2 = fn("Review.Remark.list")(function* (reading) {
15558
15739
  return yield* against(reading.worktree, reading.patches);
15559
15740
  });
15741
+ idStarting$1 = fn("Review.Remark.idStarting")(function* (worktree, given) {
15742
+ const kept = yield* held$1(worktree);
15743
+ return yield* startingWith(kept.map((one) => one.id), given);
15744
+ });
15560
15745
  named$1 = fn("Review.Remark.named")(function* (worktree, id) {
15561
15746
  const kept = yield* held$1(worktree);
15562
15747
  const found = kept.find((one) => one.id === id);
@@ -16711,12 +16896,13 @@ var init_layers = __esmMin((() => {
16711
16896
  }));
16712
16897
  //#endregion
16713
16898
  //#region src/review/drafts.ts
16714
- var unreadIn, reported, list, markSeen, add$1, edit, drop, sameCommit, commentOf, sending, dispatch$1;
16899
+ var unreadIn, reported, list, markSeen, add$1, idStarting, edit, drop, sameCommit, commentOf, sending, dispatch$1;
16715
16900
  var init_drafts$1 = __esmMin((() => {
16716
16901
  init_dist();
16717
16902
  init_forge();
16718
16903
  init_store();
16719
16904
  init_error$3();
16905
+ init_ids();
16720
16906
  init_patches();
16721
16907
  unreadIn = (draft, seen) => {
16722
16908
  if (draft.wroteBy !== "agent") return false;
@@ -16763,6 +16949,10 @@ var init_drafts$1 = __esmMin((() => {
16763
16949
  yield* store.saveDrafts(worktree.path, [...held, one]);
16764
16950
  return reported(one, {});
16765
16951
  });
16952
+ idStarting = fn("Review.Draft.idStarting")(function* (worktree, given) {
16953
+ const held = yield* (yield* Store).drafts(worktree.path);
16954
+ return yield* startingWith(held.map((one) => one.id), given);
16955
+ });
16766
16956
  edit = fn("Review.Draft.edit")(function* (worktree, rewrite) {
16767
16957
  const store = yield* Store;
16768
16958
  const held = yield* store.drafts(worktree.path);
@@ -17106,7 +17296,8 @@ const NAME_ROOM = 18;
17106
17296
  const OPTION_ROOM = 24;
17107
17297
  const version = () => version$1;
17108
17298
  const opening$1 = (about) => about.split(". ")[0] ?? about;
17109
- const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${opening$1(command.about)}`;
17299
+ const REVIEWERS = "[reviewer]";
17300
+ const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${opening$1(command.about)}${command.audience === "reviewer" ? ` ${REVIEWERS}` : ""}`;
17110
17301
  const banner = () => [
17111
17302
  `adiff ${version()}`,
17112
17303
  "",
@@ -17118,12 +17309,13 @@ const banner = () => [
17118
17309
  "",
17119
17310
  "An agent working in that worktree answers them:",
17120
17311
  "",
17121
- " adiff comment take --worktree . collect every comment owed an answer",
17122
- " adiff comment take --worktree . --wait 6900 block until a new comment arrives",
17123
- " adiff comment answer --worktree . --id <id> --body '…'",
17124
- " adiff layers set --worktree . --json - publish a reading order, when asked",
17312
+ " adiff comment take collect every comment owed an answer",
17313
+ " adiff comment take --wait 6900 block until a new comment arrives",
17314
+ " adiff comment answer <id> --body '…'",
17315
+ " adiff layers set --file - publish a reading order, when asked",
17125
17316
  "",
17126
17317
  "Every comment carries an id, and an answer goes back to the reviewer under it.",
17318
+ "Run inside the worktree, a command acts on that worktree's review.",
17127
17319
  "",
17128
17320
  "adiff --help lists every command. adiff describe answers the same as JSON,",
17129
17321
  "and describe --command 'comment take' answers for one."
@@ -17140,40 +17332,42 @@ const help = () => [
17140
17332
  " adiff <command> [options]",
17141
17333
  "",
17142
17334
  ...groups.flatMap(under),
17335
+ `${REVIEWERS} marks a command that speaks for the person reviewing. An agent leaves those to them.`,
17336
+ "",
17143
17337
  "Run `adiff <command> --help` for what it needs, or `adiff describe` for the same as JSON."
17144
17338
  ].join("\n");
17145
17339
  const placeholder = (spec) => spec.value === "flag" ? `--${spec.name}` : `--${spec.name} <${spec.value}>`;
17146
17340
  const wanted = (spec) => spec.required ? placeholder(spec) : `[${placeholder(spec)}]`;
17147
- const REVIEW = "(--worktree <path> | --repo <path> --branch <name>)";
17341
+ const REVIEW = "[--worktree <path> | --repo <path> --branch <name>]";
17148
17342
  const addressed = (name) => addressing.some((spec) => spec.name === name);
17149
17343
  const usageOf = (command) => {
17150
17344
  const own = command.options.filter((spec) => !addressed(spec.name)).map(wanted);
17151
17345
  const parts = command.addresses === "review" ? [REVIEW, ...own] : own;
17152
17346
  return [`adiff ${command.name}`, ...parts].join(" ");
17153
17347
  };
17154
- const FIELDS = {
17155
- name: "fields",
17156
- required: false,
17157
- value: "a,b",
17158
- about: "Narrow the answer to these fields, at every level"
17159
- };
17160
17348
  const option = (spec) => ` ${placeholder(spec).padEnd(OPTION_ROOM)}${spec.about}${spec.required ? " (required)" : ""}`;
17349
+ const FOR = {
17350
+ reviewer: "For the reviewer. It speaks for the person reviewing, so an agent leaves it to them.",
17351
+ agent: "For the agent working in the worktree under review.",
17352
+ anyone: "For the reviewer and the agent alike."
17353
+ };
17161
17354
  const answers$1 = (command) => command.dataKey === "" ? ["Answers by handing the terminal to the reviewer, not in JSON."] : [`Answers {"ok":true,"${command.dataKey}":…}`];
17162
17355
  const helpFor = (name) => {
17163
17356
  const command = findCommand(name);
17164
17357
  if (command === void 0) return void 0;
17165
- const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS];
17166
17358
  return [
17167
17359
  `adiff ${command.name}`,
17168
17360
  "",
17169
17361
  command.about,
17170
17362
  "",
17363
+ FOR[command.audience],
17364
+ "",
17171
17365
  "Usage",
17172
17366
  ` ${usageOf(command)}`,
17173
- ...command.addresses === "review" ? ["", "Naming the review is required: give --worktree, or --repo with --branch."] : [],
17367
+ ...command.addresses === "review" ? ["", "Name the review with --worktree, or with --repo and --branch. With neither, the review is the worktree this command is run in."] : [],
17174
17368
  "",
17175
17369
  "Options",
17176
- ...shown.map(option),
17370
+ ...command.options.map(option),
17177
17371
  "",
17178
17372
  "Example",
17179
17373
  ` ${command.example}`,
@@ -26885,7 +27079,7 @@ const answer = fn("Main.answer")(function* (options, body) {
26885
27079
  const fields = fieldsOf(options);
26886
27080
  const strange = strangeField(body, fields);
26887
27081
  if (strange !== void 0) return yield* new UnknownField(strange);
26888
- const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
27082
+ const narrowed = onlyOk(fields) ? {} : Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
26889
27083
  return yield* (yield* Replies).say(JSON.stringify({
26890
27084
  ok: true,
26891
27085
  ...narrowed
@@ -26900,6 +27094,15 @@ const readingIn = fn("Main.readingIn")(function* (options) {
26900
27094
  const worktreeNamed = fn("Main.worktreeNamed")(function* (options) {
26901
27095
  return yield* worktreeAt(yield* required(options, "worktree"));
26902
27096
  });
27097
+ const commentIn = fn("Main.commentIn")(function* (worktree, options, name = "id") {
27098
+ return yield* idStarting$2(worktree, yield* required(options, name));
27099
+ });
27100
+ const draftIn = fn("Main.draftIn")(function* (worktree, options) {
27101
+ return yield* idStarting(worktree, yield* required(options, "id"));
27102
+ });
27103
+ const remarkIn = fn("Main.remarkIn")(function* (worktree, options) {
27104
+ return yield* idStarting$1(worktree, yield* required(options, "id"));
27105
+ });
26903
27106
  const stamp = (options) => options["at"] ?? (/* @__PURE__ */ new Date()).toISOString();
26904
27107
  const branchList = fn("Main.branchList")(function* (options) {
26905
27108
  const branches = yield* list$5(yield* required(options, "repo"), options["base"]);
@@ -26953,8 +27156,9 @@ const draftAdd = fn("Main.draftAdd")(function* (options) {
26953
27156
  yield* answer(options, { draft });
26954
27157
  });
26955
27158
  const draftEdit = fn("Main.draftEdit")(function* (options) {
26956
- const draft = yield* edit(yield* worktreeIn(options), {
26957
- id: yield* required(options, "id"),
27159
+ const worktree = yield* worktreeIn(options);
27160
+ const draft = yield* edit(worktree, {
27161
+ id: yield* draftIn(worktree, options),
26958
27162
  body: yield* text$1(options, "body"),
26959
27163
  at: stamp(options),
26960
27164
  by: "agent"
@@ -26962,7 +27166,8 @@ const draftEdit = fn("Main.draftEdit")(function* (options) {
26962
27166
  yield* answer(options, { draft });
26963
27167
  });
26964
27168
  const draftDrop = fn("Main.draftDrop")(function* (options) {
26965
- const dropped = yield* drop(yield* worktreeIn(options), yield* required(options, "id"));
27169
+ const worktree = yield* worktreeIn(options);
27170
+ const dropped = yield* drop(worktree, yield* draftIn(worktree, options));
26966
27171
  yield* answer(options, { dropped });
26967
27172
  });
26968
27173
  const draftSend = fn("Main.draftSend")(function* (options) {
@@ -26970,8 +27175,9 @@ const draftSend = fn("Main.draftSend")(function* (options) {
26970
27175
  yield* answer(options, { dispatched });
26971
27176
  });
26972
27177
  const commentReply = fn("Main.commentReply")(function* (options) {
26973
- const batch = yield* reply(yield* worktreeIn(options), {
26974
- to: yield* required(options, "to"),
27178
+ const worktree = yield* worktreeIn(options);
27179
+ const batch = yield* reply(worktree, {
27180
+ to: yield* commentIn(worktree, options, "to"),
26975
27181
  body: yield* text$1(options, "body"),
26976
27182
  id: options["id"] ?? randomUUID(),
26977
27183
  at: stamp(options)
@@ -27002,8 +27208,9 @@ const commentTake = fn("Main.commentTake")(function* (options) {
27002
27208
  });
27003
27209
  });
27004
27210
  const commentAnswer = fn("Main.commentAnswer")(function* (options) {
27005
- const report = yield* answer$3(yield* worktreeNamed(options), {
27006
- id: yield* required(options, "id"),
27211
+ const worktree = yield* worktreeNamed(options);
27212
+ const report = yield* answer$3(worktree, {
27213
+ id: yield* commentIn(worktree, options),
27007
27214
  body: yield* text$1(options, "body"),
27008
27215
  asks: options["question"] !== void 0,
27009
27216
  at: stamp(options),
@@ -27012,9 +27219,10 @@ const commentAnswer = fn("Main.commentAnswer")(function* (options) {
27012
27219
  yield* answer(options, { answered: report.answered });
27013
27220
  });
27014
27221
  const commentDoing = fn("Main.commentDoing")(function* (options) {
27015
- const report = yield* doing(yield* worktreeNamed(options), {
27016
- id: yield* required(options, "id"),
27017
- body: yield* oneLine(options, "body"),
27222
+ const worktree = yield* worktreeNamed(options);
27223
+ const report = yield* doing(worktree, {
27224
+ id: yield* commentIn(worktree, options),
27225
+ body: options["body"] === void 0 ? DOING_BY_DEFAULT : yield* oneLine(options, "body"),
27018
27226
  at: stamp(options)
27019
27227
  });
27020
27228
  yield* answer(options, report);
@@ -27024,8 +27232,9 @@ const remarkList = fn("Main.remarkList")(function* (options) {
27024
27232
  yield* answer(options, { remarks });
27025
27233
  });
27026
27234
  const remarkAccept = fn("Main.remarkAccept")(function* (options) {
27027
- const report = yield* accept(yield* readingIn(options), {
27028
- id: yield* required(options, "id"),
27235
+ const reading = yield* readingIn(options);
27236
+ const report = yield* accept(reading, {
27237
+ id: yield* remarkIn(reading.worktree, options),
27029
27238
  body: options["body"] === void 0 ? void 0 : yield* text$1(options, "body"),
27030
27239
  at: stamp(options),
27031
27240
  commentId: options["comment"] ?? randomUUID()
@@ -27033,15 +27242,18 @@ const remarkAccept = fn("Main.remarkAccept")(function* (options) {
27033
27242
  yield* answer(options, report);
27034
27243
  });
27035
27244
  const remarkReply = fn("Main.remarkReply")(function* (options) {
27036
- const report = yield* answer$1(yield* required(options, "repo"), yield* worktreeIn(options), yield* required(options, "id"), yield* text$1(options, "body"));
27245
+ const worktree = yield* worktreeIn(options);
27246
+ const report = yield* answer$1(yield* required(options, "repo"), worktree, yield* remarkIn(worktree, options), yield* text$1(options, "body"));
27037
27247
  yield* answer(options, { answered: report.answered });
27038
27248
  });
27039
27249
  const remarkDismiss = fn("Main.remarkDismiss")(function* (options) {
27040
- const report = yield* dismiss(yield* worktreeIn(options), yield* required(options, "id"), stamp(options));
27250
+ const worktree = yield* worktreeIn(options);
27251
+ const report = yield* dismiss(worktree, yield* remarkIn(worktree, options), stamp(options));
27041
27252
  yield* answer(options, { dismissed: report.dismissed });
27042
27253
  });
27043
27254
  const remarkRestore = fn("Main.remarkRestore")(function* (options) {
27044
- const report = yield* restore(yield* worktreeIn(options), yield* required(options, "id"));
27255
+ const worktree = yield* worktreeIn(options);
27256
+ const report = yield* restore(worktree, yield* remarkIn(worktree, options));
27045
27257
  yield* answer(options, { restored: report.restored });
27046
27258
  });
27047
27259
  const commentList = fn("Main.commentList")(function* (options) {
@@ -27059,7 +27271,8 @@ const resolveRead = fn("Main.resolveRead")(function* (options) {
27059
27271
  yield* answer(options, { settled: report.settled });
27060
27272
  });
27061
27273
  const commentRead = fn("Main.commentRead")(function* (options) {
27062
- const report = yield* markRead(yield* worktreeIn(options), yield* required(options, "id"));
27274
+ const worktree = yield* worktreeIn(options);
27275
+ const report = yield* markRead(worktree, yield* commentIn(worktree, options));
27063
27276
  yield* answer(options, {
27064
27277
  read: report.id,
27065
27278
  unread: report.unread
@@ -27097,19 +27310,23 @@ const layersAsk = fn("Main.layersAsk")(function* (options) {
27097
27310
  });
27098
27311
  const commentResolve = fn("Main.commentResolve")(function* (options) {
27099
27312
  if (options["read"] !== void 0) return yield* resolveRead(options);
27100
- const report = yield* settle(yield* worktreeIn(options), yield* required(options, "id"), stamp(options));
27313
+ const worktree = yield* worktreeIn(options);
27314
+ const report = yield* settle(worktree, yield* commentIn(worktree, options), stamp(options));
27101
27315
  return yield* answer(options, { settled: report.settled });
27102
27316
  });
27103
27317
  const commentRemove = fn("Main.commentRemove")(function* (options) {
27104
- const report = yield* remove(yield* worktreeIn(options), yield* required(options, "id"), stamp(options));
27318
+ const worktree = yield* worktreeIn(options);
27319
+ const report = yield* remove(worktree, yield* commentIn(worktree, options), stamp(options));
27105
27320
  yield* answer(options, { removed: report.removed });
27106
27321
  });
27107
27322
  const commentRestore = fn("Main.commentRestore")(function* (options) {
27108
- const report = yield* restore$1(yield* worktreeIn(options), yield* required(options, "id"));
27323
+ const worktree = yield* worktreeIn(options);
27324
+ const report = yield* restore$1(worktree, yield* commentIn(worktree, options));
27109
27325
  yield* answer(options, { restored: report.restored });
27110
27326
  });
27111
27327
  const commentReopen = fn("Main.commentReopen")(function* (options) {
27112
- const report = yield* unsettle(yield* worktreeIn(options), yield* required(options, "id"));
27328
+ const worktree = yield* worktreeIn(options);
27329
+ const report = yield* unsettle(worktree, yield* commentIn(worktree, options));
27113
27330
  yield* answer(options, { reopened: report.unsettled });
27114
27331
  });
27115
27332
  const vouched = fn("Main.vouched")(function* (options) {
@@ -27151,7 +27368,7 @@ const documentAt = fn("Main.documentAt")(function* (source) {
27151
27368
  });
27152
27369
  });
27153
27370
  const layersSet = fn("Main.layersSet")(function* (options) {
27154
- const document = yield* documentAt(yield* required(options, "json"));
27371
+ const document = yield* documentAt(yield* required(options, "file"));
27155
27372
  const layers = yield* set(yield* worktreeNamed(options), document, stamp(options));
27156
27373
  yield* answer(options, { layers });
27157
27374
  });
@@ -27267,9 +27484,15 @@ const unknown = (name) => {
27267
27484
  verbs
27268
27485
  });
27269
27486
  const didYouMean = nearestCommand(name);
27270
- return didYouMean === void 0 ? new UnknownCommand({ name }) : new UnknownCommand({
27487
+ if (didYouMean === void 0) return new UnknownCommand({ name });
27488
+ const beside = verbsUnder(name.split(" ")[0] ?? "");
27489
+ return beside.length === 0 ? new UnknownCommand({
27271
27490
  name,
27272
27491
  didYouMean
27492
+ }) : new UnknownCommand({
27493
+ name,
27494
+ didYouMean,
27495
+ verbs: beside
27273
27496
  });
27274
27497
  };
27275
27498
  const byBranch = fn("Main.byBranch")(function* (options, repo, branch) {
@@ -27278,6 +27501,10 @@ const byBranch = fn("Main.byBranch")(function* (options, repo, branch) {
27278
27501
  worktree: (yield* find(repo, branch)).path
27279
27502
  };
27280
27503
  });
27504
+ const byHere = (options, repo, branch) => byBranch({
27505
+ ...options,
27506
+ repo
27507
+ }, repo, branch);
27281
27508
  const byWorktree = fn("Main.byWorktree")(function* (options, worktree) {
27282
27509
  return {
27283
27510
  ...options,
@@ -27285,14 +27512,22 @@ const byWorktree = fn("Main.byWorktree")(function* (options, worktree) {
27285
27512
  branch: yield* nameAt(worktree)
27286
27513
  };
27287
27514
  });
27515
+ const standingIn = fn("Main.standingIn")(function* (options) {
27516
+ const standing = worktreeAbove(process.cwd());
27517
+ const branch = options["branch"];
27518
+ if (standing === void 0 || options["repo"] !== void 0) return yield* new MissingOption({ option: addressing[0]?.name ?? "worktree" });
27519
+ return branch === void 0 ? yield* byWorktree({
27520
+ ...options,
27521
+ worktree: standing
27522
+ }, standing) : yield* byHere(options, yield* repoOf(standing), branch);
27523
+ });
27288
27524
  const addressOf = fn("Main.addressOf")(function* (name, options) {
27289
27525
  if (findCommand(name)?.addresses !== "review") return options;
27290
27526
  const repo = options["repo"];
27291
27527
  const branch = options["branch"];
27292
27528
  if (repo !== void 0 && branch !== void 0) return yield* byBranch(options, repo, branch);
27293
27529
  const worktree = options["worktree"];
27294
- if (worktree !== void 0) return yield* byWorktree(options, worktree);
27295
- return yield* new MissingOption({ option: addressing[0]?.name ?? "worktree" });
27530
+ return worktree === void 0 ? yield* standingIn(options) : yield* byWorktree(options, worktree);
27296
27531
  });
27297
27532
  const RESUME_ADVICE = "Nothing has been opened here yet. Run `adiff review open --repo .` and pick a branch.";
27298
27533
  const resume = fn("Main.resume")(function* (options) {
@@ -27344,10 +27579,59 @@ const stillTaken = (name, options) => {
27344
27579
  command: name,
27345
27580
  reason: removed.reason
27346
27581
  }));
27582
+ const renames = renamedIn(name, Object.keys(options));
27347
27583
  const retired = new Set(retiredIn(name, Object.keys(options)));
27348
- return succeed$1(Object.fromEntries(Object.entries(options).filter(([key]) => !retired.has(key))));
27584
+ return succeed$1(Object.fromEntries(Object.entries(options).flatMap(([key, value]) => {
27585
+ const to = renames[key];
27586
+ if (to !== void 0) return [[to, value]];
27587
+ return retired.has(key) ? [] : [[key, value]];
27588
+ })));
27589
+ };
27590
+ const strange = (command) => (error) => {
27591
+ const didYouMean = nearestOption(command, error.option);
27592
+ return fail(new UnknownOption({
27593
+ option: error.option,
27594
+ known: optionsOf(command),
27595
+ command: command.name,
27596
+ usage: usageOf(command),
27597
+ ...didYouMean === void 0 ? {} : { didYouMean }
27598
+ }));
27599
+ };
27600
+ const withBareId = fn("Main.withBareId")(function* (command, options, bare) {
27601
+ const [first] = bare;
27602
+ if (first === void 0) return options;
27603
+ if (!takesId(command)) return yield* new UnexpectedArgument({
27604
+ argument: first,
27605
+ command: command.name,
27606
+ usage: usageOf(command)
27607
+ });
27608
+ if (bare.length > 1) return yield* new SeveralIds({
27609
+ ids: bare,
27610
+ command: command.name
27611
+ });
27612
+ const id = options["id"];
27613
+ if (id !== void 0) return yield* new IdGivenTwice({
27614
+ bare: first,
27615
+ id,
27616
+ command: command.name
27617
+ });
27618
+ return {
27619
+ ...options,
27620
+ id: first
27621
+ };
27622
+ });
27623
+ const optionsAsked = fn("Main.optionsAsked")(function* (command, args) {
27624
+ const rest = args.slice(command.name.split(" ").length);
27625
+ const valued = valuedIn(command.name);
27626
+ const kept = yield* stillTaken(command.name, optionsFrom(rest, valued));
27627
+ const options = yield* onlyKnown(kept, knownIn(command.name)).pipe(catchTag("UnknownOption", strange(command)));
27628
+ return yield* withBareId(command, options, bareIn(rest, valued));
27629
+ });
27630
+ const run = (name, args) => {
27631
+ const command = findCommand(name);
27632
+ if (command === void 0) return fail(unknown(name));
27633
+ return optionsAsked(command, args).pipe(flatMap((options) => dispatch(name, options)), catchTag("MissingOption", wanting(name)));
27349
27634
  };
27350
- const run = (name, options) => stillTaken(name, options).pipe(flatMap((kept) => onlyKnown(kept, knownIn(name)).pipe(flatMap(() => dispatch(name, kept)))), catchTag("MissingOption", wanting(name)));
27351
27635
  const leading = (argv) => {
27352
27636
  const stop = argv.findIndex((token) => token.startsWith("-"));
27353
27637
  return stop === -1 ? argv : argv.slice(0, stop);
@@ -27359,8 +27643,8 @@ const nameOf = (argv) => {
27359
27643
  return words.length > 1 ? pair : words[0] ?? "";
27360
27644
  };
27361
27645
  const storeRoot = () => process.env["ADIFF_ROOT"] ?? defaultRoot();
27362
- const folderOf = fn("Main.folderOf")(function* (given) {
27363
- const options = yield* addressOf("comment list", given);
27646
+ const folderOf = fn("Main.folderOf")(function* (args) {
27647
+ const options = yield* addressOf("comment list", optionsFrom(args, valuedIn("comment list")));
27364
27648
  const worktree = yield* find(yield* required(options, "repo"), yield* required(options, "branch"));
27365
27649
  return branchDir(storeRoot(), yield* branchKeyOf(worktree.path));
27366
27650
  });
@@ -27403,8 +27687,13 @@ const reportFailure = (cause) => sync(() => {
27403
27687
  process.stderr.write(`${reported.line}\n`);
27404
27688
  process.exitCode = reported.exit;
27405
27689
  });
27406
- const asked = opening ? "review open" : nameOf(argv);
27407
- const started = asked === "serve" ? serving() : run(asked, opening ? { repo: "." } : optionsFrom(argv, valuedIn(asked)));
27690
+ const called = opening ? "review open" : nameOf(argv);
27691
+ const started = called === "serve" ? serving() : run(called, opening ? [
27692
+ "review",
27693
+ "open",
27694
+ "--repo",
27695
+ "."
27696
+ ] : argv);
27408
27697
  runFork(started.pipe(provide(layer), catchCause(reportFailure)));
27409
27698
  //#endregion
27410
27699
  export {};