@eliya-oss/agent-diff 0.1.0-alpha.178 → 0.1.0-alpha.179
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 +13 -0
- package/dist/main.js +120 -69
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.179
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat(diff): a line that only changed its indentation is shown once, as unchanged, so a block wrapped in a new function is two added lines and not a rewrite of every line inside it.
|
|
8
|
+
|
|
9
|
+
<details><summary>What was wrong</summary>
|
|
10
|
+
|
|
11
|
+
Wrapping twenty-five lines in `startTransition(() => { … })` drew twenty-five removed lines and
|
|
12
|
+
twenty-seven added ones, and the reviewer had to read both blocks to find the two that mattered.
|
|
13
|
+
|
|
14
|
+
</details>
|
|
15
|
+
|
|
3
16
|
## 0.1.0-alpha.178
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/main.js
CHANGED
|
@@ -10027,7 +10027,7 @@ var init_config = __esmMin((() => {
|
|
|
10027
10027
|
//#region package.json
|
|
10028
10028
|
init_pane();
|
|
10029
10029
|
init_config();
|
|
10030
|
-
var version$1 = "0.1.0-alpha.
|
|
10030
|
+
var version$1 = "0.1.0-alpha.179";
|
|
10031
10031
|
//#endregion
|
|
10032
10032
|
//#region src/cli/error.ts
|
|
10033
10033
|
var UnknownCommand, MissingOption, UnknownField, UnknownOption, BadOption, RegistryUnanswered;
|
|
@@ -11215,11 +11215,11 @@ var init_model$5 = __esmMin((() => {
|
|
|
11215
11215
|
}));
|
|
11216
11216
|
//#endregion
|
|
11217
11217
|
//#region src/domain/patch/anchor.ts
|
|
11218
|
-
var sideOf, linesOn, anchorFor, rowsForRange, sideLines, runsAt, nearestRun, SHORTEST_NEAR, PER_EDIT, edits, isNear, nearestLike, foundExactly, foundAlike, foundAgain;
|
|
11218
|
+
var sideOf$1, linesOn, anchorFor, rowsForRange, sideLines, runsAt, nearestRun, SHORTEST_NEAR, PER_EDIT, edits, isNear, nearestLike, foundExactly, foundAlike, foundAgain;
|
|
11219
11219
|
var init_anchor = __esmMin((() => {
|
|
11220
11220
|
init_dist();
|
|
11221
11221
|
init_model$5();
|
|
11222
|
-
sideOf = (rows) => rows.some((row) => isSome(row.newLine)) ? "new" : "old";
|
|
11222
|
+
sideOf$1 = (rows) => rows.some((row) => isSome(row.newLine)) ? "new" : "old";
|
|
11223
11223
|
linesOn = (rows, side) => rows.flatMap((row) => match$3(lineOn(row, side), {
|
|
11224
11224
|
onNone: () => [],
|
|
11225
11225
|
onSome: (n) => [n]
|
|
@@ -11228,7 +11228,7 @@ var init_anchor = __esmMin((() => {
|
|
|
11228
11228
|
const [low, high] = from <= to ? [from, to] : [to, from];
|
|
11229
11229
|
const rows = patch.rows.slice(low, high + 1);
|
|
11230
11230
|
if (rows.length === 0) return none();
|
|
11231
|
-
const side = wanted ?? sideOf(rows);
|
|
11231
|
+
const side = wanted ?? sideOf$1(rows);
|
|
11232
11232
|
const onSide = rows.filter((row) => isSome(lineOn(row, side)));
|
|
11233
11233
|
const lines = linesOn(onSide, side);
|
|
11234
11234
|
if (lines.length === 0) return none();
|
|
@@ -11314,10 +11314,120 @@ var init_anchor = __esmMin((() => {
|
|
|
11314
11314
|
foundAgain = (patch, wanted) => orElse(foundExactly(patch, wanted), () => foundAlike(patch, wanted));
|
|
11315
11315
|
}));
|
|
11316
11316
|
//#endregion
|
|
11317
|
+
//#region src/domain/patch/reindent.ts
|
|
11318
|
+
var LCS_ROOM, body, isBlock, openBlock, sideOf, blocksOf$1, at, fillRow, lcsTable, joined, stepAt, walked, canFold, folded, rowsOf, reindexed, foldReindents;
|
|
11319
|
+
var init_reindent = __esmMin((() => {
|
|
11320
|
+
LCS_ROOM = 1e6;
|
|
11321
|
+
body = (row) => row.text.trimStart();
|
|
11322
|
+
isBlock = (entry) => !("kind" in entry);
|
|
11323
|
+
openBlock = () => ({
|
|
11324
|
+
removed: [],
|
|
11325
|
+
added: []
|
|
11326
|
+
});
|
|
11327
|
+
sideOf = (block, row) => row.kind === "removed" ? block.removed : block.added;
|
|
11328
|
+
blocksOf$1 = (rows) => {
|
|
11329
|
+
const out = [];
|
|
11330
|
+
for (const row of rows) {
|
|
11331
|
+
if (row.kind === "context") {
|
|
11332
|
+
out.push(row);
|
|
11333
|
+
continue;
|
|
11334
|
+
}
|
|
11335
|
+
const last = out.at(-1);
|
|
11336
|
+
const block = last !== void 0 && isBlock(last) ? last : openBlock();
|
|
11337
|
+
if (block !== last) out.push(block);
|
|
11338
|
+
sideOf(block, row).push(row);
|
|
11339
|
+
}
|
|
11340
|
+
return out;
|
|
11341
|
+
};
|
|
11342
|
+
at = (table, i, j) => table[i]?.[j] ?? 0;
|
|
11343
|
+
fillRow = (table, old, now, i) => {
|
|
11344
|
+
const row = table[i];
|
|
11345
|
+
if (row === void 0) return;
|
|
11346
|
+
for (let j = now.length - 1; j >= 0; j--) row[j] = old === now[j] ? at(table, i + 1, j + 1) + 1 : Math.max(at(table, i + 1, j), at(table, i, j + 1));
|
|
11347
|
+
};
|
|
11348
|
+
lcsTable = (old, now) => {
|
|
11349
|
+
const table = Array.from({ length: old.length + 1 }, () => new Uint32Array(now.length + 1));
|
|
11350
|
+
for (let i = old.length - 1; i >= 0; i--) fillRow(table, old[i] ?? "", now, i);
|
|
11351
|
+
return table;
|
|
11352
|
+
};
|
|
11353
|
+
joined = (removed, added) => ({
|
|
11354
|
+
index: 0,
|
|
11355
|
+
kind: "context",
|
|
11356
|
+
oldLine: removed.oldLine,
|
|
11357
|
+
newLine: added.newLine,
|
|
11358
|
+
text: added.text
|
|
11359
|
+
});
|
|
11360
|
+
stepAt = (block, table, i, j) => {
|
|
11361
|
+
const removed = block.removed[i];
|
|
11362
|
+
const added = block.added[j];
|
|
11363
|
+
if (removed === void 0 || added === void 0) return void 0;
|
|
11364
|
+
if (body(removed) === body(added)) return {
|
|
11365
|
+
row: joined(removed, added),
|
|
11366
|
+
old: 1,
|
|
11367
|
+
now: 1
|
|
11368
|
+
};
|
|
11369
|
+
if (at(table, i + 1, j) >= at(table, i, j + 1)) return {
|
|
11370
|
+
row: removed,
|
|
11371
|
+
old: 1,
|
|
11372
|
+
now: 0
|
|
11373
|
+
};
|
|
11374
|
+
return {
|
|
11375
|
+
row: added,
|
|
11376
|
+
old: 0,
|
|
11377
|
+
now: 1
|
|
11378
|
+
};
|
|
11379
|
+
};
|
|
11380
|
+
walked = (block, table) => {
|
|
11381
|
+
const out = [];
|
|
11382
|
+
let i = 0;
|
|
11383
|
+
let j = 0;
|
|
11384
|
+
for (let step = stepAt(block, table, i, j); step !== void 0; step = stepAt(block, table, i, j)) {
|
|
11385
|
+
out.push(step.row);
|
|
11386
|
+
i += step.old;
|
|
11387
|
+
j += step.now;
|
|
11388
|
+
}
|
|
11389
|
+
return [
|
|
11390
|
+
...out,
|
|
11391
|
+
...block.removed.slice(i),
|
|
11392
|
+
...block.added.slice(j)
|
|
11393
|
+
];
|
|
11394
|
+
};
|
|
11395
|
+
canFold = (block) => block.removed.length > 0 && block.added.length > 0 && block.removed.length * block.added.length <= LCS_ROOM;
|
|
11396
|
+
folded = (block) => {
|
|
11397
|
+
if (!canFold(block)) return [...block.removed, ...block.added];
|
|
11398
|
+
const table = lcsTable(block.removed.map(body), block.added.map(body));
|
|
11399
|
+
if (at(table, 0, 0) === 0) return [...block.removed, ...block.added];
|
|
11400
|
+
return walked(block, table);
|
|
11401
|
+
};
|
|
11402
|
+
rowsOf = (hunk) => blocksOf$1(hunk.rows).flatMap((entry) => isBlock(entry) ? folded(entry) : [entry]);
|
|
11403
|
+
reindexed = (rows, startRow) => rows.map((row, offset) => Object.assign({}, row, { index: startRow + offset }));
|
|
11404
|
+
foldReindents = (hunks) => {
|
|
11405
|
+
const rows = [];
|
|
11406
|
+
const kept = [];
|
|
11407
|
+
for (const hunk of hunks) {
|
|
11408
|
+
const startRow = rows.length;
|
|
11409
|
+
const own = reindexed(rowsOf(hunk), startRow);
|
|
11410
|
+
rows.push(...own);
|
|
11411
|
+
kept.push({
|
|
11412
|
+
...hunk,
|
|
11413
|
+
startRow,
|
|
11414
|
+
rows: own
|
|
11415
|
+
});
|
|
11416
|
+
}
|
|
11417
|
+
return {
|
|
11418
|
+
hunks: kept,
|
|
11419
|
+
rows,
|
|
11420
|
+
added: rows.filter((row) => row.kind === "added").length,
|
|
11421
|
+
removed: rows.filter((row) => row.kind === "removed").length
|
|
11422
|
+
};
|
|
11423
|
+
};
|
|
11424
|
+
}));
|
|
11425
|
+
//#endregion
|
|
11317
11426
|
//#region src/domain/patch/parse.ts
|
|
11318
11427
|
var FILE_MARKER, HUNK_MARKER, BINARY_MARKER, NO_NEWLINE_MARKER, NO_NEWLINE_SAID, BINARY_SAID, MODE_OLD_MARKER, MODE_NEW_MARKER, FILE_ADDED_MARKER, FILE_GONE_MARKER, EMPTY_ADDED_SAID, EMPTY_GONE_SAID, NOTHING_SAID, BLOB_MARKER, OLD_PATH_MARKER, NEW_PATH_MARKER, HUNK_HEADER, FILE_HEADER, SIGNS$1, MADE_SAID, FROM_MARKERS, draftFrom, openHunk, appendRow, appendMarker, readBody, openPlain, told, notesOf$1, readMode, readMeta, readBinary, readHeader, readLine, parsePatches;
|
|
11319
11428
|
var init_parse = __esmMin((() => {
|
|
11320
11429
|
init_dist();
|
|
11430
|
+
init_reindent();
|
|
11321
11431
|
FILE_MARKER = "diff --git ";
|
|
11322
11432
|
HUNK_MARKER = "@@";
|
|
11323
11433
|
BINARY_MARKER = "Binary files ";
|
|
@@ -11497,49 +11607,7 @@ var init_parse = __esmMin((() => {
|
|
|
11497
11607
|
if (draft !== void 0) readLine(draft, line);
|
|
11498
11608
|
}
|
|
11499
11609
|
for (const draft of drafts) told(draft, notesOf$1(draft));
|
|
11500
|
-
return drafts;
|
|
11501
|
-
};
|
|
11502
|
-
}));
|
|
11503
|
-
//#endregion
|
|
11504
|
-
//#region src/domain/patch/reindent.ts
|
|
11505
|
-
var known$1, body, addedByBody, firstAbove, removedWithBody, pairsIn, reindentRows;
|
|
11506
|
-
var init_reindent = __esmMin((() => {
|
|
11507
|
-
known$1 = /* @__PURE__ */ new WeakMap();
|
|
11508
|
-
body = (row) => row.text.trimStart();
|
|
11509
|
-
addedByBody = (rows) => {
|
|
11510
|
-
const found = /* @__PURE__ */ new Map();
|
|
11511
|
-
for (const row of rows) {
|
|
11512
|
-
if (row.kind !== "added" || body(row).length === 0) continue;
|
|
11513
|
-
const text = body(row);
|
|
11514
|
-
const at = found.get(text);
|
|
11515
|
-
if (at === void 0) found.set(text, [row.index]);
|
|
11516
|
-
else at.push(row.index);
|
|
11517
|
-
}
|
|
11518
|
-
return found;
|
|
11519
|
-
};
|
|
11520
|
-
firstAbove = (free, floor) => {
|
|
11521
|
-
while (free.length > 0 && (free[0] ?? -1) <= floor) free.shift();
|
|
11522
|
-
return free.shift();
|
|
11523
|
-
};
|
|
11524
|
-
removedWithBody = (hunk) => hunk.rows.filter((row) => row.kind === "removed" && body(row).length > 0);
|
|
11525
|
-
pairsIn = (hunk, paired) => {
|
|
11526
|
-
const added = addedByBody(hunk.rows);
|
|
11527
|
-
let floor = -1;
|
|
11528
|
-
for (const row of removedWithBody(hunk)) {
|
|
11529
|
-
const match = firstAbove(added.get(body(row)) ?? [], floor);
|
|
11530
|
-
if (match === void 0) continue;
|
|
11531
|
-
floor = match;
|
|
11532
|
-
paired.add(row.index);
|
|
11533
|
-
paired.add(match);
|
|
11534
|
-
}
|
|
11535
|
-
};
|
|
11536
|
-
reindentRows = (patch) => {
|
|
11537
|
-
const had = known$1.get(patch);
|
|
11538
|
-
if (had !== void 0) return had;
|
|
11539
|
-
const paired = /* @__PURE__ */ new Set();
|
|
11540
|
-
for (const hunk of patch.hunks) pairsIn(hunk, paired);
|
|
11541
|
-
known$1.set(patch, paired);
|
|
11542
|
-
return paired;
|
|
11610
|
+
return drafts.map((draft) => Object.assign(draft, foldReindents(draft.hunks)));
|
|
11543
11611
|
};
|
|
11544
11612
|
}));
|
|
11545
11613
|
//#endregion
|
|
@@ -11589,7 +11657,6 @@ var init_sticky = __esmMin((() => {
|
|
|
11589
11657
|
var init_patch = __esmMin((() => {
|
|
11590
11658
|
init_anchor();
|
|
11591
11659
|
init_parse();
|
|
11592
|
-
init_reindent();
|
|
11593
11660
|
init_sticky();
|
|
11594
11661
|
init_model$5();
|
|
11595
11662
|
}));
|
|
@@ -18532,10 +18599,6 @@ var init_theme = __esmMin((() => {
|
|
|
18532
18599
|
removedBg: "#2e1418",
|
|
18533
18600
|
addedGutter: "#1d4a2b",
|
|
18534
18601
|
removedGutter: "#4a1f26",
|
|
18535
|
-
reindentAddedBg: "#0e1c14",
|
|
18536
|
-
reindentRemovedBg: "#1c1216",
|
|
18537
|
-
reindentAddedGutter: "#16351f",
|
|
18538
|
-
reindentRemovedGutter: "#33191e",
|
|
18539
18602
|
pickedOn: "#2b3854",
|
|
18540
18603
|
pickedOnAdded: "#22432f",
|
|
18541
18604
|
pickedOnRemoved: "#4a2733",
|
|
@@ -18581,7 +18644,7 @@ var init_theme = __esmMin((() => {
|
|
|
18581
18644
|
"note.label": { fg: "#7aa2f7" },
|
|
18582
18645
|
default: { fg: ink }
|
|
18583
18646
|
};
|
|
18584
|
-
})), Code, Gap, Comment, Label, DraftLine, ProseLine, $is, $match, isCode, isDraft, isProse, isSaid, isNote, isChrome, WASH,
|
|
18647
|
+
})), Code, Gap, Comment, Label, DraftLine, ProseLine, $is, $match, isCode, isDraft, isProse, isSaid, isNote, isChrome, WASH, NOTE_MIN, OVERSCAN, SIGN_WIDTH, SCROLL_ROWS, PAN_COLUMNS, WAYS, wheelTo, SIGNS, numberFor, DiffView, startsOf, numbered, bareOf, noteKey, keyOf, groupOf, alike, heldAt, sameLine, NO_SPANS, lineStarts, overLine, shifted, acrossLines, firstOfEach, spansByLine, textAt, noteSpans, NOTE_PAINT, wrap, SAID_INDENT, REMARK_MARK$1, remarkHead, HELD_HEAD, commentHead, headOf, spokenLines, heardFrom, answerLines, REMARK_LINES, capped, bodyLines, saidLines, noteLines, REMARK_RULE, noteRows, proseRows, freshLines, proseAt, apart, notesAt, TRAILING, shownText, codeRow, DRAFT_STOP, draftText, draftRows, rowsFor, replacedBy, layout, lineNumbers, BARE_SIGN, signFor, lineSigns, sideLineOf;
|
|
18585
18648
|
var init_diffview = __esmMin((() => {
|
|
18586
18649
|
init_dist();
|
|
18587
18650
|
init_patch();
|
|
@@ -18605,16 +18668,6 @@ var init_diffview = __esmMin((() => {
|
|
|
18605
18668
|
content: RGBA.fromHex(palette.removedBg)
|
|
18606
18669
|
}
|
|
18607
18670
|
};
|
|
18608
|
-
REINDENT_WASH = {
|
|
18609
|
-
added: {
|
|
18610
|
-
gutter: RGBA.fromHex(palette.reindentAddedGutter),
|
|
18611
|
-
content: RGBA.fromHex(palette.reindentAddedBg)
|
|
18612
|
-
},
|
|
18613
|
-
removed: {
|
|
18614
|
-
gutter: RGBA.fromHex(palette.reindentRemovedGutter),
|
|
18615
|
-
content: RGBA.fromHex(palette.reindentRemovedBg)
|
|
18616
|
-
}
|
|
18617
|
-
};
|
|
18618
18671
|
NOTE_MIN = 24;
|
|
18619
18672
|
OVERSCAN = 2;
|
|
18620
18673
|
SIGN_WIDTH = 2;
|
|
@@ -19069,8 +19122,8 @@ var init_diffview = __esmMin((() => {
|
|
|
19069
19122
|
}
|
|
19070
19123
|
this.numbers.setLineColors(colors);
|
|
19071
19124
|
}
|
|
19072
|
-
washOf(kind
|
|
19073
|
-
return
|
|
19125
|
+
washOf(kind) {
|
|
19126
|
+
return WASH[kind];
|
|
19074
19127
|
}
|
|
19075
19128
|
};
|
|
19076
19129
|
startsOf = (display) => {
|
|
@@ -20044,7 +20097,7 @@ var init_paint = __esmMin((() => {
|
|
|
20044
20097
|
if (flags.cursor) return UNDER_CURSOR[kind] ?? PLAIN_CURSOR;
|
|
20045
20098
|
if (flags.selected) return PICKED[kind] ?? PLAIN_PICKED;
|
|
20046
20099
|
if (flags.gap) return GAP_PAINT;
|
|
20047
|
-
return view.washOf(kind
|
|
20100
|
+
return view.washOf(kind);
|
|
20048
20101
|
};
|
|
20049
20102
|
PLAIN_PICKED = {
|
|
20050
20103
|
gutter: RGBA.fromHex(palette.pickedGutter),
|
|
@@ -21458,15 +21511,13 @@ var init_render = __esmMin((() => {
|
|
|
21458
21511
|
const shown = shownOf(state);
|
|
21459
21512
|
const rows = shown?.patch.rows ?? [];
|
|
21460
21513
|
const gaps = shown === void 0 ? /* @__PURE__ */ new Set() : gapRowSet(shown);
|
|
21461
|
-
const reindents = shown === void 0 ? /* @__PURE__ */ new Set() : reindentRows(shown.patch);
|
|
21462
21514
|
return (row) => {
|
|
21463
21515
|
const kind = rows[row]?.kind;
|
|
21464
21516
|
if (kind === void 0) return void 0;
|
|
21465
21517
|
return pickPaint(this.view, kind, {
|
|
21466
21518
|
cursor: row === state.cursor,
|
|
21467
21519
|
selected: selecting && row >= from && row <= to,
|
|
21468
|
-
gap: gaps.has(row)
|
|
21469
|
-
reindent: reindents.has(row)
|
|
21520
|
+
gap: gaps.has(row)
|
|
21470
21521
|
});
|
|
21471
21522
|
};
|
|
21472
21523
|
}
|
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.
|
|
26
|
+
"version": "0.1.0-alpha.179",
|
|
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": {
|