@eliya-oss/agent-diff 0.1.0-alpha.12 → 0.1.0-alpha.13
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/dist/main.js +179 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/main.js
CHANGED
|
@@ -10849,6 +10849,26 @@ const cursorOps = (state, saveState, inbox) => {
|
|
|
10849
10849
|
});
|
|
10850
10850
|
return pending;
|
|
10851
10851
|
}),
|
|
10852
|
+
restage: fn("Store.restage")(function* (worktreePath, comment) {
|
|
10853
|
+
const current = yield* state(worktreePath);
|
|
10854
|
+
if (!current.pending.some((entry) => entry.id === comment.id)) return none();
|
|
10855
|
+
const pending = current.pending.map((entry) => entry.id === comment.id ? comment : entry);
|
|
10856
|
+
yield* saveState(worktreePath, {
|
|
10857
|
+
...current,
|
|
10858
|
+
pending
|
|
10859
|
+
});
|
|
10860
|
+
return some(pending);
|
|
10861
|
+
}),
|
|
10862
|
+
unstage: fn("Store.unstage")(function* (worktreePath, id) {
|
|
10863
|
+
const current = yield* state(worktreePath);
|
|
10864
|
+
if (!current.pending.some((entry) => entry.id === id)) return none();
|
|
10865
|
+
const pending = current.pending.filter((entry) => entry.id !== id);
|
|
10866
|
+
yield* saveState(worktreePath, {
|
|
10867
|
+
...current,
|
|
10868
|
+
pending
|
|
10869
|
+
});
|
|
10870
|
+
return some(pending);
|
|
10871
|
+
}),
|
|
10852
10872
|
take: fn("Store.take")(function* (worktreePath) {
|
|
10853
10873
|
const batches = yield* inbox(worktreePath);
|
|
10854
10874
|
const current = yield* state(worktreePath);
|
|
@@ -11118,6 +11138,25 @@ const stageComment = fn("Cli.stageComment")(function* (request) {
|
|
|
11118
11138
|
};
|
|
11119
11139
|
return { pending: (yield* store.stage(worktree.path, entry)).length };
|
|
11120
11140
|
});
|
|
11141
|
+
const editStaged = fn("Cli.editStaged")(function* (request) {
|
|
11142
|
+
const store = yield* Store;
|
|
11143
|
+
const worktree = yield* findBranch(request.repo, request.branch);
|
|
11144
|
+
const current = yield* store.state(worktree.path);
|
|
11145
|
+
const found = current.pending.find((entry) => entry.id === request.id);
|
|
11146
|
+
if (found === void 0) return yield* new UnknownComment({ id: request.id });
|
|
11147
|
+
const pending = yield* store.restage(worktree.path, {
|
|
11148
|
+
...found,
|
|
11149
|
+
body: request.body
|
|
11150
|
+
});
|
|
11151
|
+
return { pending: getOrElse(pending, () => current.pending).length };
|
|
11152
|
+
});
|
|
11153
|
+
const dropStaged = fn("Cli.dropStaged")(function* (repo, branch, id) {
|
|
11154
|
+
const store = yield* Store;
|
|
11155
|
+
const worktree = yield* findBranch(repo, branch);
|
|
11156
|
+
const pending = yield* store.unstage(worktree.path, id);
|
|
11157
|
+
if (isNone(pending)) return yield* new UnknownComment({ id });
|
|
11158
|
+
return { pending: pending.value.length };
|
|
11159
|
+
});
|
|
11121
11160
|
const listPending = fn("Cli.listPending")(function* (repo, branch) {
|
|
11122
11161
|
const store = yield* Store;
|
|
11123
11162
|
const worktree = yield* findBranch(repo, branch);
|
|
@@ -11131,7 +11170,7 @@ const listPending = fn("Cli.listPending")(function* (repo, branch) {
|
|
|
11131
11170
|
}));
|
|
11132
11171
|
});
|
|
11133
11172
|
const bodyOf = (entry) => entry.body;
|
|
11134
|
-
const sentOf = (comment, spoken, settled) => {
|
|
11173
|
+
const sentOf = (comment, spoken, settled, head) => {
|
|
11135
11174
|
const mine = spoken.filter((entry) => entry.comment === comment.id);
|
|
11136
11175
|
return {
|
|
11137
11176
|
file: comment.file,
|
|
@@ -11140,6 +11179,7 @@ const sentOf = (comment, spoken, settled) => {
|
|
|
11140
11179
|
end: comment.end,
|
|
11141
11180
|
body: comment.body,
|
|
11142
11181
|
settled: Object.hasOwn(settled, comment.id),
|
|
11182
|
+
stale: comment.head !== head,
|
|
11143
11183
|
asks: mine.at(-1)?.asks === true,
|
|
11144
11184
|
answers: mine.map(bodyOf)
|
|
11145
11185
|
};
|
|
@@ -11149,7 +11189,7 @@ const listSent = fn("Cli.listSent")(function* (repo, branch) {
|
|
|
11149
11189
|
const worktree = yield* findBranch(repo, branch);
|
|
11150
11190
|
const spoken = yield* store.answers(worktree.path);
|
|
11151
11191
|
const current = yield* store.state(worktree.path);
|
|
11152
|
-
return flatten(yield* store.inbox(worktree.path)).map((comment) => sentOf(comment, spoken, current.settled));
|
|
11192
|
+
return flatten(yield* store.inbox(worktree.path)).map((comment) => sentOf(comment, spoken, current.settled, worktree.head));
|
|
11153
11193
|
});
|
|
11154
11194
|
const submitReview = fn("Cli.submitReview")(function* (repo, branch, id, at) {
|
|
11155
11195
|
const store = yield* Store;
|
|
@@ -11705,6 +11745,46 @@ const catalog = [
|
|
|
11705
11745
|
dataKey: "pending",
|
|
11706
11746
|
example: "adiff comment stage --repo . --branch cdr-1 --file src/api.ts --start 4 --end 4 --body \"why\""
|
|
11707
11747
|
},
|
|
11748
|
+
{
|
|
11749
|
+
name: "comment edit",
|
|
11750
|
+
about: "Reword a staged comment. It keeps its id and the lines it was written against",
|
|
11751
|
+
safety: "write",
|
|
11752
|
+
options: [
|
|
11753
|
+
repo,
|
|
11754
|
+
branch,
|
|
11755
|
+
{
|
|
11756
|
+
name: "id",
|
|
11757
|
+
required: true,
|
|
11758
|
+
value: "id",
|
|
11759
|
+
about: "The staged comment, as `review progress` reported it"
|
|
11760
|
+
},
|
|
11761
|
+
{
|
|
11762
|
+
name: "body",
|
|
11763
|
+
required: true,
|
|
11764
|
+
value: "text",
|
|
11765
|
+
about: "What it should say instead"
|
|
11766
|
+
}
|
|
11767
|
+
],
|
|
11768
|
+
dataKey: "pending",
|
|
11769
|
+
example: "adiff comment edit --repo . --branch add-teammate-invitations --id c1 --body \"why is this unused\""
|
|
11770
|
+
},
|
|
11771
|
+
{
|
|
11772
|
+
name: "comment drop",
|
|
11773
|
+
about: "Take a staged comment out of the review before it is sent",
|
|
11774
|
+
safety: "write",
|
|
11775
|
+
options: [
|
|
11776
|
+
repo,
|
|
11777
|
+
branch,
|
|
11778
|
+
{
|
|
11779
|
+
name: "id",
|
|
11780
|
+
required: true,
|
|
11781
|
+
value: "id",
|
|
11782
|
+
about: "The staged comment to withdraw"
|
|
11783
|
+
}
|
|
11784
|
+
],
|
|
11785
|
+
dataKey: "pending",
|
|
11786
|
+
example: "adiff comment drop --repo . --branch add-teammate-invitations --id c1"
|
|
11787
|
+
},
|
|
11708
11788
|
{
|
|
11709
11789
|
name: "comment take",
|
|
11710
11790
|
about: "Collect the comments this worktree has not been handed yet. Exactly-once",
|
|
@@ -11907,7 +11987,7 @@ const ADVICE = {
|
|
|
11907
11987
|
},
|
|
11908
11988
|
UnknownComment: {
|
|
11909
11989
|
exit: 3,
|
|
11910
|
-
suggestion: "No comment carries that id.
|
|
11990
|
+
suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment threads` reports every id on a branch.",
|
|
11911
11991
|
retriable: false
|
|
11912
11992
|
},
|
|
11913
11993
|
UnselectableRange: {
|
|
@@ -12325,6 +12405,7 @@ const initialState = (branches) => ({
|
|
|
12325
12405
|
pending: [],
|
|
12326
12406
|
sent: [],
|
|
12327
12407
|
pendingIndex: 0,
|
|
12408
|
+
editing: void 0,
|
|
12328
12409
|
viewport: 20,
|
|
12329
12410
|
context: 3,
|
|
12330
12411
|
top: 0,
|
|
@@ -12498,7 +12579,13 @@ const lineOf = (row) => match$2(row.newLine, {
|
|
|
12498
12579
|
onNone: () => "-",
|
|
12499
12580
|
onSome: (line) => String(line)
|
|
12500
12581
|
});
|
|
12582
|
+
const editedComment = (state) => state.editing === void 0 ? void 0 : state.pending.find((entry) => entry.id === state.editing);
|
|
12501
12583
|
const composeTarget = (state) => {
|
|
12584
|
+
const edited = editedComment(state);
|
|
12585
|
+
if (edited !== void 0) {
|
|
12586
|
+
const span = edited.start === edited.end ? `${edited.start}` : `${edited.start}-${edited.end}`;
|
|
12587
|
+
return `Comment on ${edited.file}:${span}`;
|
|
12588
|
+
}
|
|
12502
12589
|
const patch = selectedPatch(state);
|
|
12503
12590
|
if (patch === void 0) return "";
|
|
12504
12591
|
const [from, to] = selectionRange(state);
|
|
@@ -12875,6 +12962,22 @@ const commands = [
|
|
|
12875
12962
|
hint: "send",
|
|
12876
12963
|
listed: false
|
|
12877
12964
|
}),
|
|
12965
|
+
command({
|
|
12966
|
+
action: "pending.edit",
|
|
12967
|
+
title: "Reword this comment",
|
|
12968
|
+
category: "Review",
|
|
12969
|
+
keys: ["e"],
|
|
12970
|
+
screens: ["pending"],
|
|
12971
|
+
hint: "reword"
|
|
12972
|
+
}),
|
|
12973
|
+
command({
|
|
12974
|
+
action: "pending.drop",
|
|
12975
|
+
title: "Withdraw this comment",
|
|
12976
|
+
category: "Review",
|
|
12977
|
+
keys: ["X"],
|
|
12978
|
+
screens: ["pending"],
|
|
12979
|
+
hint: "withdraw"
|
|
12980
|
+
}),
|
|
12878
12981
|
command({
|
|
12879
12982
|
action: "pending.next",
|
|
12880
12983
|
title: "Next staged comment",
|
|
@@ -13198,6 +13301,8 @@ const transitions = {
|
|
|
13198
13301
|
"compose.stage": (state) => state,
|
|
13199
13302
|
"pending.open": (state) => state,
|
|
13200
13303
|
"pending.submit": (state) => state,
|
|
13304
|
+
"pending.edit": (state) => state,
|
|
13305
|
+
"pending.drop": (state) => state,
|
|
13201
13306
|
"pending.next": (state) => movePending(state, 1),
|
|
13202
13307
|
"pending.prev": (state) => movePending(state, -1),
|
|
13203
13308
|
"compose.newline": (state) => ({
|
|
@@ -13372,6 +13477,10 @@ const paletteClosed = (state) => ({
|
|
|
13372
13477
|
screen: state.returnTo,
|
|
13373
13478
|
query: ""
|
|
13374
13479
|
});
|
|
13480
|
+
const withNoticeHere = (state, notice) => ({
|
|
13481
|
+
...state,
|
|
13482
|
+
notice
|
|
13483
|
+
});
|
|
13375
13484
|
const withNotice = (state, notice) => ({
|
|
13376
13485
|
...state,
|
|
13377
13486
|
screen: "review",
|
|
@@ -13780,10 +13889,12 @@ const wrap = (text, room) => {
|
|
|
13780
13889
|
return lines;
|
|
13781
13890
|
};
|
|
13782
13891
|
const headOf = (note) => {
|
|
13783
|
-
|
|
13784
|
-
if (note.
|
|
13785
|
-
if (note.
|
|
13786
|
-
|
|
13892
|
+
const moved = note.stale ? ", the branch moved on" : "";
|
|
13893
|
+
if (note.settled) return `${marks().sent} settled${moved}`;
|
|
13894
|
+
if (note.asks) return `${marks().staged} asked back${moved}`;
|
|
13895
|
+
if (note.answers.length > 0) return `${marks().sent} answered${moved}`;
|
|
13896
|
+
if (note.sent) return `${marks().sent} sent${moved}`;
|
|
13897
|
+
return `${marks().staged} staged`;
|
|
13787
13898
|
};
|
|
13788
13899
|
const spokenLines = (body, room) => {
|
|
13789
13900
|
return wrap(body.replaceAll("\n", " "), Math.max(NOTE_MIN, room - 2)).map((text, at) => at === 0 ? `${ANSWER_MARK} ${text}` : ` ${text}`);
|
|
@@ -14164,6 +14275,7 @@ const notesOf = (comments, path, sent) => comments.filter((entry) => entry.file
|
|
|
14164
14275
|
body: entry.body,
|
|
14165
14276
|
sent,
|
|
14166
14277
|
settled: entry.settled === true,
|
|
14278
|
+
stale: entry.stale === true,
|
|
14167
14279
|
asks: entry.asks === true,
|
|
14168
14280
|
answers: entry.answers ?? []
|
|
14169
14281
|
}));
|
|
@@ -14876,6 +14988,8 @@ var App = class {
|
|
|
14876
14988
|
"file.vouch.next": () => this.vouch(true),
|
|
14877
14989
|
"review.reload": () => this.reloadBranch(),
|
|
14878
14990
|
"pending.open": () => this.openPending(),
|
|
14991
|
+
"pending.edit": () => this.editStagedComment(),
|
|
14992
|
+
"pending.drop": () => this.dropStagedComment(),
|
|
14879
14993
|
"pending.submit": () => this.sendReview(),
|
|
14880
14994
|
"report.open": () => this.commit(reduce(this.measured(), "report.open")),
|
|
14881
14995
|
back: () => this.goBack(),
|
|
@@ -15004,6 +15118,8 @@ var App = class {
|
|
|
15004
15118
|
};
|
|
15005
15119
|
}
|
|
15006
15120
|
async stage() {
|
|
15121
|
+
const editing = this.state.editing;
|
|
15122
|
+
if (editing !== void 0) return this.restage(editing);
|
|
15007
15123
|
const request = this.request();
|
|
15008
15124
|
if (request === void 0) return this.commit(withNotice(this.state, "nothing to stage"));
|
|
15009
15125
|
await this.run(stageComment(request));
|
|
@@ -15012,6 +15128,23 @@ var App = class {
|
|
|
15012
15128
|
const next = withPending(this.state, pending, "review");
|
|
15013
15129
|
this.commit(withNotice(next, `${pending.length} staged`));
|
|
15014
15130
|
}
|
|
15131
|
+
async restage(id) {
|
|
15132
|
+
const branch = selectedBranch(this.state);
|
|
15133
|
+
if (branch === void 0) return;
|
|
15134
|
+
await this.run(editStaged({
|
|
15135
|
+
repo: this.repo,
|
|
15136
|
+
branch: branch.branch,
|
|
15137
|
+
id,
|
|
15138
|
+
body: this.state.draft
|
|
15139
|
+
}));
|
|
15140
|
+
const pending = await this.run(listPending(this.repo, branch.branch));
|
|
15141
|
+
const next = withPending({
|
|
15142
|
+
...this.state,
|
|
15143
|
+
editing: void 0,
|
|
15144
|
+
draft: ""
|
|
15145
|
+
}, pending, "pending");
|
|
15146
|
+
this.commit(withNoticeHere(next, "reworded"));
|
|
15147
|
+
}
|
|
15015
15148
|
loadSent(branch) {
|
|
15016
15149
|
return this.run(listSent(this.repo, branch));
|
|
15017
15150
|
}
|
|
@@ -15047,6 +15180,30 @@ var App = class {
|
|
|
15047
15180
|
if (pending.length === 0) return this.commit(withNotice(this.state, "nothing staged"));
|
|
15048
15181
|
this.commit(withPending(this.state, pending, "pending"));
|
|
15049
15182
|
}
|
|
15183
|
+
editStagedComment() {
|
|
15184
|
+
const entry = this.state.pending[this.state.pendingIndex];
|
|
15185
|
+
if (entry?.id === void 0) return;
|
|
15186
|
+
this.commit({
|
|
15187
|
+
...this.state,
|
|
15188
|
+
screen: "compose",
|
|
15189
|
+
draft: entry.body,
|
|
15190
|
+
editing: entry.id
|
|
15191
|
+
});
|
|
15192
|
+
}
|
|
15193
|
+
async dropStagedComment() {
|
|
15194
|
+
const branch = selectedBranch(this.state);
|
|
15195
|
+
const entry = this.state.pending[this.state.pendingIndex];
|
|
15196
|
+
if (branch === void 0 || entry?.id === void 0) return;
|
|
15197
|
+
await this.run(dropStaged(this.repo, branch.branch, entry.id));
|
|
15198
|
+
const pending = await this.run(listPending(this.repo, branch.branch));
|
|
15199
|
+
const kept = withPending(this.state, pending, pending.length === 0 ? "review" : "pending");
|
|
15200
|
+
const at = Math.min(this.state.pendingIndex, Math.max(0, pending.length - 1));
|
|
15201
|
+
const said = pending.length === 0 ? "nothing staged" : `withdrawn — ${pending.length} left`;
|
|
15202
|
+
this.commit(withNoticeHere({
|
|
15203
|
+
...kept,
|
|
15204
|
+
pendingIndex: at
|
|
15205
|
+
}, said));
|
|
15206
|
+
}
|
|
15050
15207
|
async sendReview() {
|
|
15051
15208
|
const branch = selectedBranch(this.state);
|
|
15052
15209
|
if (branch === void 0) return;
|
|
@@ -15192,6 +15349,19 @@ const commentStage = fn("Main.commentStage")(function* (options) {
|
|
|
15192
15349
|
});
|
|
15193
15350
|
yield* answer(options, { pending: report.pending });
|
|
15194
15351
|
});
|
|
15352
|
+
const commentEdit = fn("Main.commentEdit")(function* (options) {
|
|
15353
|
+
const report = yield* editStaged({
|
|
15354
|
+
repo: yield* required(options, "repo"),
|
|
15355
|
+
branch: yield* required(options, "branch"),
|
|
15356
|
+
id: yield* required(options, "id"),
|
|
15357
|
+
body: yield* required(options, "body")
|
|
15358
|
+
});
|
|
15359
|
+
yield* answer(options, { pending: report.pending });
|
|
15360
|
+
});
|
|
15361
|
+
const commentDrop = fn("Main.commentDrop")(function* (options) {
|
|
15362
|
+
const report = yield* dropStaged(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
|
|
15363
|
+
yield* answer(options, { pending: report.pending });
|
|
15364
|
+
});
|
|
15195
15365
|
const reviewSubmit = fn("Main.reviewSubmit")(function* (options) {
|
|
15196
15366
|
const report = yield* submitReview(yield* required(options, "repo"), yield* required(options, "branch"), options["id"] ?? randomUUID(), options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
15197
15367
|
yield* answer(options, { submitted: report.submitted });
|
|
@@ -15225,6 +15395,8 @@ const routes = {
|
|
|
15225
15395
|
"branch list": branchList,
|
|
15226
15396
|
"comment add": commentAdd,
|
|
15227
15397
|
"comment stage": commentStage,
|
|
15398
|
+
"comment edit": commentEdit,
|
|
15399
|
+
"comment drop": commentDrop,
|
|
15228
15400
|
"comment take": commentTake,
|
|
15229
15401
|
"comment answer": commentAnswer,
|
|
15230
15402
|
"comment threads": commentThreads,
|
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.13",
|
|
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": {
|