@eliya-oss/agent-diff 0.1.0-alpha.189 → 0.1.0-alpha.190

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.190
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(CLI): `patch show` names the scope each line of a file sits in, so a second client pins the same class, function and block above the diff that the terminal pins.
8
+
3
9
  ## 0.1.0-alpha.189
4
10
 
5
11
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10044,7 +10044,7 @@ var init_config = __esmMin((() => {
10044
10044
  //#region package.json
10045
10045
  init_pane();
10046
10046
  init_config();
10047
- var version$1 = "0.1.0-alpha.189";
10047
+ var version$1 = "0.1.0-alpha.190";
10048
10048
  //#endregion
10049
10049
  //#region src/cli/error.ts
10050
10050
  var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered, NotServed, BadRequest;
@@ -10422,7 +10422,7 @@ var init_catalog = __esmMin((() => {
10422
10422
  },
10423
10423
  {
10424
10424
  name: "patch show",
10425
- about: "A branch's diff as rows with line numbers on both sides, read from the same parse the terminal draws. Binary and generated files are listed and flagged",
10425
+ 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",
10426
10426
  group: READ_A_BRANCH,
10427
10427
  addresses: "review",
10428
10428
  safety: "read",
@@ -11899,7 +11899,7 @@ var init_parse = __esmMin((() => {
11899
11899
  }));
11900
11900
  //#endregion
11901
11901
  //#region src/domain/patch/sticky.ts
11902
- var CLOSER, COMMENT, LOOKAHEAD, indentOf, pinnable, limitFrom, stickyChain, kept;
11902
+ var CLOSER, COMMENT, LOOKAHEAD, indentOf, pinnable, limitFrom, enclosing, read$3, enclosedBy, scopeLines, stickyChain, kept;
11903
11903
  var init_sticky = __esmMin((() => {
11904
11904
  CLOSER = /^[)\]}>;,]/;
11905
11905
  COMMENT = /^(\/\/|\/\*|\*|#|<!--)/;
@@ -11916,20 +11916,35 @@ var init_sticky = __esmMin((() => {
11916
11916
  const ahead = source.slice(index, index + LOOKAHEAD).find((line) => line.trim().length > 0);
11917
11917
  return ahead === void 0 ? 0 : indentOf(ahead);
11918
11918
  };
11919
+ enclosing = (source) => {
11920
+ const open = [];
11921
+ const found = [];
11922
+ source.forEach((text, index) => {
11923
+ const limit = limitFrom(source, index);
11924
+ const outer = open.findLast((at) => indentOf(source[at] ?? "") < limit);
11925
+ found.push(outer === void 0 ? 0 : outer + 1);
11926
+ if (!pinnable(text)) return;
11927
+ const indent = indentOf(text);
11928
+ while (open.length > 0 && indentOf(source[open.at(-1) ?? 0] ?? "") >= indent) open.pop();
11929
+ open.push(index);
11930
+ });
11931
+ return found;
11932
+ };
11933
+ read$3 = /* @__PURE__ */ new WeakMap();
11934
+ enclosedBy = (source) => {
11935
+ const known = read$3.get(source);
11936
+ if (known !== void 0) return known;
11937
+ const found = enclosing(source);
11938
+ read$3.set(source, found);
11939
+ return found;
11940
+ };
11941
+ scopeLines = (source) => [...new Set(enclosedBy(source).filter((line) => line > 0))].toSorted((left, right) => left - right);
11919
11942
  stickyChain = (source, line, max) => {
11920
11943
  const index = line - 1;
11921
11944
  if (index <= 0 || index >= source.length) return [];
11922
- let limit = limitFrom(source, index);
11945
+ const outer = enclosedBy(source);
11923
11946
  const chain = [];
11924
- for (let above = index - 1; above >= 0; above -= 1) {
11925
- const text = source[above] ?? "";
11926
- if (!pinnable(text)) continue;
11927
- const indent = indentOf(text);
11928
- if (indent >= limit) continue;
11929
- chain.push(text);
11930
- limit = indent;
11931
- if (indent === 0) break;
11932
- }
11947
+ for (let at = outer[index] ?? 0; at > 0; at = outer[at - 1] ?? 0) chain.push(source[at - 1] ?? "");
11933
11948
  return kept(chain.toReversed(), max);
11934
11949
  };
11935
11950
  kept = (chain, max) => {
@@ -13172,7 +13187,7 @@ var init_branches$1 = __esmMin((() => {
13172
13187
  }));
13173
13188
  //#endregion
13174
13189
  //#region src/review/patches.ts
13175
- var findPatch, blobOf, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, shownFile, show$3;
13190
+ var findPatch, blobOf, anchor, list$4, source, before, linesAround, GENERATED_NAME, lineOf$2, isNote$1, shownRow, shownHunk, scopesOf, shownFile, sourceShown, fileShown$1, show$3;
13176
13191
  var init_patches = __esmMin((() => {
13177
13192
  init_dist();
13178
13193
  init_patch();
@@ -13236,7 +13251,11 @@ var init_patches = __esmMin((() => {
13236
13251
  skipped: hunk.skipped,
13237
13252
  rows: hunk.rows.map((row) => shownRow(hunk, row))
13238
13253
  });
13239
- shownFile = (patch, generated) => ({
13254
+ scopesOf = (lines) => scopeLines(lines).map((line) => ({
13255
+ line,
13256
+ text: lines[line - 1] ?? ""
13257
+ }));
13258
+ shownFile = (patch, generated, lines) => ({
13240
13259
  path: patch.path,
13241
13260
  previousPath: patch.previousPath,
13242
13261
  status: patch.status,
@@ -13244,8 +13263,15 @@ var init_patches = __esmMin((() => {
13244
13263
  generated: generated.has(patch.path) || GENERATED_NAME.test(patch.path),
13245
13264
  added: patch.added,
13246
13265
  removed: patch.removed,
13247
- hunks: patch.hunks.map(shownHunk)
13266
+ hunks: patch.hunks.map(shownHunk),
13267
+ enclosedBy: enclosedBy(lines),
13268
+ scopes: scopesOf(lines)
13269
+ });
13270
+ sourceShown = fn("Review.Diff.sourceShown")(function* (worktree, patch) {
13271
+ if (patch.binary || patch.status === "deleted") return [];
13272
+ return yield* source(worktree, patch.path);
13248
13273
  });
13274
+ fileShown$1 = (worktree, generated) => (patch) => map$1(sourceShown(worktree, patch), (lines) => shownFile(patch, generated, lines));
13249
13275
  show$3 = fn("Review.Diff.show")(function* (based, showing) {
13250
13276
  const git = yield* Git;
13251
13277
  const { worktree } = based;
@@ -13256,7 +13282,7 @@ var init_patches = __esmMin((() => {
13256
13282
  base: based.base,
13257
13283
  mergeBase: worktree.base,
13258
13284
  head: worktree.head,
13259
- files: patches$3.map((patch) => shownFile(patch, generated))
13285
+ files: yield* forEach(patches$3, fileShown$1(worktree, generated), { concurrency: 16 })
13260
13286
  };
13261
13287
  });
13262
13288
  }));
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.189",
26
+ "version": "0.1.0-alpha.190",
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": {