@eliya-oss/agent-diff 0.1.0-alpha.153 → 0.1.0-alpha.155

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 +39 -0
  2. package/dist/main.js +118 -36
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.155
4
+
5
+ ### Patch Changes
6
+
7
+ - feat(report): a bug report says the base, the preferences away from their default, what the reading order holds, whether remarks are read, the shape of the file on screen, and the slowest actions.
8
+
9
+ <details><summary>Why</summary>
10
+
11
+ Two reports cost a day between them. Neither said which base the diff was computed against, that the
12
+ branch had a reading order at all, or whether the slow thing took three seconds or thirty — so each
13
+ one had to be reproduced by hand against a real repository before it could be read. Counts, spans,
14
+ flags and timings name nothing, so they are in a minimal report too; a layer's title is the agent's
15
+ prose, so a minimal report says which layer by number.
16
+
17
+ </details>
18
+
19
+ feat(CLI): `layers set` says how many hunks more than one layer claims, which coverage cannot express.
20
+
21
+ <details><summary>Why</summary>
22
+
23
+ A reading order whose layers all claim the whole diff reports perfect coverage, and so does one
24
+ whose layers each claim their own run. The number that tells them apart was the one nothing counted.
25
+
26
+ </details>
27
+
28
+ ## 0.1.0-alpha.154
29
+
30
+ ### Patch Changes
31
+
32
+ - fix(layers): a layer shows the changed lines it claims, and the lines another layer claims are one line saying which layer that is, even inside the run it is showing.
33
+
34
+ <details><summary>What was wrong</summary>
35
+
36
+ A reading order written one layer to a commit splits a long run of changed lines between several
37
+ layers. Scoping a layer to whole runs still drew all of a 276-line run for every layer that claimed
38
+ any line of it, so a reviewer walking eleven commits read the same block eleven times.
39
+
40
+ </details>
41
+
3
42
  ## 0.1.0-alpha.153
4
43
 
5
44
  ### Patch Changes
