@eliya-oss/agent-diff 0.1.0-alpha.17 → 0.1.0-alpha.18
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 +6 -0
- package/README.md +2 -0
- package/dist/main.js +85 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -9,6 +9,8 @@ comment, and the agent picks it up.
|
|
|
9
9
|
<pre align="center">brew install Newbie012/tap/adiff
|
|
10
10
|
npm i -g @eliya-oss/agent-diff@alpha</pre>
|
|
11
11
|
|
|
12
|
+
<img src="assets/terminal.webp" alt="The adiff worktree list, showing seven branches with their sizes, layers and review state" width="820">
|
|
13
|
+
|
|
12
14
|
</div>
|
|
13
15
|
|
|
14
16
|
## Usage
|
package/dist/main.js
CHANGED
|
@@ -12429,6 +12429,8 @@ const initialState = (branches) => ({
|
|
|
12429
12429
|
patches: [],
|
|
12430
12430
|
patchIndex: 0,
|
|
12431
12431
|
cursor: 0,
|
|
12432
|
+
stop: 0,
|
|
12433
|
+
opened: [],
|
|
12432
12434
|
anchorRow: 0,
|
|
12433
12435
|
selecting: false,
|
|
12434
12436
|
draft: "",
|
|
@@ -12679,6 +12681,14 @@ const commentRowsIn = (state, fileIndex) => {
|
|
|
12679
12681
|
const notes = [...state.pending, ...state.sent].filter((entry) => entry.file === patch.path);
|
|
12680
12682
|
return patch.rows.filter((row) => notes.some((note) => lineOnSide(row, note.side) === note.end)).map((row) => row.index).toSorted((left, right) => left - right);
|
|
12681
12683
|
};
|
|
12684
|
+
const threadsAtRow = (state, row) => {
|
|
12685
|
+
const patch = selectedPatch(state);
|
|
12686
|
+
const here = patch?.rows[row];
|
|
12687
|
+
if (patch === void 0 || here === void 0) return [];
|
|
12688
|
+
return state.sent.filter((entry) => entry.file === patch.path && entry.id !== void 0 && lineOnSide(here, entry.side) === entry.end);
|
|
12689
|
+
};
|
|
12690
|
+
const stopsAtRow = (state, row) => 1 + threadsAtRow(state, row).length;
|
|
12691
|
+
const threadAtStop = (state) => state.stop === 0 ? void 0 : threadsAtRow(state, state.cursor)[state.stop - 1];
|
|
12682
12692
|
const threadAtRow = (state, row) => {
|
|
12683
12693
|
const patch = selectedPatch(state);
|
|
12684
12694
|
const here = patch?.rows[row];
|
|
@@ -13019,14 +13029,14 @@ const commands = [
|
|
|
13019
13029
|
}),
|
|
13020
13030
|
command({
|
|
13021
13031
|
action: "tree.collapse",
|
|
13022
|
-
title: "Close the folder, layer, or
|
|
13032
|
+
title: "Close the folder, layer, gap, or settled thread",
|
|
13023
13033
|
category: "Files",
|
|
13024
13034
|
keys: ["h"],
|
|
13025
13035
|
screens: ["review"]
|
|
13026
13036
|
}),
|
|
13027
13037
|
command({
|
|
13028
13038
|
action: "tree.expand",
|
|
13029
|
-
title: "Open the folder, layer, or
|
|
13039
|
+
title: "Open the folder, layer, gap, or settled thread",
|
|
13030
13040
|
category: "Files",
|
|
13031
13041
|
keys: ["l"],
|
|
13032
13042
|
screens: ["review"]
|
|
@@ -13255,8 +13265,31 @@ const withCursorVisible = (state) => {
|
|
|
13255
13265
|
};
|
|
13256
13266
|
const moveCursor = (state, delta) => withCursorVisible({
|
|
13257
13267
|
...state,
|
|
13268
|
+
stop: 0,
|
|
13258
13269
|
cursor: clamp(state.cursor + delta, 0, lastRow(selectedPatch(state)))
|
|
13259
13270
|
});
|
|
13271
|
+
const stepStop = (state, delta) => {
|
|
13272
|
+
const here = stopsAtRow(state, state.cursor) - 1;
|
|
13273
|
+
if (delta > 0 && state.stop < here) return {
|
|
13274
|
+
...state,
|
|
13275
|
+
stop: state.stop + 1
|
|
13276
|
+
};
|
|
13277
|
+
if (delta < 0 && state.stop > 0) return {
|
|
13278
|
+
...state,
|
|
13279
|
+
stop: state.stop - 1
|
|
13280
|
+
};
|
|
13281
|
+
const row = clamp(state.cursor + delta, 0, lastRow(selectedPatch(state)));
|
|
13282
|
+
if (row === state.cursor) return state;
|
|
13283
|
+
const landing = delta < 0 ? stopsAtRow({
|
|
13284
|
+
...state,
|
|
13285
|
+
cursor: row
|
|
13286
|
+
}, row) - 1 : 0;
|
|
13287
|
+
return withCursorVisible({
|
|
13288
|
+
...state,
|
|
13289
|
+
cursor: row,
|
|
13290
|
+
stop: landing
|
|
13291
|
+
});
|
|
13292
|
+
};
|
|
13260
13293
|
const scrolled = (state, delta) => {
|
|
13261
13294
|
const highest = Math.max(0, rowsIn(state) - Math.max(1, state.viewport));
|
|
13262
13295
|
return {
|
|
@@ -13272,6 +13305,7 @@ const draggedTo = (state, from, to) => ({
|
|
|
13272
13305
|
});
|
|
13273
13306
|
const atRow = (state, row) => withCursorVisible({
|
|
13274
13307
|
...state,
|
|
13308
|
+
stop: 0,
|
|
13275
13309
|
cursor: clamp(row, 0, lastRow(selectedPatch(state)))
|
|
13276
13310
|
});
|
|
13277
13311
|
const layerHunk = (state, delta) => {
|
|
@@ -13338,7 +13372,7 @@ const moveLayer = (state, delta) => {
|
|
|
13338
13372
|
};
|
|
13339
13373
|
};
|
|
13340
13374
|
const inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
|
|
13341
|
-
const layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) :
|
|
13375
|
+
const layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : stepStop(state, delta);
|
|
13342
13376
|
const toggleRail = (state) => {
|
|
13343
13377
|
if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
|
|
13344
13378
|
if (state.rail === "layers") return {
|
|
@@ -13367,7 +13401,18 @@ const foldLayer = (state, shut) => {
|
|
|
13367
13401
|
openLayers: shut ? open : [...open, state.layerIndex]
|
|
13368
13402
|
};
|
|
13369
13403
|
};
|
|
13370
|
-
const
|
|
13404
|
+
const foldThread = (state, shut, id) => {
|
|
13405
|
+
const rest = state.opened.filter((held) => held !== id);
|
|
13406
|
+
return {
|
|
13407
|
+
...state,
|
|
13408
|
+
opened: shut ? rest : [...rest, id]
|
|
13409
|
+
};
|
|
13410
|
+
};
|
|
13411
|
+
const fold = (state, shut) => {
|
|
13412
|
+
const thread = threadAtStop(state);
|
|
13413
|
+
if (thread?.id !== void 0 && thread.settled === true) return foldThread(state, shut, thread.id);
|
|
13414
|
+
return onLayers(state) ? foldLayer(state, shut) : foldDirectory(state, shut);
|
|
13415
|
+
};
|
|
13371
13416
|
const moveBranch = (state, delta) => ({
|
|
13372
13417
|
...state,
|
|
13373
13418
|
branchIndex: clamp(state.branchIndex + delta, 0, Math.max(0, state.branches.length - 1))
|
|
@@ -14091,6 +14136,15 @@ var DiffView = class {
|
|
|
14091
14136
|
const at = Math.max(0, Math.min(this.display.length - 1, line));
|
|
14092
14137
|
return this.display[at]?.row ?? 0;
|
|
14093
14138
|
}
|
|
14139
|
+
stopAt(visual) {
|
|
14140
|
+
return this.display[this.lineAt(visual)]?.stop ?? 0;
|
|
14141
|
+
}
|
|
14142
|
+
carries(visual) {
|
|
14143
|
+
const entry = this.display[this.lineAt(visual)];
|
|
14144
|
+
if (entry === void 0) return false;
|
|
14145
|
+
if (entry.prose) return false;
|
|
14146
|
+
return true;
|
|
14147
|
+
}
|
|
14094
14148
|
isComment(visual) {
|
|
14095
14149
|
const entry = this.display[this.lineAt(visual)];
|
|
14096
14150
|
return entry?.comment === true || entry?.prose === true;
|
|
@@ -14134,7 +14188,7 @@ const startsOf = (display) => {
|
|
|
14134
14188
|
const bareOf = (display) => new Set(display.flatMap((entry, index) => entry.comment || entry.gap || entry.prose ? [index] : []));
|
|
14135
14189
|
const keyOf = (room, notes, prose) => [
|
|
14136
14190
|
room,
|
|
14137
|
-
...notes.map((note) => `${note.side}${note.line}:${note.body}`),
|
|
14191
|
+
...notes.map((note) => `${note.side}${note.line}:${note.folded ? "-" : "+"}${note.body}`),
|
|
14138
14192
|
...prose.map((entry) => `p${entry.line}${entry.after ? ">" : "<"}:${entry.markdown}`)
|
|
14139
14193
|
].join("\0");
|
|
14140
14194
|
const groupOf = (entry) => {
|
|
@@ -14189,14 +14243,15 @@ const spokenLines = (body, room) => {
|
|
|
14189
14243
|
return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
|
|
14190
14244
|
};
|
|
14191
14245
|
const answerLines = (note, room) => note.answers.flatMap((body) => spokenLines(body, room));
|
|
14192
|
-
const noteLines = (note, room) => [
|
|
14246
|
+
const noteLines = (note, room) => note.folded ? [`${headOf(note)} · press l`] : [
|
|
14193
14247
|
headOf(note),
|
|
14194
14248
|
...note.body.split("\n").flatMap((line) => wrap(line, room)),
|
|
14195
14249
|
...answerLines(note, room)
|
|
14196
14250
|
];
|
|
14197
|
-
const noteRows = (note, row, room) => noteLines(note, room).map((line, index) => ({
|
|
14251
|
+
const noteRows = (note, row, room, stop) => noteLines(note, room).map((line, index) => ({
|
|
14198
14252
|
text: `${marks().rule} ${line}`,
|
|
14199
14253
|
row,
|
|
14254
|
+
stop,
|
|
14200
14255
|
comment: true,
|
|
14201
14256
|
sent: note.sent,
|
|
14202
14257
|
label: index === 0,
|
|
@@ -14206,6 +14261,7 @@ const noteRows = (note, row, room) => noteLines(note, room).map((line, index) =>
|
|
|
14206
14261
|
const proseRows = (entry, row, room) => [...entry.markdown.split("\n").flatMap((line) => wrap(line, room - 2)), ""].map((line) => ({
|
|
14207
14262
|
text: line.length === 0 ? "" : ` ${line}`,
|
|
14208
14263
|
row,
|
|
14264
|
+
stop: 0,
|
|
14209
14265
|
comment: false,
|
|
14210
14266
|
sent: false,
|
|
14211
14267
|
label: false,
|
|
@@ -14217,10 +14273,11 @@ const proseAt = (plan, row, after) => {
|
|
|
14217
14273
|
if (line === void 0) return [];
|
|
14218
14274
|
return plan.prose.filter((entry) => entry.after === after && entry.line === line);
|
|
14219
14275
|
};
|
|
14220
|
-
const notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note) => noteRows(note, row.index, plan.room));
|
|
14276
|
+
const notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note, at) => noteRows(note, row.index, plan.room, at + 1));
|
|
14221
14277
|
const codeRow = (plan, row) => ({
|
|
14222
14278
|
text: row.text,
|
|
14223
14279
|
row: row.index,
|
|
14280
|
+
stop: 0,
|
|
14224
14281
|
comment: false,
|
|
14225
14282
|
sent: false,
|
|
14226
14283
|
label: false,
|
|
@@ -14558,7 +14615,10 @@ const waitingLabel = (branch) => {
|
|
|
14558
14615
|
if (branch.staged > 0) return `${branch.staged} staged`;
|
|
14559
14616
|
return branch.unread > 0 ? `${branch.unread} unread` : "";
|
|
14560
14617
|
};
|
|
14561
|
-
const
|
|
14618
|
+
const inRange = (state, row, from, to) => state.selecting && row >= from && row <= to;
|
|
14619
|
+
const notesOf = (comments, path, sent, opened = []) => comments.filter((entry) => entry.file === path).map((entry) => ({
|
|
14620
|
+
id: entry.id ?? "",
|
|
14621
|
+
folded: entry.settled === true && !(entry.id !== void 0 && opened.includes(entry.id)),
|
|
14562
14622
|
side: entry.side,
|
|
14563
14623
|
line: entry.end,
|
|
14564
14624
|
body: entry.body,
|
|
@@ -14568,7 +14628,7 @@ const notesOf = (comments, path, sent) => comments.filter((entry) => entry.file
|
|
|
14568
14628
|
asks: entry.asks === true,
|
|
14569
14629
|
answers: entry.answers ?? []
|
|
14570
14630
|
}));
|
|
14571
|
-
const notesFor = (state, path) => [...notesOf(state.sent, path, true), ...notesOf(state.pending, path, false)];
|
|
14631
|
+
const notesFor = (state, path) => [...notesOf(state.sent, path, true, state.opened), ...notesOf(state.pending, path, false)];
|
|
14572
14632
|
const paired = (chunks) => {
|
|
14573
14633
|
const chips = [];
|
|
14574
14634
|
for (let at = 0; at < chunks.length; at += CHIP_CHUNKS) chips.push(chunks.slice(at, at + CHIP_CHUNKS));
|
|
@@ -15059,12 +15119,15 @@ var Screen = class {
|
|
|
15059
15119
|
const [from, to] = selectionRange(state);
|
|
15060
15120
|
const marked = markedRows(state);
|
|
15061
15121
|
const drawn = this.view.drawn();
|
|
15062
|
-
const bare = (visual) => visual >= drawn || this.view.
|
|
15063
|
-
const
|
|
15064
|
-
|
|
15065
|
-
const
|
|
15066
|
-
|
|
15067
|
-
|
|
15122
|
+
const bare = (visual) => visual >= drawn || !this.view.carries(visual) || this.view.isRunOn(visual);
|
|
15123
|
+
const held = (visual) => {
|
|
15124
|
+
const row = this.view.rowAt(visual);
|
|
15125
|
+
const onCode = this.view.stopAt(visual) === 0;
|
|
15126
|
+
const standing = row === state.cursor && this.view.stopAt(visual) === state.stop;
|
|
15127
|
+
const within = onCode && inRange(state, row, from, to);
|
|
15128
|
+
return `${standing || within ? marks().cursor : " "}${onCode && marked.has(row) ? marks().comment : " "}`;
|
|
15129
|
+
};
|
|
15130
|
+
const rows = Array.from({ length: height }, (_, index) => bare(top + index) ? " " : held(top + index));
|
|
15068
15131
|
this.gutter.content = rows.join("\n");
|
|
15069
15132
|
}
|
|
15070
15133
|
paintSticky(state, top) {
|
|
@@ -15409,11 +15472,15 @@ var App = class {
|
|
|
15409
15472
|
}
|
|
15410
15473
|
async settleHere() {
|
|
15411
15474
|
const branch = selectedBranch(this.state);
|
|
15412
|
-
const id = threadAtRow(this.state, this.state.cursor)?.id;
|
|
15475
|
+
const id = (threadAtStop(this.state) ?? threadAtRow(this.state, this.state.cursor))?.id;
|
|
15413
15476
|
if (branch === void 0 || id === void 0) return this.commit(withNotice(this.state, "no thread here"));
|
|
15414
15477
|
await this.run(settleThread(this.repo, branch.branch, id, (/* @__PURE__ */ new Date()).toISOString()));
|
|
15415
15478
|
const sent = await this.loadSent(branch.branch);
|
|
15416
|
-
|
|
15479
|
+
const held = withSent({
|
|
15480
|
+
...this.state,
|
|
15481
|
+
opened: this.state.opened.filter((was) => was !== id)
|
|
15482
|
+
}, sent);
|
|
15483
|
+
this.commit(withNotice(held, "settled"));
|
|
15417
15484
|
}
|
|
15418
15485
|
async reloadList() {
|
|
15419
15486
|
const here = selectedBranch(this.state)?.branch;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"bin": {
|
|
22
22
|
"adiff": "./bin/adiff.js"
|
|
23
23
|
},
|
|
24
|
-
"version": "0.1.0-alpha.
|
|
24
|
+
"version": "0.1.0-alpha.18",
|
|
25
25
|
"description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": {
|