@eliya-oss/agent-diff 0.1.0-alpha.34 → 0.1.0-alpha.36

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 +239 -44
  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.36
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+
9
+ ## 0.1.0-alpha.35
10
+
11
+ ### Patch Changes
12
+
13
+ - A comment can be removed from the review and restored, and the record keeps it either way.
14
+
3
15
  ## 0.1.0-alpha.34
4
16
 
5
17
  ### Patch Changes
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { appendFile, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
3
3
  import { text } from "node:stream/consumers";
4
- import { dirname, join } from "node:path";
4
+ import { dirname, join, resolve } from "node:path";
5
5
  import { execFile } from "node:child_process";
6
6
  import { promisify } from "node:util";
7
7
  import { homedir, hostname, platform } from "node:os";
@@ -4028,12 +4028,12 @@ var init_Effect = __esmMin((() => {
4028
4028
  //#endregion
4029
4029
  //#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/internal/schema/annotations.js
4030
4030
  /** @internal */
4031
- function resolve$1(ast) {
4031
+ function resolve$2(ast) {
4032
4032
  return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
4033
4033
  }
4034
4034
  /** @internal */
4035
4035
  function resolveAt(key) {
4036
- return (ast) => resolve$1(ast)?.[key];
4036
+ return (ast) => resolve$2(ast)?.[key];
4037
4037
  }
4038
4038
  var SENTINELS_ANNOTATION_KEY, resolveIdentifier, resolveBrands, getExpected;
4039
4039
  var init_annotations = __esmMin((() => {
@@ -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) {
@@ -7946,7 +7951,8 @@ var init_model$2 = __esmMin((() => {
7946
7951
  vouches: {},
7947
7952
  consumed: 0,
7948
7953
  pending: [],
7949
- settled: {}
7954
+ settled: {},
7955
+ removed: {}
7950
7956
  };
7951
7957
  }));
7952
7958
  //#endregion
@@ -7985,7 +7991,8 @@ var init_schema = __esmMin((() => {
7985
7991
  vouches: optionalKey(Record(String$1, String$1)),
7986
7992
  consumed: optionalKey(Int),
7987
7993
  pending: optionalKey(ArraySchema(StoredComment)),
7988
- settled: optionalKey(Record(String$1, String$1))
7994
+ settled: optionalKey(Record(String$1, String$1)),
7995
+ removed: optionalKey(Record(String$1, String$1))
7989
7996
  });
7990
7997
  Settings = Struct({ wrap: optionalKey(Boolean) });
7991
7998
  Prose = Struct({
@@ -8027,7 +8034,7 @@ var init_paths = __esmMin((() => {
8027
8034
  settingsPath = (root) => join(root, "settings.json");
8028
8035
  reportsDir = (root) => join(root, "reports");
8029
8036
  reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
8030
- })), 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;
8031
8038
  var init_service$1 = __esmMin((() => {
8032
8039
  init_dist();
8033
8040
  init_error$2();
@@ -8171,11 +8178,21 @@ var init_service$1 = __esmMin((() => {
8171
8178
  });
8172
8179
  return path;
8173
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}`));
8174
8190
  answerOps = (root) => {
8175
8191
  return {
8176
8192
  answer: fn("Store.answer")(function* (worktreePath, entry) {
8177
- const path = outboxPath(root, worktreePath);
8178
- yield* ensureDir(branchDir(root, worktreePath));
8193
+ const key = yield* keyOf$2(worktreePath);
8194
+ const path = outboxPath(root, key);
8195
+ yield* ensureDir(branchDir(root, key));
8179
8196
  yield* tryPromise({
8180
8197
  try: () => appendFile(path, `${JSON.stringify(entry)}\n`, "utf8"),
8181
8198
  catch: (cause) => new StoreUnwritable({
@@ -8185,7 +8202,8 @@ var init_service$1 = __esmMin((() => {
8185
8202
  });
8186
8203
  }),
8187
8204
  answers: fn("Store.answers")(function* (worktreePath) {
8188
- const path = outboxPath(root, worktreePath);
8205
+ const key = yield* keyOf$2(worktreePath);
8206
+ const path = outboxPath(root, key);
8189
8207
  const raw = yield* readOptional(path);
8190
8208
  return yield* match$3(raw, {
8191
8209
  onNone: () => succeed([]),
@@ -8197,14 +8215,16 @@ var init_service$1 = __esmMin((() => {
8197
8215
  layersOps = (root) => {
8198
8216
  return {
8199
8217
  layers: fn("Store.layers")(function* (worktreePath) {
8200
- const path = layersPath(root, worktreePath);
8218
+ const key = yield* keyOf$2(worktreePath);
8219
+ const path = layersPath(root, key);
8201
8220
  const raw = yield* readOptional(path);
8202
8221
  if (isNone(raw)) return none();
8203
8222
  return some(yield* parseLayers(path, raw.value));
8204
8223
  }),
8205
8224
  saveLayers: fn("Store.saveLayers")(function* (worktreePath, next) {
8206
- const path = layersPath(root, worktreePath);
8207
- yield* ensureDir(branchDir(root, worktreePath));
8225
+ const key = yield* keyOf$2(worktreePath);
8226
+ const path = layersPath(root, key);
8227
+ yield* ensureDir(branchDir(root, key));
8208
8228
  yield* tryPromise({
8209
8229
  try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
8210
8230
  catch: (cause) => new StoreUnwritable({
@@ -8218,8 +8238,9 @@ var init_service$1 = __esmMin((() => {
8218
8238
  inboxOps = (root) => {
8219
8239
  return {
8220
8240
  submit: fn("Store.submit")(function* (worktreePath, batch) {
8221
- const path = inboxPath(root, worktreePath);
8222
- yield* ensureDir(branchDir(root, worktreePath));
8241
+ const key = yield* keyOf$2(worktreePath);
8242
+ const path = inboxPath(root, key);
8243
+ yield* ensureDir(branchDir(root, key));
8223
8244
  yield* tryPromise({
8224
8245
  try: () => appendFile(path, `${JSON.stringify(batch)}\n`, "utf8"),
8225
8246
  catch: (cause) => new StoreUnwritable({
@@ -8229,7 +8250,8 @@ var init_service$1 = __esmMin((() => {
8229
8250
  });
8230
8251
  }),
8231
8252
  inbox: fn("Store.inbox")(function* (worktreePath) {
8232
- const path = inboxPath(root, worktreePath);
8253
+ const key = yield* keyOf$2(worktreePath);
8254
+ const path = inboxPath(root, key);
8233
8255
  const raw = yield* readOptional(path);
8234
8256
  return yield* match$3(raw, {
8235
8257
  onNone: () => succeed([]),
@@ -8241,7 +8263,8 @@ var init_service$1 = __esmMin((() => {
8241
8263
  stateOps = (root) => {
8242
8264
  return {
8243
8265
  state: fn("Store.state")(function* (worktreePath) {
8244
- const path = statePath(root, worktreePath);
8266
+ const key = yield* keyOf$2(worktreePath);
8267
+ const path = statePath(root, key);
8245
8268
  const raw = yield* readOptional(path);
8246
8269
  return yield* match$3(raw, {
8247
8270
  onNone: () => succeed(emptyBranchState),
@@ -8249,8 +8272,9 @@ var init_service$1 = __esmMin((() => {
8249
8272
  });
8250
8273
  }),
8251
8274
  saveState: fn("Store.saveState")(function* (worktreePath, next) {
8252
- const path = statePath(root, worktreePath);
8253
- yield* ensureDir(branchDir(root, worktreePath));
8275
+ const key = yield* keyOf$2(worktreePath);
8276
+ const path = statePath(root, key);
8277
+ yield* ensureDir(branchDir(root, key));
8254
8278
  yield* tryPromise({
8255
8279
  try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
8256
8280
  catch: (cause) => new StoreUnwritable({
@@ -8507,7 +8531,7 @@ var init_commands = __esmMin((() => {
8507
8531
  const worktree = yield* findBranch(repo, branch);
8508
8532
  const spoken = yield* store.answers(worktree.path);
8509
8533
  const current = yield* store.state(worktree.path);
8510
- return flatten(yield* store.inbox(worktree.path)).map((comment) => sentOf(comment, spoken, current.settled, worktree.head));
8534
+ return flatten(yield* store.inbox(worktree.path)).filter((comment) => !Object.hasOwn(current.removed, comment.id)).map((comment) => sentOf(comment, spoken, current.settled, worktree.head));
8511
8535
  });
8512
8536
  submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
8513
8537
  const store = yield* Store;
@@ -9025,7 +9049,7 @@ var init_layers$1 = __esmMin((() => {
9025
9049
  }));
9026
9050
  //#endregion
9027
9051
  //#region src/cli/layers.ts
9028
- var STALE_ADVICE, unique, spansOfLayer, isSpan, isBlock, codeBlockOf, blocksOf, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, listLayers;
9052
+ var STALE_ADVICE, unique, spansOfLayer, isSpan, isBlock, codeBlockOf, blocksOf, layerOf, parsed, readLayers, fromStored, toStored, reportedLayers, reportOf, resolve$1, resolveAll, worktreeAt, storedLayers, setLayers, showLayers, listLayers;
9029
9053
  var init_layers = __esmMin((() => {
9030
9054
  init_dist();
9031
9055
  init_layers$1();
@@ -9136,11 +9160,11 @@ var init_layers = __esmMin((() => {
9136
9160
  layers: reportedLayers(patches, layers)
9137
9161
  };
9138
9162
  };
9139
- resolve = (path) => realpath(path).catch(() => path);
9140
- resolveAll = (paths) => Promise.all(paths.map(resolve));
9163
+ resolve$1 = (path) => realpath(path).catch(() => path);
9164
+ resolveAll = (paths) => Promise.all(paths.map(resolve$1));
9141
9165
  worktreeAt = fn("Cli.worktreeAt")(function* (worktreePath) {
9142
9166
  const git = yield* Git;
9143
- const asked = yield* promise(() => resolve(worktreePath));
9167
+ const asked = yield* promise(() => resolve$1(worktreePath));
9144
9168
  const worktrees = yield* git.worktrees(asked);
9145
9169
  const paths = worktrees.map((entry) => entry.path);
9146
9170
  const found = worktrees[(yield* promise(() => resolveAll(paths))).indexOf(asked)];
@@ -9200,14 +9224,15 @@ var init_layers = __esmMin((() => {
9200
9224
  }));
9201
9225
  //#endregion
9202
9226
  //#region src/cli/threads.ts
9203
- var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread;
9227
+ var stateOf$1, spoken$1, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleThread, removeComment, without, restoreComment;
9204
9228
  var init_threads = __esmMin((() => {
9205
9229
  init_dist();
9206
9230
  init_store();
9207
9231
  init_commands();
9208
9232
  init_layers();
9209
9233
  init_error$1();
9210
- stateOf$1 = (answers, isSettled) => {
9234
+ stateOf$1 = (answers, isSettled, isRemoved) => {
9235
+ if (isRemoved) return "removed";
9211
9236
  if (isSettled) return "done";
9212
9237
  const last = answers.at(-1);
9213
9238
  if (last === void 0) return "submitted";
@@ -9227,7 +9252,7 @@ var init_threads = __esmMin((() => {
9227
9252
  start: comment.anchor.start,
9228
9253
  end: comment.anchor.end,
9229
9254
  body: comment.body,
9230
- state: stateOf$1(mine, Object.hasOwn(reading.settled, comment.id)),
9255
+ state: stateOf$1(mine, Object.hasOwn(reading.settled, comment.id), Object.hasOwn(reading.removed, comment.id)),
9231
9256
  stale: batch.head !== reading.head,
9232
9257
  answers: mine.map(spoken$1)
9233
9258
  };
@@ -9245,6 +9270,7 @@ var init_threads = __esmMin((() => {
9245
9270
  return threadsIn(yield* store.inbox(worktree.path), {
9246
9271
  answers: yield* store.answers(worktree.path),
9247
9272
  settled: current.settled,
9273
+ removed: current.removed,
9248
9274
  head: worktree.head
9249
9275
  });
9250
9276
  });
@@ -9275,6 +9301,32 @@ var init_threads = __esmMin((() => {
9275
9301
  });
9276
9302
  return { settled: id };
9277
9303
  });
9304
+ removeComment = fn("Cli.removeComment")(function* (repo, branch, id, at) {
9305
+ const store = yield* Store;
9306
+ const worktree = yield* findBranch(repo, branch);
9307
+ if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
9308
+ const current = yield* store.state(worktree.path);
9309
+ yield* store.saveState(worktree.path, {
9310
+ ...current,
9311
+ removed: {
9312
+ ...current.removed,
9313
+ [id]: at
9314
+ }
9315
+ });
9316
+ return { removed: id };
9317
+ });
9318
+ without = (entries, id) => Object.fromEntries(Object.entries(entries).filter(([key]) => key !== id));
9319
+ restoreComment = fn("Cli.restoreComment")(function* (repo, branch, id) {
9320
+ const store = yield* Store;
9321
+ const worktree = yield* findBranch(repo, branch);
9322
+ if (!(yield* isKnown(worktree.path, id))) return yield* new UnknownComment({ id });
9323
+ const current = yield* store.state(worktree.path);
9324
+ yield* store.saveState(worktree.path, {
9325
+ ...current,
9326
+ removed: without(current.removed, id)
9327
+ });
9328
+ return { restored: id };
9329
+ });
9278
9330
  }));
9279
9331
  //#endregion
9280
9332
  //#region src/cli/parse.ts
@@ -9524,6 +9576,40 @@ var init_catalog = __esmMin((() => {
9524
9576
  dataKey: "settled",
9525
9577
  example: "adiff comment resolve --repo . --branch add-teammate-invitations --id c1"
9526
9578
  },
9579
+ {
9580
+ name: "comment remove",
9581
+ about: "Take a comment out of the review. It stays in the record as removed",
9582
+ safety: "write",
9583
+ options: [
9584
+ repo,
9585
+ branch,
9586
+ {
9587
+ name: "id",
9588
+ required: true,
9589
+ value: "id",
9590
+ about: "The comment to remove"
9591
+ }
9592
+ ],
9593
+ dataKey: "removed",
9594
+ example: "adiff comment remove --repo . --branch add-teammate-invitations --id c1"
9595
+ },
9596
+ {
9597
+ name: "comment restore",
9598
+ about: "Put a removed comment back into the review",
9599
+ safety: "write",
9600
+ options: [
9601
+ repo,
9602
+ branch,
9603
+ {
9604
+ name: "id",
9605
+ required: true,
9606
+ value: "id",
9607
+ about: "The comment to restore"
9608
+ }
9609
+ ],
9610
+ dataKey: "restored",
9611
+ example: "adiff comment restore --repo . --branch add-teammate-invitations --id c1"
9612
+ },
9527
9613
  {
9528
9614
  name: "file vouch",
9529
9615
  about: "Toggle a file as reviewed. Lapses on its own when the file changes",
@@ -9820,7 +9906,7 @@ var init_error = __esmMin((() => {
9820
9906
  }));
9821
9907
  //#endregion
9822
9908
  //#region src/service/forge/service.ts
9823
- 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;
9824
9910
  var init_service = __esmMin((() => {
9825
9911
  init_dist();
9826
9912
  init_error();
@@ -9862,6 +9948,24 @@ var init_service = __esmMin((() => {
9862
9948
  })));
9863
9949
  });
9864
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
+ });
9865
9969
  read = fn("Forge.read")(function* (repo, raw) {
9866
9970
  const parsed = yield* try_({
9867
9971
  try: () => JSON.parse(raw),
@@ -9882,7 +9986,13 @@ var init_service = __esmMin((() => {
9882
9986
  const raw = yield* ask(repo);
9883
9987
  return yield* read(repo, raw);
9884
9988
  });
9885
- 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
+ });
9886
9996
  }));
9887
9997
  //#endregion
9888
9998
  //#region src/service/forge/index.ts
@@ -10157,7 +10267,7 @@ var init_tree = __esmMin((() => {
10157
10267
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
10158
10268
  };
10159
10269
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
10160
- })), initialState, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, treeOf, treeRows, crowdedOf, directoryOfFile, isReviewed, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, editedComment, composeTarget, selectedLines, KEYWORDS, NAME, longestName, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
10270
+ })), initialState, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, treeOf, treeRows, crowdedOf, directoryOfFile, isReviewed, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, editedComment, composeTarget, selectedLines, KEYWORDS, NAME, longestName, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
10161
10271
  var init_model = __esmMin((() => {
10162
10272
  init_dist();
10163
10273
  init_patch();
@@ -10235,6 +10345,11 @@ var init_model = __esmMin((() => {
10235
10345
  if (last === void 0 || last.length + 1 + word.length > room) return [...lines, word];
10236
10346
  return [...lines.slice(0, -1), `${last} ${word}`];
10237
10347
  };
10348
+ shortened = (word, room) => word.length <= room ? word : `${word.slice(0, Math.max(1, room - 1))}\u2026`;
10349
+ wordWrapped = (text, room) => {
10350
+ const width = Math.max(1, room);
10351
+ return text.split(/\s+/).filter((word) => word.length > 0).map((word) => shortened(word, width)).reduce((lines, word) => packed(lines, word, width), []);
10352
+ };
10238
10353
  wrapped = (text, room) => {
10239
10354
  const width = Math.max(1, room);
10240
10355
  return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
@@ -10270,7 +10385,7 @@ var init_model = __esmMin((() => {
10270
10385
  }
10271
10386
  return rows;
10272
10387
  };
10273
- titleRows = (state, layerIndex, room) => wrapped(state.layers[layerIndex]?.title ?? "", room).map((text, at) => ({
10388
+ titleRows = (state, layerIndex, room) => wordWrapped(state.layers[layerIndex]?.title ?? "", room).map((text, at) => ({
10274
10389
  index: layerIndex,
10275
10390
  kind: "title",
10276
10391
  text,
@@ -10644,6 +10759,7 @@ var init_command = __esmMin((() => {
10644
10759
  whenStaged: false,
10645
10760
  counted: false,
10646
10761
  whenLayers: false,
10762
+ whenThread: false,
10647
10763
  ...input
10648
10764
  });
10649
10765
  commands = [
@@ -10670,6 +10786,14 @@ var init_command = __esmMin((() => {
10670
10786
  screens: ["branches"],
10671
10787
  hint: "review"
10672
10788
  }),
10789
+ command({
10790
+ action: "branch.pull",
10791
+ title: "Open the pull request in a browser",
10792
+ category: "Branches",
10793
+ keys: ["p"],
10794
+ screens: ["branches"],
10795
+ hint: "pull request"
10796
+ }),
10673
10797
  command({
10674
10798
  action: "cursor.next",
10675
10799
  title: "Next line",
@@ -10872,7 +10996,15 @@ var init_command = __esmMin((() => {
10872
10996
  category: "Review",
10873
10997
  keys: ["d"],
10874
10998
  screens: ["review"],
10875
- hint: "settle"
10999
+ hint: "settle",
11000
+ whenThread: true
11001
+ }),
11002
+ command({
11003
+ action: "thread.remove",
11004
+ title: "Remove the comment here",
11005
+ category: "Review",
11006
+ keys: ["X"],
11007
+ screens: ["review"]
10876
11008
  }),
10877
11009
  command({
10878
11010
  action: "rail.toggle",
@@ -11081,7 +11213,7 @@ var init_command = __esmMin((() => {
11081
11213
  if (key.startsWith("ctrl+")) return `^${key.slice(5)}`;
11082
11214
  return GLYPHS[key] ?? key;
11083
11215
  };
11084
- 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) => ({
11216
+ 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).map((entry) => ({
11085
11217
  key: displayKey(entry.keys[0] ?? ""),
11086
11218
  hint: entry.counted ? `${entry.hint} ${staged}` : entry.hint,
11087
11219
  press: entry.keys[0] ?? ""
@@ -11390,6 +11522,7 @@ var init_reduce = __esmMin((() => {
11390
11522
  "branch.next": (state) => moveBranch(state, 1),
11391
11523
  "branch.prev": (state) => moveBranch(state, -1),
11392
11524
  "branch.open": (state) => state,
11525
+ "branch.pull": (state) => state,
11393
11526
  "cursor.next": (state) => layerDown(state, 1),
11394
11527
  "cursor.top": (state) => atRow(state, 0),
11395
11528
  "cursor.bottom": (state) => atRow(state, lastRow(selectedPatch(state))),
@@ -11439,6 +11572,7 @@ var init_reduce = __esmMin((() => {
11439
11572
  "pan.left": (state) => panned(state, -8),
11440
11573
  "review.reload": (state) => state,
11441
11574
  "thread.settle": (state) => state,
11575
+ "thread.remove": (state) => state,
11442
11576
  "rail.toggle": toggleRail,
11443
11577
  "file.vouch": (state) => state,
11444
11578
  "file.vouch.next": (state) => state,
@@ -11915,6 +12049,9 @@ var init_diffview = __esmMin((() => {
11915
12049
  noteRoom() {
11916
12050
  return Math.max(NOTE_MIN, this.code.width - this.gutterWidth() - 3);
11917
12051
  }
12052
+ room() {
12053
+ return this.noteRoom();
12054
+ }
11918
12055
  gutterWidth() {
11919
12056
  return Math.max(0, this.code.x - this.numbers.x) + SIGN_WIDTH;
11920
12057
  }
@@ -12230,7 +12367,7 @@ var init_diffview = __esmMin((() => {
12230
12367
  }));
12231
12368
  //#endregion
12232
12369
  //#region src/tui/render.ts
12233
- 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, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, Screen;
12370
+ 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;
12234
12371
  var init_render = __esmMin((() => {
12235
12372
  init_command();
12236
12373
  init_patch();
@@ -12676,7 +12813,10 @@ var init_render = __esmMin((() => {
12676
12813
  STEP_LEAD = 8;
12677
12814
  NOTE_LEAD = 10;
12678
12815
  STEP_GAP = 1;
12679
- staleBanner = (room) => wrapped("stale, the branch moved on", room).map((line) => ` ${line}`).join("\n");
12816
+ STALE_ROOM = 13;
12817
+ STALE_LONG = "stale, the branch moved on";
12818
+ STALE_SHORT = "stale";
12819
+ staleBanner = (room) => wrapped(room >= STALE_ROOM ? STALE_LONG : STALE_SHORT, room).map((line) => ` ${line}`).join("\n");
12680
12820
  layerRoom = (state, pane) => {
12681
12821
  const tally = Math.max(1, ...state.layers.map((layer) => `${layer.files.length}`.length));
12682
12822
  return {
@@ -12810,12 +12950,15 @@ var init_render = __esmMin((() => {
12810
12950
  viewportRows() {
12811
12951
  return this.diffRows();
12812
12952
  }
12953
+ noteRoom() {
12954
+ return this.view.room();
12955
+ }
12813
12956
  diffRows() {
12814
12957
  return Math.max(1, this.diffScroll.height);
12815
12958
  }
12816
12959
  update(state) {
12817
12960
  this.shown = state;
12818
- this.chips = hintsFor(state.screen, state.staged, state.layers.length);
12961
+ this.chips = hintsFor(state.screen, state.staged, state.layers.length, state.stop > 0);
12819
12962
  this.header.content = this.headerText(state);
12820
12963
  this.footer.content = this.footerText(state);
12821
12964
  this.list.content = this.listText(state);
@@ -13188,6 +13331,7 @@ var init_display = __esmMin((() => {
13188
13331
  shapeOf = (screen) => ({
13189
13332
  paint: paintWith(screen),
13190
13333
  rows: sync(() => screen.viewportRows()),
13334
+ room: sync(() => screen.noteRoom()),
13191
13335
  listen: listenWith(screen)
13192
13336
  });
13193
13337
  displayOn = (renderer, repo) => sync$1(Display)(() => shapeOf(new Screen(renderer, repo)));
@@ -13229,7 +13373,7 @@ var init_session = __esmMin((() => {
13229
13373
  writeSession = fn("Tui.writeSession")(function* (path, session) {
13230
13374
  yield* promise(() => saved(path, session));
13231
13375
  });
13232
- })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, keyName, App, launch, told, untilDestroyed, runOn, runTui;
13376
+ })), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, keyName, App, settledPath, launch, told, untilDestroyed, runOn, runTui;
13233
13377
  var init_app = __esmMin((() => {
13234
13378
  init_dist();
13235
13379
  init_report();
@@ -13275,6 +13419,7 @@ var init_app = __esmMin((() => {
13275
13419
  renderer;
13276
13420
  repo;
13277
13421
  noticeMs;
13422
+ roomed = 0;
13278
13423
  sessionPath;
13279
13424
  remembered = "";
13280
13425
  wrapKept = false;
@@ -13423,11 +13568,17 @@ var init_app = __esmMin((() => {
13423
13568
  }
13424
13569
  syncGeometry() {
13425
13570
  const rows = runSync(this.display.rows);
13426
- if (rows === this.state.viewport) return;
13427
- this.commit({
13428
- ...this.state,
13429
- viewport: rows
13430
- });
13571
+ if (rows !== this.state.viewport) {
13572
+ this.commit({
13573
+ ...this.state,
13574
+ viewport: rows
13575
+ });
13576
+ return;
13577
+ }
13578
+ const room = runSync(this.display.room);
13579
+ if (room === this.roomed) return;
13580
+ this.roomed = room;
13581
+ runSync(this.display.paint(this.state));
13431
13582
  }
13432
13583
  measured() {
13433
13584
  return {
@@ -13482,6 +13633,7 @@ var init_app = __esmMin((() => {
13482
13633
  return {
13483
13634
  quit: () => sync(() => this.renderer.destroy()),
13484
13635
  "branch.open": () => this.openBranch(),
13636
+ "branch.pull": () => this.showPull(),
13485
13637
  "compose.submit": () => this.send(),
13486
13638
  "compose.stage": () => this.stage(),
13487
13639
  "palette.run": () => this.runChoice(),
@@ -13495,6 +13647,7 @@ var init_app = __esmMin((() => {
13495
13647
  "file.vouch": () => this.vouch(false),
13496
13648
  "file.vouch.next": () => this.vouch(true),
13497
13649
  "thread.settle": () => this.settleHere(),
13650
+ "thread.remove": () => this.removeHere(),
13498
13651
  "selection.copy": () => sync(() => this.copySelection()),
13499
13652
  "search.open": () => this.findSelection(),
13500
13653
  "search.jump": () => this.openMatch(),
@@ -13670,6 +13823,23 @@ var init_app = __esmMin((() => {
13670
13823
  this.commit(withNotice(held, "settled"));
13671
13824
  });
13672
13825
  }
13826
+ removeHere() {
13827
+ return gen({ self: this }, function* () {
13828
+ const branch = selectedBranch(this.state);
13829
+ const id = (threadAtStop(this.state) ?? threadAtRow(this.state, this.state.cursor))?.id;
13830
+ if (branch === void 0 || id === void 0) {
13831
+ this.commit(withNotice(this.state, "no thread here"));
13832
+ return;
13833
+ }
13834
+ yield* removeComment(this.repo, branch.branch, id, (/* @__PURE__ */ new Date()).toISOString());
13835
+ const sent = yield* this.loadSent(branch.branch);
13836
+ const held = withSent({
13837
+ ...this.state,
13838
+ opened: this.state.opened.filter((was) => was !== id)
13839
+ }, sent);
13840
+ this.commit(withNotice(held, "removed, restore it with comment restore"));
13841
+ });
13842
+ }
13673
13843
  reloadList() {
13674
13844
  return gen({ self: this }, function* () {
13675
13845
  const here = selectedBranch(this.state)?.branch;
@@ -13804,6 +13974,19 @@ var init_app = __esmMin((() => {
13804
13974
  loadSent(branch) {
13805
13975
  return listSent(this.repo, branch);
13806
13976
  }
13977
+ showPull() {
13978
+ return gen({ self: this }, function* () {
13979
+ const branch = selectedBranch(this.state);
13980
+ if (branch === void 0) return;
13981
+ const state = this.state.pulls[branch.branch];
13982
+ if (state === void 0) {
13983
+ this.commit(withNoticeHere(this.state, "no pull request for this branch"));
13984
+ return;
13985
+ }
13986
+ 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";
13987
+ this.commit(withNoticeHere(this.state, said));
13988
+ });
13989
+ }
13807
13990
  loadPulls() {
13808
13991
  return gen({ self: this }, function* () {
13809
13992
  const pulls = yield* (yield* map(Forge, (service) => service)).pulls(this.repo).pipe(catchTag("ForgeUnavailable", () => succeed([])));
@@ -13937,7 +14120,9 @@ var init_app = __esmMin((() => {
13937
14120
  });
13938
14121
  }
13939
14122
  };
13940
- launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath) {
14123
+ settledPath = (path) => promise(() => realpath(path).catch(() => resolve(path)));
14124
+ launch = fn("Tui.launch")(function* (asked, renderer, noticeMs, sessionPath) {
14125
+ const repo = yield* settledPath(asked);
13941
14126
  const branches = yield* listBranches(repo);
13942
14127
  const resume = sessionPath === void 0 ? none() : yield* readSession(sessionPath);
13943
14128
  const store = yield* Store;
@@ -14067,6 +14252,14 @@ const commentResolve = fn("Main.commentResolve")(function* (options) {
14067
14252
  const report = yield* settleThread(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14068
14253
  yield* answer(options, { settled: report.settled });
14069
14254
  });
14255
+ const commentRemove = fn("Main.commentRemove")(function* (options) {
14256
+ const report = yield* removeComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14257
+ yield* answer(options, { removed: report.removed });
14258
+ });
14259
+ const commentRestore = fn("Main.commentRestore")(function* (options) {
14260
+ const report = yield* restoreComment(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
14261
+ yield* answer(options, { restored: report.restored });
14262
+ });
14070
14263
  const commentStage = fn("Main.commentStage")(function* (options) {
14071
14264
  const report = yield* stageComment({
14072
14265
  repo: yield* required(options, "repo"),
@@ -14153,6 +14346,8 @@ const routes = {
14153
14346
  "comment answer": commentAnswer,
14154
14347
  "comment threads": commentThreads,
14155
14348
  "comment resolve": commentResolve,
14349
+ "comment remove": commentRemove,
14350
+ "comment restore": commentRestore,
14156
14351
  "review submit": reviewSubmit,
14157
14352
  "review pane": fn("Main.reviewPane")(function* (options) {
14158
14353
  const report = yield* openPane(yield* required(options, "repo"));
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.34",
26
+ "version": "0.1.0-alpha.36",
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": {