package/dist/main.js CHANGED
@@ -11309,7 +11309,7 @@ var init_pane = __esmMin((() => {
11309
11309
  //#region package.json
11310
11310
  init_drafts();
11311
11311
  init_pane();
11312
- var version$1 = "0.1.0-alpha.153";
11312
+ var version$1 = "0.1.0-alpha.155";
11313
11313
  //#endregion
11314
11314
  //#region src/cli/upgrade.ts
11315
11315
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
@@ -11715,7 +11715,7 @@ var init_model$1 = __esmMin((() => {
11715
11715
  }));
11716
11716
  //#endregion
11717
11717
  //#region src/domain/layers/coverage.ts
11718
- var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
11718
+ var codeBlockOf$1, codeBlocks, noteOf, spansOf$1, changedLines, holds, claimsHunk, runsOf, tallyOf, coverage, sharedHunks, runsSaid, filesSaid, leftSaid, unordered, withFullCoverage, proseAnchors;
11719
11719
  var init_coverage = __esmMin((() => {
11720
11720
  init_dist();
11721
11721
  init_model$1();
@@ -11772,6 +11772,10 @@ var init_coverage = __esmMin((() => {
11772
11772
  missing: tallies.flatMap((tally) => tally.missing)
11773
11773
  };
11774
11774
  };
11775
+ sharedHunks = (patches, layers) => {
11776
+ const claiming = (patch, hunk) => layers.filter((layer) => claimsHunk(spansOf$1([layer]), patch.path, hunk)).length;
11777
+ return patches.reduce((sum, patch) => sum + patch.hunks.filter((hunk) => changedLines(hunk).length > 0 && claiming(patch, hunk) > 1).length, 0);
11778
+ };
11775
11779
  runsSaid = (count) => count === 1 ? "One run of changed lines the layers do not account for." : `${count} runs of changed lines the layers do not account for.`;
11776
11780
  filesSaid = (count) => count === 1 ? "One file the layers had no lines to order." : `${count} files the layers had no lines to order.`;
11777
11781
  leftSaid = (runs, files) => {
@@ -12004,6 +12008,7 @@ var init_layers = __esmMin((() => {
12004
12008
  partial: status.partial,
12005
12009
  total: status.total,
12006
12010
  uncovered: status.uncovered,
12011
+ shared: sharedHunks(patches, layers.layers),
12007
12012
  vanished: status.vanished,
12008
12013
  layers: reportedLayers(patches, layers)
12009
12014
  };
@@ -13585,7 +13590,7 @@ const helpUnder = (noun) => {
13585
13590
  };
13586
13591
  //#endregion
13587
13592
  //#region src/tui/gaps.ts
13588
- var sourceLength, markerText, lastNewLine, spansOf, linesFrom, push, markGap, openOf, countOf$1, openAbove, openBelow, changedIn, elsewhereText, markElsewhere, makeRows, compose, cache, keyOf$1, saidOf, claimOf, shownOf, gapAtRow, gapNumbered, gapRowSet;
13593
+ var sourceLength, markerText, lastNewLine, spansOf, linesFrom, push, markGap, openOf, countOf$1, openAbove, openBelow, elsewhereText, markElsewhere, flushed, someRows, changedIn, firstChanged, makeRows, compose, cache, keyOf$1, saidOf, lineOf$1, inSpans, spansFor, claimOf, shownOf, gapAtRow, gapNumbered, gapRowSet;
13589
13594
  var init_gaps = __esmMin((() => {
13590
13595
  init_dist();
13591
13596
  init_layers$1();
@@ -13665,19 +13670,35 @@ var init_gaps = __esmMin((() => {
13665
13670
  for (const row of linesFrom(build, span.lo, span.lo + open - 1)) push(made, row);
13666
13671
  if (count - open > 0) markGap(made, index, count - open);
13667
13672
  };
13668
- changedIn = (hunk) => hunk.rows.filter((row) => row.kind !== "context").length;
13669
- elsewhereText = (hunk, said) => {
13670
- const lines = changedIn(hunk);
13671
- return `⋯ ${lines} changed ${lines === 1 ? "line" : "lines"} · ${said}`;
13672
- };
13673
- markElsewhere = (made, hunk, said) => {
13673
+ elsewhereText = (lines, said) => `⋯ ${lines} changed ${lines === 1 ? "line" : "lines"} · ${said}`;
13674
+ markElsewhere = (made, lines, said) => {
13674
13675
  push(made, {
13675
13676
  kind: "context",
13676
13677
  oldLine: none(),
13677
13678
  newLine: none(),
13678
- text: elsewhereText(hunk, said)
13679
+ text: elsewhereText(lines, said)
13679
13680
  });
13680
13681
  };
13682
+ flushed = (made, run) => {
13683
+ if (run !== void 0) markElsewhere(made, run.lines, run.said);
13684
+ };
13685
+ someRows = (made, hunk, claim) => {
13686
+ let run;
13687
+ for (const row of hunk.rows) {
13688
+ if (row.kind === "context" || claim.mine(row)) {
13689
+ run = flushed(made, run);
13690
+ push(made, row);
13691
+ continue;
13692
+ }
13693
+ run = {
13694
+ lines: (run?.lines ?? 0) + 1,
13695
+ said: run?.said ?? claim.said(row)
13696
+ };
13697
+ }
13698
+ flushed(made, run);
13699
+ };
13700
+ changedIn = (hunk) => hunk.rows.filter((row) => row.kind !== "context").length;
13701
+ firstChanged = (hunk) => hunk.rows.find((row) => row.kind !== "context");
13681
13702
  makeRows = (build) => {
13682
13703
  const made = {
13683
13704
  rows: [],
@@ -13686,13 +13707,15 @@ var init_gaps = __esmMin((() => {
13686
13707
  };
13687
13708
  for (const [index, hunk] of build.base.hunks.entries()) {
13688
13709
  const left = openAbove(made, build, index);
13689
- const said = build.claim === void 0 || build.claim.claimed.has(index) ? void 0 : build.claim.explains.get(index) ?? "no layer claims them";
13690
- if (said !== void 0) {
13691
- markElsewhere(made, hunk, said);
13710
+ const claim = build.claim;
13711
+ const gone = firstChanged(hunk);
13712
+ if (claim !== void 0 && gone !== void 0 && !claim.holds(hunk)) {
13713
+ markElsewhere(made, changedIn(hunk), claim.said(gone));
13692
13714
  continue;
13693
13715
  }
13694
13716
  const startRow = made.rows.length;
13695
- for (const row of hunk.rows) push(made, row);
13717
+ if (claim === void 0) for (const row of hunk.rows) push(made, row);
13718
+ else someRows(made, hunk, claim);
13696
13719
  made.hunks.push({
13697
13720
  ...hunk,
13698
13721
  startRow,
@@ -13715,11 +13738,11 @@ var init_gaps = __esmMin((() => {
13715
13738
  };
13716
13739
  };
13717
13740
  cache = /* @__PURE__ */ new WeakMap();
13718
- keyOf$1 = (total, full, reveals, claim) => [
13741
+ keyOf$1 = (total, full, reveals, spans) => [
13719
13742
  total,
13720
13743
  full === void 0 ? 0 : full.rows.length,
13721
13744
  reveals.map((entry) => `${entry.gap}-${entry.lines}`).join(","),
13722
- claim === void 0 ? "all" : [...claim.claimed].toSorted((a, b) => a - b).join("-")
13745
+ spans.map((span) => `${span.start}-${span.end}`).join(",")
13723
13746
  ].join(":");
13724
13747
  saidOf = (state, at) => {
13725
13748
  if (at === -1) return "no layer claims them";
@@ -13727,22 +13750,27 @@ var init_gaps = __esmMin((() => {
13727
13750
  if (layer === void 0 || layer.title === "not in any layer") return "no layer claims them";
13728
13751
  return `layer ${at + 1} explains them`;
13729
13752
  };
13753
+ lineOf$1 = (row) => getOrUndefined$1(orElse(row.newLine, () => row.oldLine));
13754
+ inSpans = (spans, path, line) => spans.some((span) => span.path === path && span.start <= line && span.end >= line);
13755
+ spansFor = (state, path) => (state.layers[state.layerIndex]?.spans ?? []).filter((span) => span.path === path);
13730
13756
  claimOf = (state, base) => {
13731
13757
  if (state.rail !== "layers" || state.layers.length === 0) return void 0;
13732
- const layer = state.layers[state.layerIndex];
13733
- if (layer === void 0) return void 0;
13734
- const claimed = /* @__PURE__ */ new Set();
13735
- const explains = /* @__PURE__ */ new Map();
13736
- for (const [at, hunk] of base.hunks.entries()) {
13737
- if (claimsHunk(layer.spans, base.path, hunk)) {
13738
- claimed.add(at);
13739
- continue;
13740
- }
13741
- explains.set(at, saidOf(state, state.layers.findIndex((one) => claimsHunk(one.spans, base.path, hunk))));
13742
- }
13743
- return claimed.size === base.hunks.length ? void 0 : {
13744
- claimed,
13745
- explains
13758
+ if (state.layers[state.layerIndex] === void 0) return void 0;
13759
+ const mineSpans = spansFor(state, base.path);
13760
+ const mine = (row) => {
13761
+ const line = lineOf$1(row);
13762
+ return line !== void 0 && inSpans(mineSpans, base.path, line);
13763
+ };
13764
+ const said = (row) => {
13765
+ const line = lineOf$1(row);
13766
+ if (line === void 0) return "no layer claims them";
13767
+ return saidOf(state, state.layers.findIndex((one) => inSpans(one.spans, base.path, line)));
13768
+ };
13769
+ const holds = (hunk) => hunk.rows.some((row) => row.kind !== "context" && mine(row));
13770
+ return base.hunks.every(holds) && base.hunks.every((hunk) => hunk.rows.every((row) => row.kind === "context" || mine(row))) ? void 0 : {
13771
+ mine,
13772
+ said,
13773
+ holds
13746
13774
  };
13747
13775
  };
13748
13776
  shownOf = (state) => {
@@ -13752,7 +13780,7 @@ var init_gaps = __esmMin((() => {
13752
13780
  const total = sourceLength(state.source);
13753
13781
  const reveals = state.revealed.filter((entry) => entry.file === base.path);
13754
13782
  const claim = claimOf(state, base);
13755
- const key = keyOf$1(total, full, reveals, claim);
13783
+ const key = keyOf$1(total, full, reveals, claim === void 0 ? [] : spansFor(state, base.path));
13756
13784
  const known = cache.get(base);
13757
13785
  const found = known?.get(key);
13758
13786
  if (found !== void 0) return found;
@@ -14735,10 +14763,11 @@ var init_model = __esmMin((() => {
14735
14763
  }));
14736
14764
  //#endregion
14737
14765
  //#region src/tui/report.ts
14738
- var AROUND_CURSOR, TREE_ROWS, sign, visibleRows, visibleTree, whereabouts, facts, fenced, fully, minimal, lastFailure, buildReport;
14766
+ var AROUND_CURSOR, TREE_ROWS, sign, visibleRows, visibleTree, whereabouts, said$1, chosenAway, standingOn, layersLine, remarksLine, shapeLine, tookLine, facts, fenced, fully, minimal, lastFailure, buildReport;
14739
14767
  var init_report = __esmMin((() => {
14740
14768
  init_dist();
14741
14769
  init_model();
14770
+ init_preferences();
14742
14771
  AROUND_CURSOR = 8;
14743
14772
  TREE_ROWS = 12;
14744
14773
  sign = (kind) => {
@@ -14762,15 +14791,49 @@ var init_report = __esmMin((() => {
14762
14791
  });
14763
14792
  whereabouts = (state, around) => [
14764
14793
  `- repo \`${around.repo}\``,
14765
- `- branch \`${selectedBranch(state)?.branch ?? "none"}\``,
14794
+ `- branch \`${selectedBranch(state)?.branch ?? "none"}\`, base \`${around.base.length === 0 ? "resolved by adiff" : around.base}\``,
14766
14795
  `- file \`${selectedPatch(state)?.path ?? "none"}\`, row ${state.cursor + 1}`
14767
14796
  ];
14797
+ said$1 = (many, one) => `${many} ${one}${many === 1 ? "" : "s"}`;
14798
+ chosenAway = (state) => {
14799
+ const held = chosenNow(state);
14800
+ const away = preferences.filter((one) => (held[one.name] ?? one.byDefault) !== one.byDefault);
14801
+ return away.length === 0 ? "every preference at its default" : away.map((one) => one.name).join(", ");
14802
+ };
14803
+ standingOn = (state) => {
14804
+ if (!state.reportFull) return `standing on layer ${state.layerIndex + 1}`;
14805
+ return `standing on \`${state.layers[state.layerIndex]?.title ?? "none"}\``;
14806
+ };
14807
+ layersLine = (state) => {
14808
+ if (state.layers.length === 0) return "- no reading order on this branch";
14809
+ const spans = state.layers.reduce((sum, layer) => sum + layer.spans.length, 0);
14810
+ return `- reading order: ${said$1(state.layers.length, "layer")} over ${said$1(spans, "span")}, rail on ${state.rail}, ${state.layersStale ? "stale" : "current"}, ${standingOn(state)}`;
14811
+ };
14812
+ remarksLine = (state) => {
14813
+ if (!state.remarksOn) return "- the pull request's remarks are off";
14814
+ const waiting = state.remarks.filter((one) => one.state === "waiting").length;
14815
+ return `- remarks on: ${said$1(state.remarks.length, "remark")}, ${waiting} waiting`;
14816
+ };
14817
+ shapeLine = (state) => {
14818
+ const hunks = selectedPatch(state)?.hunks.length ?? 0;
14819
+ const whole = state.context >= 1e5 ? "the whole file" : `${state.context} lines of context`;
14820
+ return `- this file: ${said$1(hunks, "hunk")} shown, ${whole}, ${state.wrap ? "wrapped" : "not wrapped"}`;
14821
+ };
14822
+ tookLine = (around) => {
14823
+ if (around.slowest.length === 0) return [];
14824
+ return [`- slowest: ${around.slowest.map((one) => `${one.action} ${one.ms}ms`).join(", ")}`];
14825
+ };
14768
14826
  facts = (state, around) => [
14769
14827
  `- adiff ${version$1} on Node ${process.version}, ${platform()}${state.reportFull ? `, ${hostname()}` : ""}`,
14770
14828
  `- terminal ${around.width}x${around.height}`,
14771
14829
  ...state.reportFull ? whereabouts(state, around) : [],
14772
14830
  `- screen \`${state.screen}\`, focus \`${state.focus}\`, selecting ${String(state.selecting)}`,
14773
- `- ${state.vouched.length} of ${state.patches.length} reviewed`
14831
+ `- ${state.vouched.length} of ${state.patches.length} reviewed`,
14832
+ `- preferences away from default: ${chosenAway(state)}`,
14833
+ layersLine(state),
14834
+ remarksLine(state),
14835
+ shapeLine(state),
14836
+ ...tookLine(around)
14774
14837
  ];
14775
14838
  fenced = (title, lines) => [
14776
14839
  `## ${title}`,
@@ -19341,7 +19404,7 @@ var init_upgrade = __esmMin((() => {
19341
19404
  }));
19342
19405
  //#endregion
19343
19406
  //#region src/tui/app.ts
19344
- var LEAVING_MS, LOOK_MS, LEAST_TERM, AGE_TICK_MS, LEAVING_SAID, NOTHING_WRITTEN, NOTHING_COUNTED, READING_PULL, FORGE_QUIET, countOf, leavingSaid, LAYERS_ASK_LEAD, layersAsk, askedFor, alongFrom, NOTICE_MS, KEY_HISTORY, DRAIN_PASSES, TRAIL_HISTORY, clockOf, momentOf, noticeOf, COPIERS, wayland, seedFor, handOver, throughMultiplexer, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, OVER, overReview, writesInto, listens, LETTER, laidOut, ARROWS, SHIFTED, keyName, App, sentAway, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
19407
+ var LEAVING_MS, LOOK_MS, LEAST_TERM, AGE_TICK_MS, LEAVING_SAID, NOTHING_WRITTEN, WORTH_TIMING_MS, TIMES_KEPT, SLOWEST_KEPT, NOTHING_COUNTED, READING_PULL, FORGE_QUIET, countOf, leavingSaid, LAYERS_ASK_LEAD, layersAsk, askedFor, alongFrom, NOTICE_MS, KEY_HISTORY, DRAIN_PASSES, TRAIL_HISTORY, clockOf, momentOf, noticeOf, COPIERS, wayland, seedFor, handOver, throughMultiplexer, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, OVER, overReview, writesInto, listens, LETTER, laidOut, ARROWS, SHIFTED, keyName, App, sentAway, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
19345
19408
  var init_app = __esmMin((() => {
19346
19409
  init_dist();
19347
19410
  init_report();
@@ -19365,6 +19428,9 @@ var init_app = __esmMin((() => {
19365
19428
  AGE_TICK_MS = 3e4;
19366
19429
  LEAVING_SAID = "press ctrl+c again to leave";
19367
19430
  NOTHING_WRITTEN = "nothing written yet";
19431
+ WORTH_TIMING_MS = 250;
19432
+ TIMES_KEPT = 40;
19433
+ SLOWEST_KEPT = 3;
19368
19434
  NOTHING_COUNTED = {
19369
19435
  file: 0,
19370
19436
  branch: 0,
@@ -19536,6 +19602,7 @@ var init_app = __esmMin((() => {
19536
19602
  ticking;
19537
19603
  grewWithShift = false;
19538
19604
  keys = [];
19605
+ took = [];
19539
19606
  trail = [];
19540
19607
  began = Date.now();
19541
19608
  fading;
@@ -19612,6 +19679,9 @@ var init_app = __esmMin((() => {
19612
19679
  noticeOnList() {
19613
19680
  return sync(() => this.commit(withWaiting(this.state, "the agent answered · press r")));
19614
19681
  }
19682
+ slowest() {
19683
+ return [...this.took].toSorted((left, right) => right.ms - left.ms).slice(0, SLOWEST_KEPT);
19684
+ }
19615
19685
  dispatchTask(task) {
19616
19686
  offerUnsafe(this.intents, Intent.Task({ run: task }));
19617
19687
  }
@@ -19619,7 +19689,17 @@ var init_app = __esmMin((() => {
19619
19689
  return runForEach(fromQueue(this.intents), (intent) => this.act(intent));
19620
19690
  }
19621
19691
  act(intent) {
19622
- return this.answer(intent).pipe(catchCause((cause) => sync(() => this.fail(squash(cause)))));
19692
+ const began = Date.now();
19693
+ return this.answer(intent).pipe(catchCause((cause) => sync(() => this.fail(squash(cause)))), ensuring(sync(() => this.timed(began))));
19694
+ }
19695
+ timed(began) {
19696
+ const ms = Date.now() - began;
19697
+ if (ms < WORTH_TIMING_MS) return;
19698
+ this.took.push({
19699
+ action: this.trail.at(-1)?.trim().split(/\s+/)[1] ?? "a key",
19700
+ ms
19701
+ });
19702
+ if (this.took.length > TIMES_KEPT) this.took.shift();
19623
19703
  }
19624
19704
  answer(intent) {
19625
19705
  return Intent.$match(intent, {
@@ -20811,6 +20891,8 @@ var init_app = __esmMin((() => {
20811
20891
  }
20812
20892
  const text = buildReport(this.state, {
20813
20893
  repo: this.repo,
20894
+ base: this.base ?? "",
20895
+ slowest: this.slowest(),
20814
20896
  keys: this.keys,
20815
20897
  trail: this.trail,
20816
20898
  failure: this.failure,
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.153",
26
+ "version": "0.1.0-alpha.155",
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": {
@@ -43,7 +43,7 @@
43
43
  "check": "pnpm run typecheck && pnpm run lint && pnpm run build && pnpm test",
44
44
  "build": "rolldown -c rolldown.config.ts",
45
45
  "typecheck": "tsc --noEmit",
46
- "lint": "oxlint && node scripts/check-rules.ts",
46
+ "lint": "oxlint && node scripts/check-rules.ts && node scripts/check-film.ts",
47
47
  "test": "NODE_OPTIONS=--experimental-ffi vitest run",
48
48
  "test:watch": "NODE_OPTIONS=--experimental-ffi vitest",
49
49
  "dev": "node --experimental-ffi --disable-warning=ExperimentalWarning src/main.ts",