@eliya-oss/agent-diff 0.1.0-alpha.35 → 0.1.0-alpha.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/main.js +245 -65
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.37
4
+
5
+ ### Patch Changes
6
+
7
+ - The footer carries the keys a review is made of, and ? lists every key the screen answers to.
8
+
9
+ ## 0.1.0-alpha.36
10
+
11
+ ### Patch Changes
12
+
13
+ - A review belongs to the branch it describes, the worktree list names the repository it opened and marks where you are, and the pull request opens from the list.
14
+
3
15
  ## 0.1.0-alpha.35
4
16
 
5
17
  ### Patch Changes
package/dist/main.js CHANGED
@@ -7737,7 +7737,7 @@ var init_run = __esmMin((() => {
7737
7737
  }));
7738
7738
  //#endregion
7739
7739
  //#region src/service/git/service.ts
7740
- var GREP_CONTEXT, DEFAULT_BRANCH_CANDIDATES, STAT, Git, parseStat, readEntries, baseNames, mergeBases, findDefaultBranch, defaultBranch, mergeBaseOf, toWorktree, splitLines, absent, readText, shape, GitLive;
7740
+ var GREP_CONTEXT, DEFAULT_BRANCH_CANDIDATES, STAT, Git, parseStat, readEntries, baseNames, mergeBases, findDefaultBranch, defaultBranch, mergeBaseOf, toWorktree, splitLines, absent, readText, settled, shape, GitLive;
7741
7741
  var init_service$2 = __esmMin((() => {
7742
7742
  init_dist();
7743
7743
  init_error$3();
@@ -7829,6 +7829,7 @@ var init_service$2 = __esmMin((() => {
7829
7829
  })
7830
7830
  }).pipe(map(some), catchTag("FileUnreadable", () => absent));
7831
7831
  });
7832
+ settled = (path) => promise(() => realpath(path).catch(() => resolve(path)));
7832
7833
  shape = {
7833
7834
  worktrees: fn("Git.worktrees")(function* (repo) {
7834
7835
  const porcelain = yield* gitOrEmpty(repo, [
@@ -7838,8 +7839,12 @@ var init_service$2 = __esmMin((() => {
7838
7839
  ]);
7839
7840
  const base = yield* defaultBranch(repo);
7840
7841
  const entries = readEntries(porcelain);
7842
+ const opened = yield* settled(repo);
7841
7843
  const found = [];
7842
- for (const [index, entry] of entries.entries()) found.push(yield* toWorktree(entry, base, index === 0));
7844
+ for (const entry of entries) {
7845
+ const path = yield* settled(entry.path);
7846
+ found.push(yield* toWorktree(entry, base, path === opened));
7847
+ }
7843
7848
  return found;
7844
7849
  }),
7845
7850
  diff: fn("Git.diff")(function* (worktree, context) {
@@ -8029,7 +8034,7 @@ var init_paths = __esmMin((() => {
8029
8034
  settingsPath = (root) => join(root, "settings.json");
8030
8035
  reportsDir = (root) => join(root, "reports");
8031
8036
  reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
8032
- })), Store, ensureDir, readOptional, missing, damaged, jsonOf, decoded, asSettings, asBatch, asAnswer, asState, asLayers, linesOf, readLines, parseSettings, parseState, parseLayers, cursorOps, settingsOps, reportOps, answerOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
8037
+ })), Store, ensureDir, readOptional, missing, damaged, jsonOf, decoded, asSettings, asBatch, asAnswer, asState, asLayers, linesOf, readLines, parseSettings, parseState, parseLayers, cursorOps, settingsOps, reportOps, HEAD_REF, headOf$1, keyOf$2, answerOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
8033
8038
  var init_service$1 = __esmMin((() => {
8034
8039
  init_dist();
8035
8040
  init_error$2();
@@ -8173,11 +8178,21 @@ var init_service$1 = __esmMin((() => {
8173
8178
  });
8174
8179
  return path;
8175
8180
  });
8181
+ HEAD_REF = /^ref:\s*refs\/heads\/(.+)$/;
8182
+ headOf$1 = (worktreePath) => readFile(join(worktreePath, ".git"), "utf8").then((raw) => {
8183
+ const linked = raw.match(/^gitdir:\s*(.+)$/m);
8184
+ return linked?.[1] === void 0 ? join(worktreePath, ".git") : linked[1].trim();
8185
+ }).catch(() => join(worktreePath, ".git")).then((dir) => readFile(join(dir, "HEAD"), "utf8")).then((raw) => {
8186
+ const named = raw.trim().match(HEAD_REF);
8187
+ return named?.[1] === void 0 ? raw.trim() : named[1];
8188
+ }).catch(() => "");
8189
+ keyOf$2 = (worktreePath) => promise(() => headOf$1(worktreePath).then((head) => `${worktreePath}#${head}`));
8176
8190
  answerOps = (root) => {
8177
8191
  return {
8178
8192
  answer: fn("Store.answer")(function* (worktreePath, entry) {
8179
- const path = outboxPath(root, worktreePath);
8180
- yield* ensureDir(branchDir(root, worktreePath));
8193
+ const key = yield* keyOf$2(worktreePath);
8194
+ const path = outboxPath(root, key);
8195
+ yield* ensureDir(branchDir(root, key));
8181
8196
  yield* tryPromise({
8182
8197
  try: () => appendFile(path, `${JSON.stringify(entry)}\n`, "utf8"),
8183
8198
  catch: (cause) => new StoreUnwritable({
@@ -8187,7 +8202,8 @@ var init_service$1 = __esmMin((() => {
8187
8202
  });
8188
8203
  }),
8189
8204
  answers: fn("Store.answers")(function* (worktreePath) {
8190
- const path = outboxPath(root, worktreePath);
8205
+ const key = yield* keyOf$2(worktreePath);
8206
+ const path = outboxPath(root, key);
8191
8207
  const raw = yield* readOptional(path);
8192
8208
  return yield* match$3(raw, {
8193
8209
  onNone: () => succeed([]),
@@ -8199,14 +8215,16 @@ var init_service$1 = __esmMin((() => {
8199
8215
  layersOps = (root) => {
8200
8216
  return {
8201
8217
  layers: fn("Store.layers")(function* (worktreePath) {
8202
- const path = layersPath(root, worktreePath);
8218
+ const key = yield* keyOf$2(worktreePath);
8219
+ const path = layersPath(root, key);
8203
8220
  const raw = yield* readOptional(path);
8204
8221
  if (isNone(raw)) return none();
8205
8222
  return some(yield* parseLayers(path, raw.value));
8206
8223
  }),
8207
8224
  saveLayers: fn("Store.saveLayers")(function* (worktreePath, next) {
8208
- const path = layersPath(root, worktreePath);
8209
- yield* ensureDir(branchDir(root, worktreePath));
8225
+ const key = yield* keyOf$2(worktreePath);
8226
+ const path = layersPath(root, key);
8227
+ yield* ensureDir(branchDir(root, key));
8210
8228
  yield* tryPromise({
8211
8229
  try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
8212
8230
  catch: (cause) => new StoreUnwritable({
@@ -8220,8 +8238,9 @@ var init_service$1 = __esmMin((() => {
8220
8238
  inboxOps = (root) => {
8221
8239
  return {
8222
8240
  submit: fn("Store.submit")(function* (worktreePath, batch) {
8223
- const path = inboxPath(root, worktreePath);
8224
- yield* ensureDir(branchDir(root, worktreePath));
8241
+ const key = yield* keyOf$2(worktreePath);
8242
+ const path = inboxPath(root, key);
8243
+ yield* ensureDir(branchDir(root, key));
8225
8244
  yield* tryPromise({
8226
8245
  try: () => appendFile(path, `${JSON.stringify(batch)}\n`, "utf8"),
8227
8246
  catch: (cause) => new StoreUnwritable({
@@ -8231,7 +8250,8 @@ var init_service$1 = __esmMin((() => {
8231
8250
  });
8232
8251
  }),
8233
8252
  inbox: fn("Store.inbox")(function* (worktreePath) {
8234
- const path = inboxPath(root, worktreePath);
8253
+ const key = yield* keyOf$2(worktreePath);
8254
+ const path = inboxPath(root, key);
8235
8255
  const raw = yield* readOptional(path);
8236
8256
  return yield* match$3(raw, {
8237
8257
  onNone: () => succeed([]),
@@ -8243,7 +8263,8 @@ var init_service$1 = __esmMin((() => {
8243
8263
  stateOps = (root) => {
8244
8264
  return {
8245
8265
  state: fn("Store.state")(function* (worktreePath) {
8246
- const path = statePath(root, worktreePath);
8266
+ const key = yield* keyOf$2(worktreePath);
8267
+ const path = statePath(root, key);
8247
8268
  const raw = yield* readOptional(path);
8248
8269
  return yield* match$3(raw, {
8249
8270
  onNone: () => succeed(emptyBranchState),
@@ -8251,8 +8272,9 @@ var init_service$1 = __esmMin((() => {
8251
8272
  });
8252
8273
  }),
8253
8274
  saveState: fn("Store.saveState")(function* (worktreePath, next) {
8254
- const path = statePath(root, worktreePath);
8255
- yield* ensureDir(branchDir(root, worktreePath));
8275
+ const key = yield* keyOf$2(worktreePath);
8276
+ const path = statePath(root, key);
8277
+ yield* ensureDir(branchDir(root, key));
8256
8278
  yield* tryPromise({
8257
8279
  try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
8258
8280
  catch: (cause) => new StoreUnwritable({
@@ -9884,7 +9906,7 @@ var init_error = __esmMin((() => {
9884
9906
  }));
9885
9907
  //#endregion
9886
9908
  //#region src/service/forge/service.ts
9887
- var Forge, LIMIT, TIMEOUT_MS, FIELDS, Row, decode, stateOf, ask, read, pulls, ForgeLive;
9909
+ var Forge, LIMIT, TIMEOUT_MS, FIELDS, Row, decode, stateOf, ask, show, read, pulls, openPull, ForgeLive;
9888
9910
  var init_service = __esmMin((() => {
9889
9911
  init_dist();
9890
9912
  init_error();
@@ -9926,6 +9948,24 @@ var init_service = __esmMin((() => {
9926
9948
  })));
9927
9949
  });
9928
9950
  });
9951
+ show = (repo, branch) => callback$1((resume) => {
9952
+ execFile("gh", [
9953
+ "pr",
9954
+ "view",
9955
+ branch,
9956
+ "--web"
9957
+ ], {
9958
+ cwd: repo,
9959
+ timeout: TIMEOUT_MS,
9960
+ encoding: "utf8"
9961
+ }, (error) => {
9962
+ if (error === null) return resume(void_);
9963
+ resume(fail(new ForgeUnavailable({
9964
+ repo,
9965
+ reason: error.message
9966
+ })));
9967
+ });
9968
+ });
9929
9969
  read = fn("Forge.read")(function* (repo, raw) {
9930
9970
  const parsed = yield* try_({
9931
9971
  try: () => JSON.parse(raw),
@@ -9946,7 +9986,13 @@ var init_service = __esmMin((() => {
9946
9986
  const raw = yield* ask(repo);
9947
9987
  return yield* read(repo, raw);
9948
9988
  });
9949
- ForgeLive = succeed$1(Forge)({ pulls });
9989
+ openPull = fn("Forge.openPull")(function* (repo, branch) {
9990
+ yield* show(repo, branch);
9991
+ });
9992
+ ForgeLive = succeed$1(Forge)({
9993
+ pulls,
9994
+ openPull
9995
+ });
9950
9996
  }));
9951
9997
  //#endregion
9952
9998
  //#region src/service/forge/index.ts
@@ -10704,7 +10750,7 @@ var init_watch = __esmMin((() => {
10704
10750
  }));
10705
10751
  //#endregion
10706
10752
  //#region src/tui/command.ts
10707
- var command, commands, TEXT_SCREENS, PRINTABLE_KEY, takesText, commandsFor, listableFor, actionFor, GLYPHS, displayKey, hintsFor;
10753
+ var command, commands, TEXT_SCREENS, PRINTABLE_KEY, takesText, commandsFor, listableFor, glossaryFor, actionFor, GLYPHS, displayKey, hintsFor;
10708
10754
  var init_command = __esmMin((() => {
10709
10755
  command = (input) => ({
10710
10756
  category: "Review",
@@ -10713,6 +10759,8 @@ var init_command = __esmMin((() => {
10713
10759
  whenStaged: false,
10714
10760
  counted: false,
10715
10761
  whenLayers: false,
10762
+ whenThread: false,
10763
+ rank: 0,
10716
10764
  ...input
10717
10765
  });
10718
10766
  commands = [
@@ -10722,7 +10770,8 @@ var init_command = __esmMin((() => {
10722
10770
  category: "Branches",
10723
10771
  keys: ["down", "j"],
10724
10772
  screens: ["branches"],
10725
- hint: "move"
10773
+ hint: "move",
10774
+ rank: 1
10726
10775
  }),
10727
10776
  command({
10728
10777
  action: "branch.prev",
@@ -10737,14 +10786,22 @@ var init_command = __esmMin((() => {
10737
10786
  category: "Branches",
10738
10787
  keys: ["return"],
10739
10788
  screens: ["branches"],
10740
- hint: "review"
10789
+ hint: "review",
10790
+ rank: 2
10791
+ }),
10792
+ command({
10793
+ action: "branch.pull",
10794
+ title: "Open the pull request in a browser",
10795
+ category: "Branches",
10796
+ keys: ["p"],
10797
+ screens: ["branches"],
10798
+ hint: "pull request"
10741
10799
  }),
10742
10800
  command({
10743
10801
  action: "cursor.next",
10744
10802
  title: "Next line",
10745
10803
  keys: ["down", "j"],
10746
- screens: ["review"],
10747
- hint: "line"
10804
+ screens: ["review"]
10748
10805
  }),
10749
10806
  command({
10750
10807
  action: "cursor.prev",
@@ -10793,7 +10850,6 @@ var init_command = __esmMin((() => {
10793
10850
  title: "Next comment",
10794
10851
  keys: ["n"],
10795
10852
  screens: ["review"],
10796
- hint: "next comment",
10797
10853
  whenStaged: true
10798
10854
  }),
10799
10855
  command({
@@ -10820,7 +10876,8 @@ var init_command = __esmMin((() => {
10820
10876
  category: "Files",
10821
10877
  keys: ["]"],
10822
10878
  screens: ["review"],
10823
- hint: "file"
10879
+ hint: "file",
10880
+ rank: 1
10824
10881
  }),
10825
10882
  command({
10826
10883
  action: "file.prev",
@@ -10841,8 +10898,7 @@ var init_command = __esmMin((() => {
10841
10898
  title: "Hide the file list",
10842
10899
  category: "General",
10843
10900
  keys: ["z", "\\"],
10844
- screens: ["review"],
10845
- hint: "zoom"
10901
+ screens: ["review"]
10846
10902
  }),
10847
10903
  command({
10848
10904
  action: "branch.first",
@@ -10868,23 +10924,20 @@ var init_command = __esmMin((() => {
10868
10924
  action: "selection.copy",
10869
10925
  title: "Copy the selection",
10870
10926
  keys: ["y"],
10871
- screens: ["review"],
10872
- hint: "copy"
10927
+ screens: ["review"]
10873
10928
  }),
10874
10929
  command({
10875
10930
  action: "search.open",
10876
10931
  title: "Find the selection elsewhere",
10877
10932
  keys: ["/"],
10878
- screens: ["review"],
10879
- hint: "find"
10933
+ screens: ["review"]
10880
10934
  }),
10881
10935
  command({
10882
10936
  action: "match.next",
10883
10937
  title: "Next match",
10884
10938
  category: "Search",
10885
10939
  keys: ["j", "down"],
10886
- screens: ["search"],
10887
- hint: "move"
10940
+ screens: ["search"]
10888
10941
  }),
10889
10942
  command({
10890
10943
  action: "match.prev",
@@ -10899,7 +10952,8 @@ var init_command = __esmMin((() => {
10899
10952
  category: "Search",
10900
10953
  keys: ["return"],
10901
10954
  screens: ["search"],
10902
- hint: "open"
10955
+ hint: "open",
10956
+ rank: 2
10903
10957
  }),
10904
10958
  command({
10905
10959
  action: "select.swap",
@@ -10912,8 +10966,7 @@ var init_command = __esmMin((() => {
10912
10966
  title: "Wrap long lines",
10913
10967
  category: "General",
10914
10968
  keys: ["w"],
10915
- screens: ["review"],
10916
- hint: "wrap"
10969
+ screens: ["review"]
10917
10970
  }),
10918
10971
  command({
10919
10972
  action: "pan.right",
@@ -10927,13 +10980,21 @@ var init_command = __esmMin((() => {
10927
10980
  keys: ["<"],
10928
10981
  screens: ["review"]
10929
10982
  }),
10983
+ command({
10984
+ action: "review.reload",
10985
+ title: "Read the worktrees again",
10986
+ category: "Branches",
10987
+ keys: ["r"],
10988
+ screens: ["branches"],
10989
+ hint: "reload",
10990
+ rank: 3
10991
+ }),
10930
10992
  command({
10931
10993
  action: "review.reload",
10932
10994
  title: "Read the branch again",
10933
10995
  category: "Review",
10934
10996
  keys: ["r"],
10935
- screens: ["branches", "review"],
10936
- hint: "reload"
10997
+ screens: ["review"]
10937
10998
  }),
10938
10999
  command({
10939
11000
  action: "thread.settle",
@@ -10941,7 +11002,8 @@ var init_command = __esmMin((() => {
10941
11002
  category: "Review",
10942
11003
  keys: ["d"],
10943
11004
  screens: ["review"],
10944
- hint: "settle"
11005
+ hint: "settle",
11006
+ whenThread: true
10945
11007
  }),
10946
11008
  command({
10947
11009
  action: "thread.remove",
@@ -10957,6 +11019,7 @@ var init_command = __esmMin((() => {
10957
11019
  keys: ["s"],
10958
11020
  screens: ["review"],
10959
11021
  hint: "layers",
11022
+ rank: 2,
10960
11023
  whenLayers: true
10961
11024
  }),
10962
11025
  command({
@@ -10979,7 +11042,8 @@ var init_command = __esmMin((() => {
10979
11042
  category: "Files",
10980
11043
  keys: ["m"],
10981
11044
  screens: ["review"],
10982
- hint: "reviewed"
11045
+ hint: "reviewed",
11046
+ rank: 2
10983
11047
  }),
10984
11048
  command({
10985
11049
  action: "file.vouch.next",
@@ -10993,14 +11057,16 @@ var init_command = __esmMin((() => {
10993
11057
  title: "Start a selection",
10994
11058
  keys: ["v"],
10995
11059
  screens: ["review"],
10996
- hint: "select"
11060
+ hint: "select",
11061
+ rank: 3
10997
11062
  }),
10998
11063
  command({
10999
11064
  action: "compose.open",
11000
11065
  title: "Comment on the selection",
11001
11066
  keys: ["c", "return"],
11002
11067
  screens: ["review"],
11003
- hint: "comment"
11068
+ hint: "comment",
11069
+ rank: 4
11004
11070
  }),
11005
11071
  command({
11006
11072
  action: "report.open",
@@ -11023,7 +11089,6 @@ var init_command = __esmMin((() => {
11023
11089
  category: "General",
11024
11090
  keys: ["ctrl+p"],
11025
11091
  screens: ["review", "pending"],
11026
- hint: "commands",
11027
11092
  listed: false
11028
11093
  }),
11029
11094
  command({
@@ -11041,7 +11106,8 @@ var init_command = __esmMin((() => {
11041
11106
  screens: ["review"],
11042
11107
  hint: "send",
11043
11108
  whenStaged: true,
11044
- counted: true
11109
+ counted: true,
11110
+ rank: 6
11045
11111
  }),
11046
11112
  command({
11047
11113
  action: "pending.submit",
@@ -11049,7 +11115,8 @@ var init_command = __esmMin((() => {
11049
11115
  keys: ["ctrl+s"],
11050
11116
  screens: ["pending"],
11051
11117
  hint: "send",
11052
- listed: false
11118
+ listed: false,
11119
+ rank: 2
11053
11120
  }),
11054
11121
  command({
11055
11122
  action: "pending.edit",
@@ -11057,7 +11124,8 @@ var init_command = __esmMin((() => {
11057
11124
  category: "Review",
11058
11125
  keys: ["e"],
11059
11126
  screens: ["pending"],
11060
- hint: "reword"
11127
+ hint: "reword",
11128
+ rank: 3
11061
11129
  }),
11062
11130
  command({
11063
11131
  action: "pending.drop",
@@ -11065,7 +11133,8 @@ var init_command = __esmMin((() => {
11065
11133
  category: "Review",
11066
11134
  keys: ["X"],
11067
11135
  screens: ["pending"],
11068
- hint: "withdraw"
11136
+ hint: "withdraw",
11137
+ rank: 4
11069
11138
  }),
11070
11139
  command({
11071
11140
  action: "pending.next",
@@ -11100,10 +11169,41 @@ var init_command = __esmMin((() => {
11100
11169
  action: "palette.run",
11101
11170
  title: "Run the highlighted command",
11102
11171
  keys: ["return"],
11103
- screens: ["palette"],
11172
+ screens: ["palette", "keys"],
11104
11173
  hint: "run",
11105
11174
  listed: false
11106
11175
  }),
11176
+ command({
11177
+ action: "keys.open",
11178
+ title: "List every key",
11179
+ category: "General",
11180
+ keys: ["?"],
11181
+ screens: [
11182
+ "branches",
11183
+ "review",
11184
+ "pending",
11185
+ "search"
11186
+ ],
11187
+ hint: "keys",
11188
+ rank: 5,
11189
+ listed: false
11190
+ }),
11191
+ command({
11192
+ action: "keys.next",
11193
+ title: "Next key",
11194
+ category: "General",
11195
+ keys: ["down", "j"],
11196
+ screens: ["keys"],
11197
+ listed: false
11198
+ }),
11199
+ command({
11200
+ action: "keys.prev",
11201
+ title: "Previous key",
11202
+ category: "General",
11203
+ keys: ["up", "k"],
11204
+ screens: ["keys"],
11205
+ listed: false
11206
+ }),
11107
11207
  command({
11108
11208
  action: "back",
11109
11209
  title: "Go back",
@@ -11115,10 +11215,12 @@ var init_command = __esmMin((() => {
11115
11215
  "palette",
11116
11216
  "pending",
11117
11217
  "report",
11118
- "search"
11218
+ "search",
11219
+ "keys"
11119
11220
  ],
11120
11221
  hint: "back",
11121
- listed: false
11222
+ listed: false,
11223
+ rank: 9
11122
11224
  }),
11123
11225
  command({
11124
11226
  action: "quit",
@@ -11127,7 +11229,8 @@ var init_command = __esmMin((() => {
11127
11229
  keys: ["q"],
11128
11230
  screens: ["branches"],
11129
11231
  hint: "quit",
11130
- listed: false
11232
+ listed: false,
11233
+ rank: 9
11131
11234
  })
11132
11235
  ];
11133
11236
  TEXT_SCREENS = /* @__PURE__ */ new Set([
@@ -11139,6 +11242,7 @@ var init_command = __esmMin((() => {
11139
11242
  takesText = (screen) => TEXT_SCREENS.has(screen);
11140
11243
  commandsFor = (screen) => commands.filter((entry) => entry.screens.includes(screen));
11141
11244
  listableFor = (screen) => commandsFor(screen).filter((entry) => entry.listed);
11245
+ glossaryFor = (screen) => commandsFor(screen).toSorted((left, right) => left.category.localeCompare(right.category) || left.title.localeCompare(right.title));
11142
11246
  actionFor = (screen, key) => {
11143
11247
  if (takesText(screen) && PRINTABLE_KEY.test(key)) return void 0;
11144
11248
  return commandsFor(screen).find((entry) => entry.keys.includes(key))?.action;
@@ -11157,7 +11261,7 @@ var init_command = __esmMin((() => {
11157
11261
  if (key.startsWith("ctrl+")) return `^${key.slice(5)}`;
11158
11262
  return GLYPHS[key] ?? key;
11159
11263
  };
11160
- hintsFor = (screen, staged, layers = 0) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenStaged || staged > 0).filter((entry) => !entry.whenLayers || layers > 0).map((entry) => ({
11264
+ hintsFor = (screen, staged, layers = 0, onThread = false) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenStaged || staged > 0).filter((entry) => !entry.whenLayers || layers > 0).filter((entry) => !entry.whenThread || onThread).toSorted((left, right) => left.rank - right.rank).map((entry) => ({
11161
11265
  key: displayKey(entry.keys[0] ?? ""),
11162
11266
  hint: entry.counted ? `${entry.hint} ${staged}` : entry.hint,
11163
11267
  press: entry.keys[0] ?? ""
@@ -11190,10 +11294,11 @@ var init_match = __esmMin((() => {
11190
11294
  }));
11191
11295
  //#endregion
11192
11296
  //#region src/tui/reduce.ts
11193
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, movePending, moveLayer, inRail, layerDown, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, movePalette, paletteMatches, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, withPending, panBy, withSent, withLayers, withPulls, withBranches, withSource, withVouched, restoredTo, withPatches, typed, backspaced, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
11297
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, atRow, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, movePending, moveLayer, inRail, layerDown, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, withPending, panBy, withSent, withLayers, withPulls, withBranches, withSource, withVouched, restoredTo, withPatches, typed, backspaced, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
11194
11298
  var init_reduce = __esmMin((() => {
11195
11299
  init_dist();
11196
11300
  init_patch();
11301
+ init_command();
11197
11302
  init_gaps();
11198
11303
  init_match();
11199
11304
  init_model();
@@ -11427,6 +11532,10 @@ var init_reduce = __esmMin((() => {
11427
11532
  screen: state.returnTo,
11428
11533
  query: ""
11429
11534
  };
11535
+ if (state.screen === "keys") return {
11536
+ ...state,
11537
+ screen: state.returnTo
11538
+ };
11430
11539
  if (state.screen === "compose") return {
11431
11540
  ...state,
11432
11541
  screen: "review",
@@ -11454,18 +11563,27 @@ var init_reduce = __esmMin((() => {
11454
11563
  query: "",
11455
11564
  paletteIndex: 0
11456
11565
  });
11566
+ openKeys = (state) => ({
11567
+ ...state,
11568
+ screen: "keys",
11569
+ returnTo: state.screen,
11570
+ query: "",
11571
+ paletteIndex: 0
11572
+ });
11457
11573
  movePalette = (state, delta) => ({
11458
11574
  ...state,
11459
- paletteIndex: clamp(state.paletteIndex + delta, 0, Math.max(0, paletteMatches(state).length - 1))
11575
+ paletteIndex: clamp(state.paletteIndex + delta, 0, Math.max(0, offered(state).length - 1))
11460
11576
  });
11461
11577
  paletteMatches = (state) => searchCommands(state.returnTo, state.query);
11462
- paletteChoice = (state) => paletteMatches(state)[state.paletteIndex]?.action;
11578
+ offered = (state) => state.screen === "keys" ? glossaryFor(state.returnTo) : paletteMatches(state);
11579
+ paletteChoice = (state) => offered(state)[state.paletteIndex]?.action;
11463
11580
  transitions = {
11464
11581
  "branch.first": (state) => atBranch(state, 0),
11465
11582
  "branch.last": (state) => atBranch(state, state.branches.length - 1),
11466
11583
  "branch.next": (state) => moveBranch(state, 1),
11467
11584
  "branch.prev": (state) => moveBranch(state, -1),
11468
11585
  "branch.open": (state) => state,
11586
+ "branch.pull": (state) => state,
11469
11587
  "cursor.next": (state) => layerDown(state, 1),
11470
11588
  "cursor.top": (state) => atRow(state, 0),
11471
11589
  "cursor.bottom": (state) => atRow(state, lastRow(selectedPatch(state))),
@@ -11529,6 +11647,9 @@ var init_reduce = __esmMin((() => {
11529
11647
  }),
11530
11648
  "report.send": (state) => state,
11531
11649
  "palette.open": openPalette,
11650
+ "keys.open": openKeys,
11651
+ "keys.next": (state) => movePalette(state, 1),
11652
+ "keys.prev": (state) => movePalette(state, -1),
11532
11653
  "palette.run": (state) => state,
11533
11654
  "search.open": (state) => state,
11534
11655
  "search.jump": (state) => state,
@@ -12310,7 +12431,7 @@ var init_diffview = __esmMin((() => {
12310
12431
  }));
12311
12432
  //#endregion
12312
12433
  //#region src/tui/render.ts
12313
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_TITLE, PALETTE_MAX, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, BODY_BORDER, PANE_CHROME, BRANCH_WIDTH, BRANCH_NAME, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, bodyRoom, treeWidth, homeWidth, modalWidth, composeRoom, laidOut, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makePendingParts, makeChoices, stack, makeBody, makeHome, makeModals, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, branchHeading, atHome, layersCell, stateCell, branchCells, headerParts, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, Screen;
12434
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_MAX, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, BODY_BORDER, PANE_CHROME, BRANCH_WIDTH, BRANCH_NAME, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, bodyRoom, treeWidth, homeWidth, commandRow, modalWidth, composeRoom, laidOut, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makePendingParts, makeChoices, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, branchHeading, atHome, layersCell, stateCell, branchCells, headerParts, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, Screen;
12314
12435
  var init_render = __esmMin((() => {
12315
12436
  init_command();
12316
12437
  init_patch();
@@ -12333,7 +12454,9 @@ var init_render = __esmMin((() => {
12333
12454
  reportActions = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
12334
12455
  actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^a")} ${fg(palette.muted)("add to review")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("comment now")}`;
12335
12456
  SNIPPET_LINES = 4;
12457
+ PALETTE_KEY = 7;
12336
12458
  PALETTE_TITLE = 34;
12459
+ PALETTE_GAP = 2;
12337
12460
  PALETTE_MAX = 18;
12338
12461
  PALETTE_CHROME = 4;
12339
12462
  PENDING_CHROME = 3;
@@ -12357,6 +12480,11 @@ var init_render = __esmMin((() => {
12357
12480
  return Math.max(0, Math.min(wanted, room - DIFF_MIN));
12358
12481
  };
12359
12482
  homeWidth = (width) => Math.max(0, Math.min(BRANCH_WIDTH, width - 2));
12483
+ commandRow = (entry, room) => {
12484
+ const key = clip(displayKey(entry.keys[0] ?? ""), 5).padEnd(PALETTE_KEY);
12485
+ const left = Math.max(1, Math.min(PALETTE_TITLE, room - PALETTE_KEY - entry.category.length - PALETTE_GAP));
12486
+ return `${key}${clip(entry.title, left - PALETTE_GAP).padEnd(left)}${entry.category}`;
12487
+ };
12360
12488
  modalWidth = (width, wanted) => Math.max(0, Math.min(wanted, width - MODAL_MARGIN));
12361
12489
  composeRoom = (width) => {
12362
12490
  const box = modalWidth(width, COMPOSE_WIDTH);
@@ -12535,8 +12663,15 @@ var init_render = __esmMin((() => {
12535
12663
  makeModals = (renderer) => ({
12536
12664
  palette: makePaletteParts(renderer),
12537
12665
  staged: makePendingParts(renderer),
12538
- found: makeFoundParts(renderer)
12666
+ found: makeFoundParts(renderer),
12667
+ keys: makeKeysParts(renderer)
12539
12668
  });
12669
+ makeKeysParts = (renderer) => {
12670
+ const parts = makePaletteParts(renderer);
12671
+ parts.box.id = "keys";
12672
+ parts.query.height = 0;
12673
+ return parts;
12674
+ };
12540
12675
  makeFoundParts = (renderer) => {
12541
12676
  const box = makePalette(renderer);
12542
12677
  const title = bar(renderer, "found-title", palette.faint);
@@ -12706,7 +12841,7 @@ var init_render = __esmMin((() => {
12706
12841
  layers: "LAYERS",
12707
12842
  state: "STATE"
12708
12843
  }, room)}`;
12709
- atHome = (state) => state.screen === "branches" || state.screen === "palette" && state.returnTo === "branches";
12844
+ atHome = (state) => state.screen === "branches" || (state.screen === "palette" || state.screen === "keys") && state.returnTo === "branches";
12710
12845
  layersCell = (branch) => {
12711
12846
  if (branch.layers === 0) return "";
12712
12847
  return branch.stale ? `${branch.layers} stale` : `${branch.layers} layers`;
@@ -12815,6 +12950,9 @@ var init_render = __esmMin((() => {
12815
12950
  paletteQuery;
12816
12951
  paletteChoices;
12817
12952
  pending;
12953
+ keys;
12954
+ keysTitle;
12955
+ keysChoices;
12818
12956
  pendingTitle;
12819
12957
  pendingChoices;
12820
12958
  found;
@@ -12858,6 +12996,9 @@ var init_render = __esmMin((() => {
12858
12996
  this.paletteTitle = modals.palette.title;
12859
12997
  this.paletteQuery = modals.palette.query;
12860
12998
  this.paletteChoices = modals.palette.choices;
12999
+ this.keys = modals.keys.box;
13000
+ this.keysTitle = modals.keys.title;
13001
+ this.keysChoices = modals.keys.choices;
12861
13002
  this.pending = modals.staged.box;
12862
13003
  this.pendingTitle = modals.staged.title;
12863
13004
  this.pendingChoices = modals.staged.choices;
@@ -12901,7 +13042,7 @@ var init_render = __esmMin((() => {
12901
13042
  }
12902
13043
  update(state) {
12903
13044
  this.shown = state;
12904
- this.chips = hintsFor(state.screen, state.staged, state.layers.length);
13045
+ this.chips = hintsFor(state.screen, state.staged, state.layers.length, state.stop > 0);
12905
13046
  this.header.content = this.headerText(state);
12906
13047
  this.footer.content = this.footerText(state);
12907
13048
  this.list.content = this.listText(state);
@@ -12910,11 +13051,12 @@ var init_render = __esmMin((() => {
12910
13051
  const room = Math.max(HOME_PATH_MIN, pane - many.length - HOME_PATH_CHROME);
12911
13052
  this.landing.content = `${elide(shortPath(this.repo), room)} · ${many}`;
12912
13053
  this.landingKeys.content = this.homeKeys(state);
12913
- this.diffPane.visible = state.screen !== "branches" && !(state.screen === "palette" && state.returnTo === "branches");
13054
+ this.diffPane.visible = state.screen !== "branches" && !atHome(state);
12914
13055
  if (this.diffPane.visible) this.paintDiff(state);
12915
13056
  this.paintPane(state);
12916
13057
  this.paintCompose(state);
12917
13058
  this.paintPalette(state);
13059
+ this.paintKeys(state);
12918
13060
  this.paintPending(state);
12919
13061
  this.paintFound(state);
12920
13062
  this.paintReport(state);
@@ -12931,18 +13073,39 @@ var init_render = __esmMin((() => {
12931
13073
  const matches = paletteMatches(state);
12932
13074
  this.paletteTitle.content = matches.length === 0 ? "No command matches" : "Commands";
12933
13075
  this.paletteQuery.content = state.query.length === 0 ? "Type to filter…" : `${state.query}▏`;
13076
+ const room = modalWidth(this.renderer.width, PALETTE_WIDTH);
12934
13077
  this.paletteChoices.options = matches.map((entry) => ({
12935
- name: `${clip(entry.title, 32).padEnd(PALETTE_TITLE)}${entry.category}`,
13078
+ name: commandRow(entry, room - MODAL_ROOM),
12936
13079
  description: "",
12937
13080
  value: entry.action
12938
13081
  }));
12939
- const room = modalWidth(this.renderer.width, PALETTE_WIDTH);
12940
13082
  this.paletteChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, matches.length - 1));
12941
13083
  this.palette.height = Math.min(PALETTE_MAX, matches.length + PALETTE_CHROME);
12942
13084
  this.palette.width = room;
12943
13085
  this.palette.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
12944
13086
  this.palette.top = Math.max(2, Math.floor(this.renderer.height / 4));
12945
13087
  }
13088
+ paintKeys(state) {
13089
+ this.keys.visible = state.screen === "keys";
13090
+ if (state.screen !== "keys") {
13091
+ this.keysTitle.content = "";
13092
+ this.keysChoices.options = [];
13093
+ return;
13094
+ }
13095
+ const rows = glossaryFor(state.returnTo);
13096
+ const room = modalWidth(this.renderer.width, PALETTE_WIDTH);
13097
+ this.keysTitle.content = `Every key here, ${rows.length} of them`;
13098
+ this.keysChoices.options = rows.map((entry) => ({
13099
+ name: commandRow(entry, room - MODAL_ROOM),
13100
+ description: "",
13101
+ value: entry.action
13102
+ }));
13103
+ this.keysChoices.selectedIndex = Math.min(state.paletteIndex, Math.max(0, rows.length - 1));
13104
+ this.keys.height = Math.min(PALETTE_MAX, rows.length + PENDING_CHROME);
13105
+ this.keys.width = room;
13106
+ this.keys.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room) / 2));
13107
+ this.keys.top = Math.max(2, Math.floor(this.renderer.height / 4));
13108
+ }
12946
13109
  headerText(state) {
12947
13110
  const branch = selectedBranch(state);
12948
13111
  if (atHome(state)) return t`${fg(palette.faint)("")}`;
@@ -13052,7 +13215,8 @@ var init_render = __esmMin((() => {
13052
13215
  this.compose,
13053
13216
  this.palette,
13054
13217
  this.pending,
13055
- this.found
13218
+ this.found,
13219
+ this.keys
13056
13220
  ]);
13057
13221
  }
13058
13222
  watchChips() {
@@ -13106,11 +13270,13 @@ var init_render = __esmMin((() => {
13106
13270
  if (this.shown !== void 0) this.footer.content = this.footerText(this.shown);
13107
13271
  }
13108
13272
  homeKeys(state) {
13109
- const chips = this.chipRow().chunks;
13110
13273
  const said = state.notice.length === 0 ? state.waiting : state.notice;
13111
- if (said.length === 0) return new StyledText(chips);
13274
+ const tail = said.length === 0 ? "" : ` ${said}`;
13275
+ const room = Math.max(0, homeWidth(this.renderer.width) - tail.length);
13276
+ const chips = keptWithin(this.chipRow().chunks, room);
13277
+ if (tail.length === 0) return new StyledText([...chips]);
13112
13278
  const colour = state.notice.length === 0 ? palette.accent : palette.attention;
13113
- return new StyledText([...chips, fg(colour)(` ${said}`)]);
13279
+ return new StyledText([...chips, fg(colour)(tail)]);
13114
13280
  }
13115
13281
  chipRow() {
13116
13282
  return new StyledText(this.chips.flatMap((chip, index) => {
@@ -13576,6 +13742,7 @@ var init_app = __esmMin((() => {
13576
13742
  return {
13577
13743
  quit: () => sync(() => this.renderer.destroy()),
13578
13744
  "branch.open": () => this.openBranch(),
13745
+ "branch.pull": () => this.showPull(),
13579
13746
  "compose.submit": () => this.send(),
13580
13747
  "compose.stage": () => this.stage(),
13581
13748
  "palette.run": () => this.runChoice(),
@@ -13916,6 +14083,19 @@ var init_app = __esmMin((() => {
13916
14083
  loadSent(branch) {
13917
14084
  return listSent(this.repo, branch);
13918
14085
  }
14086
+ showPull() {
14087
+ return gen({ self: this }, function* () {
14088
+ const branch = selectedBranch(this.state);
14089
+ if (branch === void 0) return;
14090
+ const state = this.state.pulls[branch.branch];
14091
+ if (state === void 0) {
14092
+ this.commit(withNoticeHere(this.state, "no pull request for this branch"));
14093
+ return;
14094
+ }
14095
+ const said = (yield* (yield* map(Forge, (service) => service)).openPull(this.repo, branch.branch).pipe(as(true), catchTag("ForgeUnavailable", () => succeed(false)))) ? `opened the ${state} pull request` : "could not reach the pull request";
14096
+ this.commit(withNoticeHere(this.state, said));
14097
+ });
14098
+ }
13919
14099
  loadPulls() {
13920
14100
  return gen({ self: this }, function* () {
13921
14101
  const pulls = yield* (yield* map(Forge, (service) => service)).pulls(this.repo).pipe(catchTag("ForgeUnavailable", () => succeed([])));
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.35",
26
+ "version": "0.1.0-alpha.37",
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": {