@eliya-oss/agent-diff 0.1.0-alpha.107 → 0.1.0-alpha.108
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 +8 -0
- package/dist/main.js +1042 -662
- package/package.json +1 -1
- package/skills/adiff/SKILL.md +49 -1
package/dist/main.js
CHANGED
|
@@ -2,8 +2,8 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { appendFile, mkdir, readFile, realpath, rename, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { homedir, hostname, platform } from "node:os";
|
|
4
4
|
import { text } from "node:stream/consumers";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
6
5
|
import { execFile, spawn } from "node:child_process";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
@@ -8214,543 +8214,279 @@ var init_dist = __esmMin((() => {
|
|
|
8214
8214
|
init_schema$1();
|
|
8215
8215
|
init_SubscriptionRef();
|
|
8216
8216
|
init_Utils();
|
|
8217
|
-
})), lineOn;
|
|
8218
|
-
var init_model$5 = __esmMin((() => {
|
|
8219
|
-
init_dist();
|
|
8220
|
-
String$1.pipe(brand("@adiff/Blob"));
|
|
8221
|
-
String$1.pipe(brand("@adiff/FilePath"));
|
|
8222
|
-
lineOn = (row, side) => side === "new" ? row.newLine : row.oldLine;
|
|
8223
8217
|
}));
|
|
8224
8218
|
//#endregion
|
|
8225
|
-
//#region src/
|
|
8226
|
-
var
|
|
8227
|
-
var
|
|
8219
|
+
//#region src/service/forge/error.ts
|
|
8220
|
+
var ForgeUnavailable;
|
|
8221
|
+
var init_error$3 = __esmMin((() => {
|
|
8228
8222
|
init_dist();
|
|
8229
|
-
|
|
8230
|
-
sideOf = (rows) => rows.some((row) => isSome(row.newLine)) ? "new" : "old";
|
|
8231
|
-
linesOn = (rows, side) => rows.flatMap((row) => match$3(lineOn(row, side), {
|
|
8232
|
-
onNone: () => [],
|
|
8233
|
-
onSome: (n) => [n]
|
|
8234
|
-
}));
|
|
8235
|
-
anchorFor = (patch, from, to) => {
|
|
8236
|
-
const [low, high] = from <= to ? [from, to] : [to, from];
|
|
8237
|
-
const rows = patch.rows.slice(low, high + 1);
|
|
8238
|
-
if (rows.length === 0) return none();
|
|
8239
|
-
const side = sideOf(rows);
|
|
8240
|
-
const lines = linesOn(rows, side);
|
|
8241
|
-
if (lines.length === 0) return none();
|
|
8242
|
-
return some({
|
|
8243
|
-
path: patch.path,
|
|
8244
|
-
blob: patch.blob,
|
|
8245
|
-
side,
|
|
8246
|
-
start: Math.min(...lines),
|
|
8247
|
-
end: Math.max(...lines),
|
|
8248
|
-
snippet: rows.map((row) => row.text).join("\n")
|
|
8249
|
-
});
|
|
8250
|
-
};
|
|
8223
|
+
ForgeUnavailable = class extends TaggedError("ForgeUnavailable") {};
|
|
8251
8224
|
}));
|
|
8252
8225
|
//#endregion
|
|
8253
|
-
//#region src/
|
|
8254
|
-
var
|
|
8255
|
-
var
|
|
8226
|
+
//#region src/service/forge/service.ts
|
|
8227
|
+
var Forge, LIMIT, TIMEOUT_MS$1, SEND_TIMEOUT_MS, MOST_OUTPUT, FIELDS$1, Row, decode, stateOf$1, ask, show, read, pulls, openPull, NUMBER_FIELDS, Named, readNamed, gh, named, head, bodyFor, review, ForgeLive;
|
|
8228
|
+
var init_service$2 = __esmMin((() => {
|
|
8256
8229
|
init_dist();
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
};
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
return
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
headerLines: [line],
|
|
8276
|
-
hunks: [],
|
|
8277
|
-
rows: [],
|
|
8278
|
-
added: 0,
|
|
8279
|
-
removed: 0,
|
|
8280
|
-
oldLine: 1,
|
|
8281
|
-
newLine: 1
|
|
8282
|
-
};
|
|
8230
|
+
init_error$3();
|
|
8231
|
+
Forge = class extends Service()("adiff/Forge") {};
|
|
8232
|
+
LIMIT = "200";
|
|
8233
|
+
TIMEOUT_MS$1 = 4e3;
|
|
8234
|
+
SEND_TIMEOUT_MS = 2e4;
|
|
8235
|
+
MOST_OUTPUT = 4194304;
|
|
8236
|
+
FIELDS$1 = "headRefName,state,isDraft";
|
|
8237
|
+
Row = Struct({
|
|
8238
|
+
headRefName: String$1,
|
|
8239
|
+
state: String$1,
|
|
8240
|
+
isDraft: Boolean
|
|
8241
|
+
});
|
|
8242
|
+
decode = decodeUnknownEffect(ArraySchema(Row));
|
|
8243
|
+
stateOf$1 = (row) => {
|
|
8244
|
+
if (row.isDraft && row.state === "OPEN") return "draft";
|
|
8245
|
+
if (row.state === "MERGED") return "merged";
|
|
8246
|
+
if (row.state === "CLOSED") return "closed";
|
|
8247
|
+
return "open";
|
|
8283
8248
|
};
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8249
|
+
ask = (repo) => callback$1((resume) => {
|
|
8250
|
+
execFile("gh", [
|
|
8251
|
+
"pr",
|
|
8252
|
+
"list",
|
|
8253
|
+
"--state",
|
|
8254
|
+
"all",
|
|
8255
|
+
"--limit",
|
|
8256
|
+
LIMIT,
|
|
8257
|
+
"--json",
|
|
8258
|
+
FIELDS$1
|
|
8259
|
+
], {
|
|
8260
|
+
cwd: repo,
|
|
8261
|
+
timeout: TIMEOUT_MS$1,
|
|
8262
|
+
encoding: "utf8"
|
|
8263
|
+
}, (error, stdout) => {
|
|
8264
|
+
if (error === null) return resume(succeed$1(stdout));
|
|
8265
|
+
resume(fail(new ForgeUnavailable({
|
|
8266
|
+
repo,
|
|
8267
|
+
reason: error.message
|
|
8268
|
+
})));
|
|
8296
8269
|
});
|
|
8297
|
-
};
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8270
|
+
});
|
|
8271
|
+
show = (repo, branch) => callback$1((resume) => {
|
|
8272
|
+
execFile("gh", [
|
|
8273
|
+
"pr",
|
|
8274
|
+
"view",
|
|
8275
|
+
branch,
|
|
8276
|
+
"--web"
|
|
8277
|
+
], {
|
|
8278
|
+
cwd: repo,
|
|
8279
|
+
timeout: TIMEOUT_MS$1,
|
|
8280
|
+
encoding: "utf8"
|
|
8281
|
+
}, (error) => {
|
|
8282
|
+
if (error === null) return resume(void_);
|
|
8283
|
+
resume(fail(new ForgeUnavailable({
|
|
8284
|
+
repo,
|
|
8285
|
+
reason: error.message
|
|
8286
|
+
})));
|
|
8287
|
+
});
|
|
8288
|
+
});
|
|
8289
|
+
read = fn("Forge.read")(function* (repo, raw) {
|
|
8290
|
+
const parsed = yield* try_({
|
|
8291
|
+
try: () => JSON.parse(raw),
|
|
8292
|
+
catch: (cause) => new ForgeUnavailable({
|
|
8293
|
+
repo,
|
|
8294
|
+
reason: String(cause)
|
|
8295
|
+
})
|
|
8296
|
+
});
|
|
8297
|
+
return (yield* mapError(decode(parsed), (cause) => new ForgeUnavailable({
|
|
8298
|
+
repo,
|
|
8299
|
+
reason: String(cause)
|
|
8300
|
+
}))).map((row) => ({
|
|
8301
|
+
branch: row.headRefName,
|
|
8302
|
+
state: stateOf$1(row)
|
|
8303
|
+
}));
|
|
8304
|
+
});
|
|
8305
|
+
pulls = fn("Forge.pulls")(function* (repo) {
|
|
8306
|
+
const raw = yield* ask(repo);
|
|
8307
|
+
return yield* read(repo, raw);
|
|
8308
|
+
});
|
|
8309
|
+
openPull = fn("Forge.openPull")(function* (repo, branch) {
|
|
8310
|
+
yield* show(repo, branch);
|
|
8311
|
+
});
|
|
8312
|
+
NUMBER_FIELDS = "number,headRefOid,url";
|
|
8313
|
+
Named = Struct({
|
|
8314
|
+
number: Int,
|
|
8315
|
+
headRefOid: String$1,
|
|
8316
|
+
url: String$1
|
|
8317
|
+
});
|
|
8318
|
+
readNamed = decodeUnknownEffect(Named);
|
|
8319
|
+
gh = (repo, args, input) => callback$1((resume) => {
|
|
8320
|
+
const child = execFile("gh", [...args], {
|
|
8321
|
+
cwd: repo,
|
|
8322
|
+
timeout: SEND_TIMEOUT_MS,
|
|
8323
|
+
encoding: "utf8",
|
|
8324
|
+
maxBuffer: MOST_OUTPUT
|
|
8325
|
+
}, (error, stdout, stderr) => {
|
|
8326
|
+
if (error === null) return resume(succeed$1(stdout));
|
|
8327
|
+
const said = stderr.trim().length > 0 ? stderr.trim() : error.message;
|
|
8328
|
+
resume(fail(new ForgeUnavailable({
|
|
8329
|
+
repo,
|
|
8330
|
+
reason: said
|
|
8331
|
+
})));
|
|
8332
|
+
});
|
|
8333
|
+
if (input !== void 0) child.stdin?.end(input);
|
|
8334
|
+
});
|
|
8335
|
+
named = fn("Forge.named")(function* (repo, branch) {
|
|
8336
|
+
const raw = yield* gh(repo, [
|
|
8337
|
+
"pr",
|
|
8338
|
+
"view",
|
|
8339
|
+
branch,
|
|
8340
|
+
"--json",
|
|
8341
|
+
NUMBER_FIELDS
|
|
8342
|
+
]);
|
|
8343
|
+
const parsed = yield* try_({
|
|
8344
|
+
try: () => JSON.parse(raw),
|
|
8345
|
+
catch: (cause) => new ForgeUnavailable({
|
|
8346
|
+
repo,
|
|
8347
|
+
reason: String(cause)
|
|
8348
|
+
})
|
|
8349
|
+
});
|
|
8350
|
+
return yield* mapError(readNamed(parsed), (cause) => new ForgeUnavailable({
|
|
8351
|
+
repo,
|
|
8352
|
+
reason: String(cause)
|
|
8353
|
+
}));
|
|
8354
|
+
});
|
|
8355
|
+
head = fn("Forge.head")(function* (repo, branch) {
|
|
8356
|
+
return (yield* named(repo, branch)).headRefOid;
|
|
8357
|
+
});
|
|
8358
|
+
bodyFor = (comments) => JSON.stringify({
|
|
8359
|
+
event: "COMMENT",
|
|
8360
|
+
comments: comments.map((one) => ({
|
|
8361
|
+
path: one.path,
|
|
8362
|
+
line: one.line,
|
|
8363
|
+
side: one.side === "old" ? "LEFT" : "RIGHT",
|
|
8364
|
+
body: one.body
|
|
8365
|
+
}))
|
|
8366
|
+
});
|
|
8367
|
+
review = fn("Forge.review")(function* (repo, branch, comments) {
|
|
8368
|
+
const pull = yield* named(repo, branch);
|
|
8369
|
+
const route = `repos/${(yield* gh(repo, [
|
|
8370
|
+
"repo",
|
|
8371
|
+
"view",
|
|
8372
|
+
"--json",
|
|
8373
|
+
"nameWithOwner",
|
|
8374
|
+
"-q",
|
|
8375
|
+
".nameWithOwner"
|
|
8376
|
+
])).trim()}/pulls/${pull.number}/reviews`;
|
|
8377
|
+
yield* gh(repo, [
|
|
8378
|
+
"api",
|
|
8379
|
+
"--method",
|
|
8380
|
+
"POST",
|
|
8381
|
+
route,
|
|
8382
|
+
"--input",
|
|
8383
|
+
"-"
|
|
8384
|
+
], bodyFor(comments));
|
|
8385
|
+
return {
|
|
8386
|
+
landed: comments.map((one) => `${one.path}:${one.line}`),
|
|
8387
|
+
url: pull.url
|
|
8305
8388
|
};
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
};
|
|
8313
|
-
readBody = (draft, line) => {
|
|
8314
|
-
const kind = SIGNS$1[line.slice(0, 1)];
|
|
8315
|
-
if (kind !== void 0) appendRow(draft, kind, line.slice(1));
|
|
8316
|
-
};
|
|
8317
|
-
readHeader = (draft, line) => {
|
|
8318
|
-
if (line.startsWith(BLOB_MARKER)) {
|
|
8319
|
-
draft.blob = line.slice(6).split("..")[1]?.split(" ")[0] ?? "";
|
|
8320
|
-
draft.headerLines.push(line);
|
|
8321
|
-
return true;
|
|
8322
|
-
}
|
|
8323
|
-
if (line.startsWith(OLD_PATH_MARKER) || line.startsWith(NEW_PATH_MARKER)) {
|
|
8324
|
-
draft.headerLines.push(line);
|
|
8325
|
-
return true;
|
|
8326
|
-
}
|
|
8327
|
-
return false;
|
|
8328
|
-
};
|
|
8329
|
-
parsePatches = (diff) => {
|
|
8330
|
-
const drafts = [];
|
|
8331
|
-
for (const line of diff.split("\n")) {
|
|
8332
|
-
if (line.startsWith(FILE_MARKER)) {
|
|
8333
|
-
drafts.push(draftFrom(line));
|
|
8334
|
-
continue;
|
|
8335
|
-
}
|
|
8336
|
-
const draft = drafts.at(-1);
|
|
8337
|
-
if (draft === void 0) continue;
|
|
8338
|
-
if (readHeader(draft, line)) continue;
|
|
8339
|
-
if (line.startsWith(HUNK_MARKER)) openHunk(draft, line);
|
|
8340
|
-
else readBody(draft, line);
|
|
8341
|
-
}
|
|
8342
|
-
return drafts;
|
|
8343
|
-
};
|
|
8389
|
+
});
|
|
8390
|
+
ForgeLive = succeed$2(Forge)({
|
|
8391
|
+
pulls,
|
|
8392
|
+
openPull,
|
|
8393
|
+
head,
|
|
8394
|
+
review
|
|
8395
|
+
});
|
|
8344
8396
|
}));
|
|
8345
8397
|
//#endregion
|
|
8346
|
-
//#region src/
|
|
8347
|
-
var
|
|
8348
|
-
|
|
8398
|
+
//#region src/service/forge/index.ts
|
|
8399
|
+
var init_forge = __esmMin((() => {
|
|
8400
|
+
init_service$2();
|
|
8401
|
+
init_error$3();
|
|
8349
8402
|
}));
|
|
8350
8403
|
//#endregion
|
|
8351
|
-
//#region src/
|
|
8352
|
-
var
|
|
8353
|
-
var
|
|
8354
|
-
CLOSER = /^[)\]}>;,]/;
|
|
8355
|
-
COMMENT = /^(\/\/|\/\*|\*|#|<!--)/;
|
|
8356
|
-
LOOKAHEAD = 5;
|
|
8357
|
-
indentOf = (text) => text.length - text.trimStart().length;
|
|
8358
|
-
pinnable = (text) => {
|
|
8359
|
-
const trimmed = text.trim();
|
|
8360
|
-
if (trimmed.length === 0) return false;
|
|
8361
|
-
return !CLOSER.test(trimmed) && !COMMENT.test(trimmed);
|
|
8362
|
-
};
|
|
8363
|
-
limitFrom = (source, index) => {
|
|
8364
|
-
const here = source[index] ?? "";
|
|
8365
|
-
if (here.trim().length > 0) return indentOf(here);
|
|
8366
|
-
const ahead = source.slice(index, index + LOOKAHEAD).find((line) => line.trim().length > 0);
|
|
8367
|
-
return ahead === void 0 ? 0 : indentOf(ahead);
|
|
8368
|
-
};
|
|
8369
|
-
stickyChain = (source, line, max) => {
|
|
8370
|
-
const index = line - 1;
|
|
8371
|
-
if (index <= 0 || index >= source.length) return [];
|
|
8372
|
-
let limit = limitFrom(source, index);
|
|
8373
|
-
const chain = [];
|
|
8374
|
-
for (let above = index - 1; above >= 0; above -= 1) {
|
|
8375
|
-
const text = source[above] ?? "";
|
|
8376
|
-
if (!pinnable(text)) continue;
|
|
8377
|
-
const indent = indentOf(text);
|
|
8378
|
-
if (indent >= limit) continue;
|
|
8379
|
-
chain.push(text);
|
|
8380
|
-
limit = indent;
|
|
8381
|
-
if (indent === 0) break;
|
|
8382
|
-
}
|
|
8383
|
-
return chain.toReversed().slice(0, max);
|
|
8384
|
-
};
|
|
8385
|
-
}));
|
|
8386
|
-
//#endregion
|
|
8387
|
-
//#region src/domain/patch/index.ts
|
|
8388
|
-
var init_patch = __esmMin((() => {
|
|
8389
|
-
init_anchor();
|
|
8390
|
-
init_parse$1();
|
|
8391
|
-
init_render$1();
|
|
8392
|
-
init_sticky();
|
|
8393
|
-
init_model$5();
|
|
8394
|
-
})), GitCommandFailed, FileUnreadable;
|
|
8395
|
-
var init_error$3 = __esmMin((() => {
|
|
8404
|
+
//#region src/service/store/error.ts
|
|
8405
|
+
var StoreUnwritable, StoreUnreadable;
|
|
8406
|
+
var init_error$2 = __esmMin((() => {
|
|
8396
8407
|
init_dist();
|
|
8397
|
-
|
|
8398
|
-
TaggedError("
|
|
8399
|
-
FileUnreadable = class extends TaggedError("FileUnreadable") {};
|
|
8408
|
+
StoreUnwritable = class extends TaggedError("StoreUnwritable") {};
|
|
8409
|
+
StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
|
|
8400
8410
|
}));
|
|
8401
8411
|
//#endregion
|
|
8402
|
-
//#region src/service/
|
|
8403
|
-
var
|
|
8404
|
-
var
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
maxBuffer: MAX_OUTPUT,
|
|
8414
|
-
encoding: "utf8"
|
|
8415
|
-
}),
|
|
8416
|
-
catch: (cause) => new GitCommandFailed({
|
|
8417
|
-
command: args,
|
|
8418
|
-
cwd,
|
|
8419
|
-
stderr: cause instanceof Error ? cause.message : String(cause)
|
|
8420
|
-
})
|
|
8421
|
-
}).pipe(map((result) => result.stdout));
|
|
8422
|
-
});
|
|
8423
|
-
gitOrEmpty = fn("Git.runOrEmpty")(function* (cwd, args) {
|
|
8424
|
-
return yield* git(cwd, args).pipe(catchTag("GitCommandFailed", () => succeed$1("")));
|
|
8425
|
-
});
|
|
8412
|
+
//#region src/service/store/model.ts
|
|
8413
|
+
var emptyBranchState;
|
|
8414
|
+
var init_model$5 = __esmMin((() => {
|
|
8415
|
+
emptyBranchState = {
|
|
8416
|
+
vouches: {},
|
|
8417
|
+
consumed: 0,
|
|
8418
|
+
settled: {},
|
|
8419
|
+
removed: {},
|
|
8420
|
+
base: "",
|
|
8421
|
+
read: {}
|
|
8422
|
+
};
|
|
8426
8423
|
}));
|
|
8427
8424
|
//#endregion
|
|
8428
|
-
//#region src/service/
|
|
8429
|
-
var
|
|
8430
|
-
var
|
|
8425
|
+
//#region src/service/store/schema.ts
|
|
8426
|
+
var Side, Anchor, StoredComment, StoredDraft, Drafts, StoredAnswer, Batch, BranchState, Settings, UpgradeCheck, Prose, Code, StoredLayer, StoredLayers;
|
|
8427
|
+
var init_schema = __esmMin((() => {
|
|
8431
8428
|
init_dist();
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
"main"
|
|
8441
|
-
];
|
|
8442
|
-
STAT = /(\d+) files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/;
|
|
8443
|
-
Git = class extends Service()("adiff/Git") {};
|
|
8444
|
-
parseStat = (raw) => {
|
|
8445
|
-
const matched = STAT.exec(raw);
|
|
8446
|
-
return {
|
|
8447
|
-
files: Number(matched?.[1] ?? 0),
|
|
8448
|
-
added: Number(matched?.[2] ?? 0),
|
|
8449
|
-
removed: Number(matched?.[3] ?? 0)
|
|
8450
|
-
};
|
|
8451
|
-
};
|
|
8452
|
-
readEntries = (porcelain) => {
|
|
8453
|
-
const entries = [];
|
|
8454
|
-
for (const line of porcelain.split("\n")) {
|
|
8455
|
-
if (line.startsWith("worktree ")) entries.push({
|
|
8456
|
-
path: line.slice(9),
|
|
8457
|
-
branch: "",
|
|
8458
|
-
head: "",
|
|
8459
|
-
detached: false
|
|
8460
|
-
});
|
|
8461
|
-
const current = entries.at(-1);
|
|
8462
|
-
if (current === void 0) continue;
|
|
8463
|
-
if (line.startsWith("branch ")) current.branch = line.slice(7).replace("refs/heads/", "");
|
|
8464
|
-
if (line.startsWith("HEAD ")) current.head = line.slice(5);
|
|
8465
|
-
if (line === "detached") current.detached = true;
|
|
8466
|
-
}
|
|
8467
|
-
return entries;
|
|
8468
|
-
};
|
|
8469
|
-
baseNames = /* @__PURE__ */ new Map();
|
|
8470
|
-
mergeBases = /* @__PURE__ */ new Map();
|
|
8471
|
-
findDefaultBranch = fn("Git.findDefaultBranch")(function* (repo) {
|
|
8472
|
-
const symbolic = yield* gitOrEmpty(repo, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
|
|
8473
|
-
if (symbolic.trim().length > 0) return symbolic.trim().replace("refs/remotes/", "");
|
|
8474
|
-
for (const candidate of DEFAULT_BRANCH_CANDIDATES) if ((yield* gitOrEmpty(repo, [
|
|
8475
|
-
"rev-parse",
|
|
8476
|
-
"--verify",
|
|
8477
|
-
candidate
|
|
8478
|
-
])).trim().length > 0) return candidate;
|
|
8479
|
-
return "HEAD";
|
|
8429
|
+
Side = Literals(["old", "new"]);
|
|
8430
|
+
Anchor = Struct({
|
|
8431
|
+
path: String$1,
|
|
8432
|
+
blob: String$1,
|
|
8433
|
+
snippet: String$1,
|
|
8434
|
+
side: Side,
|
|
8435
|
+
start: Int,
|
|
8436
|
+
end: Int
|
|
8480
8437
|
});
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
return found;
|
|
8438
|
+
StoredComment = Struct({
|
|
8439
|
+
id: String$1,
|
|
8440
|
+
anchor: Anchor,
|
|
8441
|
+
body: String$1,
|
|
8442
|
+
replyTo: optionalKey(String$1)
|
|
8487
8443
|
});
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
base,
|
|
8495
|
-
"HEAD"
|
|
8496
|
-
])).trim();
|
|
8497
|
-
mergeBases.set(key, found);
|
|
8498
|
-
return found;
|
|
8444
|
+
StoredDraft = Struct({
|
|
8445
|
+
id: String$1,
|
|
8446
|
+
anchor: Anchor,
|
|
8447
|
+
body: String$1,
|
|
8448
|
+
at: String$1,
|
|
8449
|
+
wroteBy: Literals(["reviewer", "agent"])
|
|
8499
8450
|
});
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
path: entry.path,
|
|
8504
|
-
branch: entry.detached ? `(detached ${entry.head.slice(0, 8)})` : entry.branch,
|
|
8505
|
-
head: entry.head.slice(0, 8),
|
|
8506
|
-
base: mergeBase.slice(0, 8),
|
|
8507
|
-
detached: entry.detached,
|
|
8508
|
-
own
|
|
8509
|
-
};
|
|
8451
|
+
Drafts = Struct({
|
|
8452
|
+
version: Int,
|
|
8453
|
+
drafts: ArraySchema(StoredDraft)
|
|
8510
8454
|
});
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
const tips = /* @__PURE__ */ new Map();
|
|
8518
|
-
for (const line of raw.split("\n")) {
|
|
8519
|
-
const [sha, ...rest] = line.trim().split(" ");
|
|
8520
|
-
const name = rest.join(" ");
|
|
8521
|
-
if (sha === void 0 || sha.length === 0 || name.length === 0) continue;
|
|
8522
|
-
const held = tips.get(sha);
|
|
8523
|
-
if (held === void 0) tips.set(sha, [name]);
|
|
8524
|
-
else held.push(name);
|
|
8525
|
-
}
|
|
8526
|
-
return tips;
|
|
8455
|
+
StoredAnswer = Struct({
|
|
8456
|
+
comment: String$1,
|
|
8457
|
+
body: String$1,
|
|
8458
|
+
head: String$1,
|
|
8459
|
+
asks: Boolean,
|
|
8460
|
+
at: String$1
|
|
8527
8461
|
});
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
const key = `${repo} ${branch} ${tip} ${fallback}`;
|
|
8534
|
-
const known = parents.get(key);
|
|
8535
|
-
if (known !== void 0) return known;
|
|
8536
|
-
const tips = yield* branchTips(repo);
|
|
8537
|
-
const found = own.slice(1).flatMap((sha) => tips.get(sha) ?? []).find((name) => name !== branch);
|
|
8538
|
-
parents.set(key, found ?? fallback);
|
|
8539
|
-
return found ?? fallback;
|
|
8462
|
+
Batch = Struct({
|
|
8463
|
+
id: String$1,
|
|
8464
|
+
at: String$1,
|
|
8465
|
+
head: String$1,
|
|
8466
|
+
comments: ArraySchema(StoredComment)
|
|
8540
8467
|
});
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
reason: String(cause)
|
|
8549
|
-
})
|
|
8550
|
-
}).pipe(map(some), catchTag("FileUnreadable", () => absent));
|
|
8468
|
+
BranchState = Struct({
|
|
8469
|
+
vouches: optionalKey(Record(String$1, String$1)),
|
|
8470
|
+
consumed: optionalKey(Int),
|
|
8471
|
+
settled: optionalKey(Record(String$1, String$1)),
|
|
8472
|
+
removed: optionalKey(Record(String$1, String$1)),
|
|
8473
|
+
base: optionalKey(String$1),
|
|
8474
|
+
read: optionalKey(Record(String$1, Int))
|
|
8551
8475
|
});
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8476
|
+
Settings = Struct({
|
|
8477
|
+
wrap: optionalKey(Boolean),
|
|
8478
|
+
sticky: optionalKey(Boolean),
|
|
8479
|
+
panel: optionalKey(Boolean),
|
|
8480
|
+
hideReviewed: optionalKey(Boolean),
|
|
8481
|
+
hideSettled: optionalKey(Boolean),
|
|
8482
|
+
newestFirst: optionalKey(Boolean),
|
|
8483
|
+
hold: optionalKey(Boolean)
|
|
8556
8484
|
});
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
]);
|
|
8563
|
-
const base = yield* defaultBranch(repo);
|
|
8564
|
-
const entries = readEntries(porcelain);
|
|
8565
|
-
const opened = yield* settled(repo);
|
|
8566
|
-
const read = (entry) => seenAs(entry, base, opened);
|
|
8567
|
-
return yield* forEach(entries, read, { concurrency: AT_ONCE$1 });
|
|
8568
|
-
});
|
|
8569
|
-
readDiff = fn("Git.diff")(function* (worktree, context, only) {
|
|
8570
|
-
const target = worktree.base.length > 0 ? worktree.base : "HEAD";
|
|
8571
|
-
const scope = only === void 0 ? [] : ["--", only];
|
|
8572
|
-
return yield* gitOrEmpty(worktree.path, [
|
|
8573
|
-
"diff",
|
|
8574
|
-
`-U${context}`,
|
|
8575
|
-
target,
|
|
8576
|
-
...scope
|
|
8577
|
-
]);
|
|
8578
|
-
});
|
|
8579
|
-
readStat = fn("Git.stat")(function* (worktree) {
|
|
8580
|
-
const raw = yield* gitOrEmpty(worktree.path, [
|
|
8581
|
-
"diff",
|
|
8582
|
-
"--shortstat",
|
|
8583
|
-
worktree.base
|
|
8584
|
-
]);
|
|
8585
|
-
return parseStat(raw);
|
|
8586
|
-
});
|
|
8587
|
-
readSource = fn("Git.source")(function* (worktree, path) {
|
|
8588
|
-
const text = yield* readText(join(worktree.path, path), path);
|
|
8589
|
-
return map$4(text, splitLines);
|
|
8590
|
-
});
|
|
8591
|
-
readBlob = fn("Git.blob")(function* (worktree, path) {
|
|
8592
|
-
const target = worktree.base.length > 0 ? worktree.base : "HEAD";
|
|
8593
|
-
const raw = yield* gitOrEmpty(worktree.path, ["show", `${target}:${path}`]);
|
|
8594
|
-
return raw.length === 0 ? none() : some(splitLines(raw));
|
|
8595
|
-
});
|
|
8596
|
-
readGrep = fn("Git.grep")(function* (worktree, term) {
|
|
8597
|
-
return yield* gitOrEmpty(worktree.path, [
|
|
8598
|
-
"grep",
|
|
8599
|
-
"--no-color",
|
|
8600
|
-
"-n",
|
|
8601
|
-
"-I",
|
|
8602
|
-
"-F",
|
|
8603
|
-
"-i",
|
|
8604
|
-
"-w",
|
|
8605
|
-
"-C",
|
|
8606
|
-
String(GREP_CONTEXT),
|
|
8607
|
-
"-e",
|
|
8608
|
-
term
|
|
8609
|
-
]);
|
|
8610
|
-
});
|
|
8611
|
-
shape = {
|
|
8612
|
-
worktrees: listWorktrees,
|
|
8613
|
-
repoOf: fn("Git.repoOf")(function* (worktree) {
|
|
8614
|
-
const trimmed = (yield* gitOrEmpty(worktree, [
|
|
8615
|
-
"rev-parse",
|
|
8616
|
-
"--path-format=absolute",
|
|
8617
|
-
"--git-common-dir"
|
|
8618
|
-
])).trim();
|
|
8619
|
-
return trimmed.length === 0 ? resolve(worktree) : resolve(trimmed, "..");
|
|
8620
|
-
}),
|
|
8621
|
-
diff: readDiff,
|
|
8622
|
-
stat: readStat,
|
|
8623
|
-
source: readSource,
|
|
8624
|
-
blob: readBlob,
|
|
8625
|
-
grep: readGrep,
|
|
8626
|
-
defaultBranch,
|
|
8627
|
-
stackParent: (repo, branch) => defaultBranch(repo).pipe(flatMap((fallback) => parentOf(repo, branch, fallback))),
|
|
8628
|
-
resolves: fn("Git.resolves")(function* (repo, ref) {
|
|
8629
|
-
return (yield* gitOrEmpty(repo, [
|
|
8630
|
-
"rev-parse",
|
|
8631
|
-
"--verify",
|
|
8632
|
-
`${ref}^{commit}`
|
|
8633
|
-
])).trim().length > 0;
|
|
8634
|
-
}),
|
|
8635
|
-
sharedWith: fn("Git.sharedWith")(function* (repo, branch, ref) {
|
|
8636
|
-
return (yield* gitOrEmpty(repo, [
|
|
8637
|
-
"merge-base",
|
|
8638
|
-
branch,
|
|
8639
|
-
ref
|
|
8640
|
-
])).trim();
|
|
8641
|
-
})
|
|
8642
|
-
};
|
|
8643
|
-
GitLive = succeed$2(Git)(shape);
|
|
8644
|
-
}));
|
|
8645
|
-
//#endregion
|
|
8646
|
-
//#region src/service/git/index.ts
|
|
8647
|
-
var init_git = __esmMin((() => {
|
|
8648
|
-
init_service$2();
|
|
8649
|
-
init_error$3();
|
|
8650
|
-
}));
|
|
8651
|
-
//#endregion
|
|
8652
|
-
//#region src/domain/review/vouch.ts
|
|
8653
|
-
var isVouched, vouch;
|
|
8654
|
-
var init_vouch = __esmMin((() => {
|
|
8655
|
-
isVouched = (vouches, path, blob) => vouches[path] === blob;
|
|
8656
|
-
vouch = (vouches, path, blob) => {
|
|
8657
|
-
if (isVouched(vouches, path, blob)) {
|
|
8658
|
-
const { [path]: _cleared, ...rest } = vouches;
|
|
8659
|
-
return rest;
|
|
8660
|
-
}
|
|
8661
|
-
return {
|
|
8662
|
-
...vouches,
|
|
8663
|
-
[path]: blob
|
|
8664
|
-
};
|
|
8665
|
-
};
|
|
8666
|
-
}));
|
|
8667
|
-
var init_model$4 = __esmMin((() => {
|
|
8668
|
-
init_dist();
|
|
8669
|
-
String$1.pipe(brand("@adiff/CommentId"));
|
|
8670
|
-
}));
|
|
8671
|
-
//#endregion
|
|
8672
|
-
//#region src/domain/review/index.ts
|
|
8673
|
-
var init_review = __esmMin((() => {
|
|
8674
|
-
init_dist();
|
|
8675
|
-
init_vouch();
|
|
8676
|
-
init_model$4();
|
|
8677
|
-
}));
|
|
8678
|
-
//#endregion
|
|
8679
|
-
//#region src/service/store/error.ts
|
|
8680
|
-
var StoreUnwritable, StoreUnreadable;
|
|
8681
|
-
var init_error$2 = __esmMin((() => {
|
|
8682
|
-
init_dist();
|
|
8683
|
-
StoreUnwritable = class extends TaggedError("StoreUnwritable") {};
|
|
8684
|
-
StoreUnreadable = class extends TaggedError("StoreUnreadable") {};
|
|
8685
|
-
}));
|
|
8686
|
-
//#endregion
|
|
8687
|
-
//#region src/service/store/model.ts
|
|
8688
|
-
var emptyBranchState;
|
|
8689
|
-
var init_model$3 = __esmMin((() => {
|
|
8690
|
-
emptyBranchState = {
|
|
8691
|
-
vouches: {},
|
|
8692
|
-
consumed: 0,
|
|
8693
|
-
settled: {},
|
|
8694
|
-
removed: {},
|
|
8695
|
-
base: "",
|
|
8696
|
-
read: {}
|
|
8697
|
-
};
|
|
8698
|
-
}));
|
|
8699
|
-
//#endregion
|
|
8700
|
-
//#region src/service/store/schema.ts
|
|
8701
|
-
var Side, Anchor, StoredComment, StoredAnswer, Batch, BranchState, Settings, UpgradeCheck, Prose, Code, StoredLayer, StoredLayers;
|
|
8702
|
-
var init_schema = __esmMin((() => {
|
|
8703
|
-
init_dist();
|
|
8704
|
-
Side = Literals(["old", "new"]);
|
|
8705
|
-
Anchor = Struct({
|
|
8706
|
-
path: String$1,
|
|
8707
|
-
blob: String$1,
|
|
8708
|
-
snippet: String$1,
|
|
8709
|
-
side: Side,
|
|
8710
|
-
start: Int,
|
|
8711
|
-
end: Int
|
|
8712
|
-
});
|
|
8713
|
-
StoredComment = Struct({
|
|
8714
|
-
id: String$1,
|
|
8715
|
-
anchor: Anchor,
|
|
8716
|
-
body: String$1,
|
|
8717
|
-
replyTo: optionalKey(String$1)
|
|
8718
|
-
});
|
|
8719
|
-
StoredAnswer = Struct({
|
|
8720
|
-
comment: String$1,
|
|
8721
|
-
body: String$1,
|
|
8722
|
-
head: String$1,
|
|
8723
|
-
asks: Boolean,
|
|
8724
|
-
at: String$1
|
|
8725
|
-
});
|
|
8726
|
-
Batch = Struct({
|
|
8727
|
-
id: String$1,
|
|
8728
|
-
at: String$1,
|
|
8729
|
-
head: String$1,
|
|
8730
|
-
comments: ArraySchema(StoredComment)
|
|
8731
|
-
});
|
|
8732
|
-
BranchState = Struct({
|
|
8733
|
-
vouches: optionalKey(Record(String$1, String$1)),
|
|
8734
|
-
consumed: optionalKey(Int),
|
|
8735
|
-
settled: optionalKey(Record(String$1, String$1)),
|
|
8736
|
-
removed: optionalKey(Record(String$1, String$1)),
|
|
8737
|
-
base: optionalKey(String$1),
|
|
8738
|
-
read: optionalKey(Record(String$1, Int))
|
|
8739
|
-
});
|
|
8740
|
-
Settings = Struct({
|
|
8741
|
-
wrap: optionalKey(Boolean),
|
|
8742
|
-
sticky: optionalKey(Boolean),
|
|
8743
|
-
panel: optionalKey(Boolean),
|
|
8744
|
-
hideReviewed: optionalKey(Boolean),
|
|
8745
|
-
hideSettled: optionalKey(Boolean),
|
|
8746
|
-
newestFirst: optionalKey(Boolean),
|
|
8747
|
-
hold: optionalKey(Boolean)
|
|
8748
|
-
});
|
|
8749
|
-
UpgradeCheck = Struct({
|
|
8750
|
-
note: optionalKey(String$1),
|
|
8751
|
-
checkedAt: optionalKey(String$1),
|
|
8752
|
-
latest: optionalKey(String$1),
|
|
8753
|
-
told: optionalKey(String$1)
|
|
8485
|
+
UpgradeCheck = Struct({
|
|
8486
|
+
note: optionalKey(String$1),
|
|
8487
|
+
checkedAt: optionalKey(String$1),
|
|
8488
|
+
latest: optionalKey(String$1),
|
|
8489
|
+
told: optionalKey(String$1)
|
|
8754
8490
|
});
|
|
8755
8491
|
Prose = Struct({
|
|
8756
8492
|
kind: Literal("prose"),
|
|
@@ -8778,7 +8514,7 @@ var init_schema = __esmMin((() => {
|
|
|
8778
8514
|
}));
|
|
8779
8515
|
//#endregion
|
|
8780
8516
|
//#region src/service/store/paths.ts
|
|
8781
|
-
var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, layersPath, settingsPath, upgradePath, reportsDir, reportPath;
|
|
8517
|
+
var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, draftsPath, layersPath, settingsPath, upgradePath, reportsDir, reportPath;
|
|
8782
8518
|
var init_paths = __esmMin((() => {
|
|
8783
8519
|
NON_SLUG = /[^a-zA-Z0-9]+/g;
|
|
8784
8520
|
slugOf = (worktreePath) => worktreePath.replace(NON_SLUG, "-");
|
|
@@ -8787,16 +8523,17 @@ var init_paths = __esmMin((() => {
|
|
|
8787
8523
|
inboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "inbox.jsonl");
|
|
8788
8524
|
outboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "outbox.jsonl");
|
|
8789
8525
|
statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
|
|
8526
|
+
draftsPath = (root, worktreePath) => join(branchDir(root, worktreePath), "drafts.json");
|
|
8790
8527
|
layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
|
|
8791
8528
|
settingsPath = (root) => join(root, "settings.json");
|
|
8792
8529
|
upgradePath = (root) => join(root, "upgrade.json");
|
|
8793
8530
|
reportsDir = (root) => join(root, "reports");
|
|
8794
8531
|
reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
|
|
8795
|
-
})), Store, ensureDir, readOptional, missing$1, damaged, jsonOf, decoded, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, cursorOps, settingsOps, upgradeOps, reportOps, HEAD_REF, gitDirOf, headOf$1, repoOf$2, keyOf$2, wasKeyOf, there, adopted, moved, adopt, keyIn, answerOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
|
|
8532
|
+
})), Store, ensureDir, readOptional, missing$1, damaged, jsonOf, decoded, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, asDrafts, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, cursorOps, settingsOps, upgradeOps, reportOps, HEAD_REF, gitDirOf, headOf$1, repoOf$2, keyOf$2, wasKeyOf, there, adopted, moved, adopt, keyIn, answerOps, draftsOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
|
|
8796
8533
|
var init_service$1 = __esmMin((() => {
|
|
8797
8534
|
init_dist();
|
|
8798
8535
|
init_error$2();
|
|
8799
|
-
init_model$
|
|
8536
|
+
init_model$5();
|
|
8800
8537
|
init_schema();
|
|
8801
8538
|
init_paths();
|
|
8802
8539
|
Store = class extends Service()("adiff/Store") {};
|
|
@@ -8837,6 +8574,7 @@ var init_service$1 = __esmMin((() => {
|
|
|
8837
8574
|
asAnswer = decoded(StoredAnswer);
|
|
8838
8575
|
asState = decoded(BranchState);
|
|
8839
8576
|
asLayers = decoded(StoredLayers);
|
|
8577
|
+
asDrafts = decoded(Drafts);
|
|
8840
8578
|
linesOf = (raw) => raw.split("\n").filter((line) => line.trim().length > 0);
|
|
8841
8579
|
readLines = (path, raw, as) => forEach(linesOf(raw), (line) => jsonOf(path, line).pipe(flatMap((value) => as(path, value))));
|
|
8842
8580
|
parseSettings = fn("Store.parseSettings")(function* (path, raw) {
|
|
@@ -8994,6 +8732,34 @@ var init_service$1 = __esmMin((() => {
|
|
|
8994
8732
|
})
|
|
8995
8733
|
};
|
|
8996
8734
|
};
|
|
8735
|
+
draftsOps = (root) => {
|
|
8736
|
+
return {
|
|
8737
|
+
drafts: fn("Store.drafts")(function* (worktreePath) {
|
|
8738
|
+
const key = yield* keyIn(root, worktreePath);
|
|
8739
|
+
const path = draftsPath(root, key);
|
|
8740
|
+
const raw = yield* readOptional(path);
|
|
8741
|
+
if (isNone(raw)) return [];
|
|
8742
|
+
const value = yield* jsonOf(path, raw.value);
|
|
8743
|
+
return (yield* asDrafts(path, value)).drafts;
|
|
8744
|
+
}),
|
|
8745
|
+
saveDrafts: fn("Store.saveDrafts")(function* (worktreePath, next) {
|
|
8746
|
+
const key = yield* keyIn(root, worktreePath);
|
|
8747
|
+
const path = draftsPath(root, key);
|
|
8748
|
+
yield* ensureDir(branchDir(root, key));
|
|
8749
|
+
const body = JSON.stringify({
|
|
8750
|
+
version: 1,
|
|
8751
|
+
drafts: next
|
|
8752
|
+
}, void 0, 2);
|
|
8753
|
+
yield* tryPromise({
|
|
8754
|
+
try: () => writeFile(path, body, "utf8"),
|
|
8755
|
+
catch: (cause) => new StoreUnwritable({
|
|
8756
|
+
path,
|
|
8757
|
+
reason: String(cause)
|
|
8758
|
+
})
|
|
8759
|
+
});
|
|
8760
|
+
})
|
|
8761
|
+
};
|
|
8762
|
+
};
|
|
8997
8763
|
layersOps = (root) => {
|
|
8998
8764
|
return {
|
|
8999
8765
|
layers: fn("Store.layers")(function* (worktreePath) {
|
|
@@ -9073,29 +8839,490 @@ var init_service$1 = __esmMin((() => {
|
|
|
9073
8839
|
const talk = answerOps(root);
|
|
9074
8840
|
const cursors = cursorOps(state, inbox, talk.answers);
|
|
9075
8841
|
return {
|
|
9076
|
-
root,
|
|
9077
|
-
branchAt: (worktreePath) => promise(() => headOf$1(worktreePath)),
|
|
9078
|
-
submit,
|
|
9079
|
-
inbox,
|
|
9080
|
-
state,
|
|
9081
|
-
saveState,
|
|
9082
|
-
saveReport: reportOps(root),
|
|
9083
|
-
...settingsOps(root),
|
|
9084
|
-
...upgradeOps(root),
|
|
9085
|
-
...talk,
|
|
9086
|
-
...layersOps(root),
|
|
9087
|
-
...
|
|
8842
|
+
root,
|
|
8843
|
+
branchAt: (worktreePath) => promise(() => headOf$1(worktreePath)),
|
|
8844
|
+
submit,
|
|
8845
|
+
inbox,
|
|
8846
|
+
state,
|
|
8847
|
+
saveState,
|
|
8848
|
+
saveReport: reportOps(root),
|
|
8849
|
+
...settingsOps(root),
|
|
8850
|
+
...upgradeOps(root),
|
|
8851
|
+
...talk,
|
|
8852
|
+
...layersOps(root),
|
|
8853
|
+
...draftsOps(root),
|
|
8854
|
+
...cursors
|
|
8855
|
+
};
|
|
8856
|
+
};
|
|
8857
|
+
storeAt = (root) => succeed$2(Store)(makeStore(root));
|
|
8858
|
+
storeAt(defaultRoot());
|
|
8859
|
+
}));
|
|
8860
|
+
//#endregion
|
|
8861
|
+
//#region src/service/store/index.ts
|
|
8862
|
+
var init_store = __esmMin((() => {
|
|
8863
|
+
init_service$1();
|
|
8864
|
+
init_error$2();
|
|
8865
|
+
init_paths();
|
|
8866
|
+
init_model$5();
|
|
8867
|
+
})), lineOn;
|
|
8868
|
+
var init_model$4 = __esmMin((() => {
|
|
8869
|
+
init_dist();
|
|
8870
|
+
String$1.pipe(brand("@adiff/Blob"));
|
|
8871
|
+
String$1.pipe(brand("@adiff/FilePath"));
|
|
8872
|
+
lineOn = (row, side) => side === "new" ? row.newLine : row.oldLine;
|
|
8873
|
+
}));
|
|
8874
|
+
//#endregion
|
|
8875
|
+
//#region src/domain/patch/anchor.ts
|
|
8876
|
+
var sideOf, linesOn, anchorFor;
|
|
8877
|
+
var init_anchor = __esmMin((() => {
|
|
8878
|
+
init_dist();
|
|
8879
|
+
init_model$4();
|
|
8880
|
+
sideOf = (rows) => rows.some((row) => isSome(row.newLine)) ? "new" : "old";
|
|
8881
|
+
linesOn = (rows, side) => rows.flatMap((row) => match$3(lineOn(row, side), {
|
|
8882
|
+
onNone: () => [],
|
|
8883
|
+
onSome: (n) => [n]
|
|
8884
|
+
}));
|
|
8885
|
+
anchorFor = (patch, from, to) => {
|
|
8886
|
+
const [low, high] = from <= to ? [from, to] : [to, from];
|
|
8887
|
+
const rows = patch.rows.slice(low, high + 1);
|
|
8888
|
+
if (rows.length === 0) return none();
|
|
8889
|
+
const side = sideOf(rows);
|
|
8890
|
+
const lines = linesOn(rows, side);
|
|
8891
|
+
if (lines.length === 0) return none();
|
|
8892
|
+
return some({
|
|
8893
|
+
path: patch.path,
|
|
8894
|
+
blob: patch.blob,
|
|
8895
|
+
side,
|
|
8896
|
+
start: Math.min(...lines),
|
|
8897
|
+
end: Math.max(...lines),
|
|
8898
|
+
snippet: rows.map((row) => row.text).join("\n")
|
|
8899
|
+
});
|
|
8900
|
+
};
|
|
8901
|
+
}));
|
|
8902
|
+
//#endregion
|
|
8903
|
+
//#region src/domain/patch/parse.ts
|
|
8904
|
+
var FILE_MARKER, HUNK_MARKER, BLOB_MARKER, OLD_PATH_MARKER, NEW_PATH_MARKER, HUNK_HEADER, FILE_HEADER, SIGNS$1, draftFrom, openHunk, appendRow, readBody, readHeader, parsePatches;
|
|
8905
|
+
var init_parse$1 = __esmMin((() => {
|
|
8906
|
+
init_dist();
|
|
8907
|
+
FILE_MARKER = "diff --git ";
|
|
8908
|
+
HUNK_MARKER = "@@";
|
|
8909
|
+
BLOB_MARKER = "index ";
|
|
8910
|
+
OLD_PATH_MARKER = "--- ";
|
|
8911
|
+
NEW_PATH_MARKER = "+++ ";
|
|
8912
|
+
HUNK_HEADER = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/;
|
|
8913
|
+
FILE_HEADER = / a\/(.+) b\/(.+)$/;
|
|
8914
|
+
SIGNS$1 = {
|
|
8915
|
+
" ": "context",
|
|
8916
|
+
"+": "added",
|
|
8917
|
+
"-": "removed"
|
|
8918
|
+
};
|
|
8919
|
+
draftFrom = (line) => {
|
|
8920
|
+
const named = FILE_HEADER.exec(line);
|
|
8921
|
+
return {
|
|
8922
|
+
path: named?.[2] ?? "",
|
|
8923
|
+
previousPath: named?.[1] ?? "",
|
|
8924
|
+
blob: "",
|
|
8925
|
+
headerLines: [line],
|
|
8926
|
+
hunks: [],
|
|
8927
|
+
rows: [],
|
|
8928
|
+
added: 0,
|
|
8929
|
+
removed: 0,
|
|
8930
|
+
oldLine: 1,
|
|
8931
|
+
newLine: 1
|
|
8932
|
+
};
|
|
8933
|
+
};
|
|
8934
|
+
openHunk = (draft, line) => {
|
|
8935
|
+
const header = HUNK_HEADER.exec(line);
|
|
8936
|
+
const previousNew = draft.newLine;
|
|
8937
|
+
draft.oldLine = Number(header?.[1] ?? 1);
|
|
8938
|
+
draft.newLine = Number(header?.[2] ?? 1);
|
|
8939
|
+
draft.hunks.push({
|
|
8940
|
+
marker: line,
|
|
8941
|
+
scope: (header?.[3] ?? "").trim(),
|
|
8942
|
+
startRow: draft.rows.length,
|
|
8943
|
+
newStart: draft.newLine,
|
|
8944
|
+
rows: [],
|
|
8945
|
+
skipped: draft.hunks.length === 0 ? 0 : Math.max(0, draft.newLine - previousNew)
|
|
8946
|
+
});
|
|
8947
|
+
};
|
|
8948
|
+
appendRow = (draft, kind, text) => {
|
|
8949
|
+
const row = {
|
|
8950
|
+
index: draft.rows.length,
|
|
8951
|
+
kind,
|
|
8952
|
+
oldLine: kind === "added" ? none() : some(draft.oldLine),
|
|
8953
|
+
newLine: kind === "removed" ? none() : some(draft.newLine),
|
|
8954
|
+
text
|
|
8955
|
+
};
|
|
8956
|
+
if (kind !== "added") draft.oldLine += 1;
|
|
8957
|
+
if (kind !== "removed") draft.newLine += 1;
|
|
8958
|
+
if (kind === "added") draft.added += 1;
|
|
8959
|
+
if (kind === "removed") draft.removed += 1;
|
|
8960
|
+
draft.rows.push(row);
|
|
8961
|
+
draft.hunks.at(-1)?.rows.push(row);
|
|
8962
|
+
};
|
|
8963
|
+
readBody = (draft, line) => {
|
|
8964
|
+
const kind = SIGNS$1[line.slice(0, 1)];
|
|
8965
|
+
if (kind !== void 0) appendRow(draft, kind, line.slice(1));
|
|
8966
|
+
};
|
|
8967
|
+
readHeader = (draft, line) => {
|
|
8968
|
+
if (line.startsWith(BLOB_MARKER)) {
|
|
8969
|
+
draft.blob = line.slice(6).split("..")[1]?.split(" ")[0] ?? "";
|
|
8970
|
+
draft.headerLines.push(line);
|
|
8971
|
+
return true;
|
|
8972
|
+
}
|
|
8973
|
+
if (line.startsWith(OLD_PATH_MARKER) || line.startsWith(NEW_PATH_MARKER)) {
|
|
8974
|
+
draft.headerLines.push(line);
|
|
8975
|
+
return true;
|
|
8976
|
+
}
|
|
8977
|
+
return false;
|
|
8978
|
+
};
|
|
8979
|
+
parsePatches = (diff) => {
|
|
8980
|
+
const drafts = [];
|
|
8981
|
+
for (const line of diff.split("\n")) {
|
|
8982
|
+
if (line.startsWith(FILE_MARKER)) {
|
|
8983
|
+
drafts.push(draftFrom(line));
|
|
8984
|
+
continue;
|
|
8985
|
+
}
|
|
8986
|
+
const draft = drafts.at(-1);
|
|
8987
|
+
if (draft === void 0) continue;
|
|
8988
|
+
if (readHeader(draft, line)) continue;
|
|
8989
|
+
if (line.startsWith(HUNK_MARKER)) openHunk(draft, line);
|
|
8990
|
+
else readBody(draft, line);
|
|
8991
|
+
}
|
|
8992
|
+
return drafts;
|
|
8993
|
+
};
|
|
8994
|
+
}));
|
|
8995
|
+
//#endregion
|
|
8996
|
+
//#region src/domain/patch/render.ts
|
|
8997
|
+
var init_render$1 = __esmMin((() => {
|
|
8998
|
+
init_model$4();
|
|
8999
|
+
}));
|
|
9000
|
+
//#endregion
|
|
9001
|
+
//#region src/domain/patch/sticky.ts
|
|
9002
|
+
var CLOSER, COMMENT, LOOKAHEAD, indentOf, pinnable, limitFrom, stickyChain;
|
|
9003
|
+
var init_sticky = __esmMin((() => {
|
|
9004
|
+
CLOSER = /^[)\]}>;,]/;
|
|
9005
|
+
COMMENT = /^(\/\/|\/\*|\*|#|<!--)/;
|
|
9006
|
+
LOOKAHEAD = 5;
|
|
9007
|
+
indentOf = (text) => text.length - text.trimStart().length;
|
|
9008
|
+
pinnable = (text) => {
|
|
9009
|
+
const trimmed = text.trim();
|
|
9010
|
+
if (trimmed.length === 0) return false;
|
|
9011
|
+
return !CLOSER.test(trimmed) && !COMMENT.test(trimmed);
|
|
9012
|
+
};
|
|
9013
|
+
limitFrom = (source, index) => {
|
|
9014
|
+
const here = source[index] ?? "";
|
|
9015
|
+
if (here.trim().length > 0) return indentOf(here);
|
|
9016
|
+
const ahead = source.slice(index, index + LOOKAHEAD).find((line) => line.trim().length > 0);
|
|
9017
|
+
return ahead === void 0 ? 0 : indentOf(ahead);
|
|
9018
|
+
};
|
|
9019
|
+
stickyChain = (source, line, max) => {
|
|
9020
|
+
const index = line - 1;
|
|
9021
|
+
if (index <= 0 || index >= source.length) return [];
|
|
9022
|
+
let limit = limitFrom(source, index);
|
|
9023
|
+
const chain = [];
|
|
9024
|
+
for (let above = index - 1; above >= 0; above -= 1) {
|
|
9025
|
+
const text = source[above] ?? "";
|
|
9026
|
+
if (!pinnable(text)) continue;
|
|
9027
|
+
const indent = indentOf(text);
|
|
9028
|
+
if (indent >= limit) continue;
|
|
9029
|
+
chain.push(text);
|
|
9030
|
+
limit = indent;
|
|
9031
|
+
if (indent === 0) break;
|
|
9032
|
+
}
|
|
9033
|
+
return chain.toReversed().slice(0, max);
|
|
9034
|
+
};
|
|
9035
|
+
}));
|
|
9036
|
+
//#endregion
|
|
9037
|
+
//#region src/domain/patch/index.ts
|
|
9038
|
+
var init_patch = __esmMin((() => {
|
|
9039
|
+
init_anchor();
|
|
9040
|
+
init_parse$1();
|
|
9041
|
+
init_render$1();
|
|
9042
|
+
init_sticky();
|
|
9043
|
+
init_model$4();
|
|
9044
|
+
})), GitCommandFailed, FileUnreadable;
|
|
9045
|
+
var init_error$1 = __esmMin((() => {
|
|
9046
|
+
init_dist();
|
|
9047
|
+
GitCommandFailed = class extends TaggedError("GitCommandFailed") {};
|
|
9048
|
+
TaggedError("NotARepository");
|
|
9049
|
+
FileUnreadable = class extends TaggedError("FileUnreadable") {};
|
|
9050
|
+
}));
|
|
9051
|
+
//#endregion
|
|
9052
|
+
//#region src/service/git/run.ts
|
|
9053
|
+
var exec, MAX_OUTPUT, git, gitOrEmpty;
|
|
9054
|
+
var init_run = __esmMin((() => {
|
|
9055
|
+
init_dist();
|
|
9056
|
+
init_error$1();
|
|
9057
|
+
exec = promisify(execFile);
|
|
9058
|
+
MAX_OUTPUT = 67108864;
|
|
9059
|
+
git = fn("Git.run")(function* (cwd, args) {
|
|
9060
|
+
return yield* tryPromise({
|
|
9061
|
+
try: () => exec("git", [...args], {
|
|
9062
|
+
cwd,
|
|
9063
|
+
maxBuffer: MAX_OUTPUT,
|
|
9064
|
+
encoding: "utf8"
|
|
9065
|
+
}),
|
|
9066
|
+
catch: (cause) => new GitCommandFailed({
|
|
9067
|
+
command: args,
|
|
9068
|
+
cwd,
|
|
9069
|
+
stderr: cause instanceof Error ? cause.message : String(cause)
|
|
9070
|
+
})
|
|
9071
|
+
}).pipe(map((result) => result.stdout));
|
|
9072
|
+
});
|
|
9073
|
+
gitOrEmpty = fn("Git.runOrEmpty")(function* (cwd, args) {
|
|
9074
|
+
return yield* git(cwd, args).pipe(catchTag("GitCommandFailed", () => succeed$1("")));
|
|
9075
|
+
});
|
|
9076
|
+
}));
|
|
9077
|
+
//#endregion
|
|
9078
|
+
//#region src/service/git/service.ts
|
|
9079
|
+
var GREP_CONTEXT, AT_ONCE$1, DEFAULT_BRANCH_CANDIDATES, STAT, Git, parseStat, readEntries, baseNames, mergeBases, findDefaultBranch, defaultBranch, mergeBaseOf, toWorktree, branchTips, parents, parentOf, splitLines, absent, readText, settled, seenAs, listWorktrees, readDiff, readStat, readSource, readBlob, readGrep, shape, GitLive;
|
|
9080
|
+
var init_service = __esmMin((() => {
|
|
9081
|
+
init_dist();
|
|
9082
|
+
init_error$1();
|
|
9083
|
+
init_run();
|
|
9084
|
+
GREP_CONTEXT = 2;
|
|
9085
|
+
AT_ONCE$1 = 8;
|
|
9086
|
+
DEFAULT_BRANCH_CANDIDATES = [
|
|
9087
|
+
"origin/master",
|
|
9088
|
+
"origin/main",
|
|
9089
|
+
"master",
|
|
9090
|
+
"main"
|
|
9091
|
+
];
|
|
9092
|
+
STAT = /(\d+) files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/;
|
|
9093
|
+
Git = class extends Service()("adiff/Git") {};
|
|
9094
|
+
parseStat = (raw) => {
|
|
9095
|
+
const matched = STAT.exec(raw);
|
|
9096
|
+
return {
|
|
9097
|
+
files: Number(matched?.[1] ?? 0),
|
|
9098
|
+
added: Number(matched?.[2] ?? 0),
|
|
9099
|
+
removed: Number(matched?.[3] ?? 0)
|
|
9100
|
+
};
|
|
9101
|
+
};
|
|
9102
|
+
readEntries = (porcelain) => {
|
|
9103
|
+
const entries = [];
|
|
9104
|
+
for (const line of porcelain.split("\n")) {
|
|
9105
|
+
if (line.startsWith("worktree ")) entries.push({
|
|
9106
|
+
path: line.slice(9),
|
|
9107
|
+
branch: "",
|
|
9108
|
+
head: "",
|
|
9109
|
+
detached: false
|
|
9110
|
+
});
|
|
9111
|
+
const current = entries.at(-1);
|
|
9112
|
+
if (current === void 0) continue;
|
|
9113
|
+
if (line.startsWith("branch ")) current.branch = line.slice(7).replace("refs/heads/", "");
|
|
9114
|
+
if (line.startsWith("HEAD ")) current.head = line.slice(5);
|
|
9115
|
+
if (line === "detached") current.detached = true;
|
|
9116
|
+
}
|
|
9117
|
+
return entries;
|
|
9118
|
+
};
|
|
9119
|
+
baseNames = /* @__PURE__ */ new Map();
|
|
9120
|
+
mergeBases = /* @__PURE__ */ new Map();
|
|
9121
|
+
findDefaultBranch = fn("Git.findDefaultBranch")(function* (repo) {
|
|
9122
|
+
const symbolic = yield* gitOrEmpty(repo, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
|
|
9123
|
+
if (symbolic.trim().length > 0) return symbolic.trim().replace("refs/remotes/", "");
|
|
9124
|
+
for (const candidate of DEFAULT_BRANCH_CANDIDATES) if ((yield* gitOrEmpty(repo, [
|
|
9125
|
+
"rev-parse",
|
|
9126
|
+
"--verify",
|
|
9127
|
+
candidate
|
|
9128
|
+
])).trim().length > 0) return candidate;
|
|
9129
|
+
return "HEAD";
|
|
9130
|
+
});
|
|
9131
|
+
defaultBranch = fn("Git.defaultBranch")(function* (repo) {
|
|
9132
|
+
const known = baseNames.get(repo);
|
|
9133
|
+
if (known !== void 0) return known;
|
|
9134
|
+
const found = yield* findDefaultBranch(repo);
|
|
9135
|
+
baseNames.set(repo, found);
|
|
9136
|
+
return found;
|
|
9137
|
+
});
|
|
9138
|
+
mergeBaseOf = fn("Git.mergeBase")(function* (entry, base) {
|
|
9139
|
+
const key = `${entry.path} ${entry.head} ${base}`;
|
|
9140
|
+
const known = mergeBases.get(key);
|
|
9141
|
+
if (known !== void 0) return known;
|
|
9142
|
+
const found = (yield* gitOrEmpty(entry.path, [
|
|
9143
|
+
"merge-base",
|
|
9144
|
+
base,
|
|
9145
|
+
"HEAD"
|
|
9146
|
+
])).trim();
|
|
9147
|
+
mergeBases.set(key, found);
|
|
9148
|
+
return found;
|
|
9149
|
+
});
|
|
9150
|
+
toWorktree = fn("Git.toWorktree")(function* (entry, base, own) {
|
|
9151
|
+
const mergeBase = yield* mergeBaseOf(entry, base);
|
|
9152
|
+
return {
|
|
9153
|
+
path: entry.path,
|
|
9154
|
+
branch: entry.detached ? `(detached ${entry.head.slice(0, 8)})` : entry.branch,
|
|
9155
|
+
head: entry.head.slice(0, 8),
|
|
9156
|
+
base: mergeBase.slice(0, 8),
|
|
9157
|
+
detached: entry.detached,
|
|
9158
|
+
own
|
|
9159
|
+
};
|
|
9160
|
+
});
|
|
9161
|
+
branchTips = fn("Git.branchTips")(function* (repo) {
|
|
9162
|
+
const raw = yield* gitOrEmpty(repo, [
|
|
9163
|
+
"for-each-ref",
|
|
9164
|
+
"--format=%(objectname) %(refname:short)",
|
|
9165
|
+
"refs/heads"
|
|
9166
|
+
]);
|
|
9167
|
+
const tips = /* @__PURE__ */ new Map();
|
|
9168
|
+
for (const line of raw.split("\n")) {
|
|
9169
|
+
const [sha, ...rest] = line.trim().split(" ");
|
|
9170
|
+
const name = rest.join(" ");
|
|
9171
|
+
if (sha === void 0 || sha.length === 0 || name.length === 0) continue;
|
|
9172
|
+
const held = tips.get(sha);
|
|
9173
|
+
if (held === void 0) tips.set(sha, [name]);
|
|
9174
|
+
else held.push(name);
|
|
9175
|
+
}
|
|
9176
|
+
return tips;
|
|
9177
|
+
});
|
|
9178
|
+
parents = /* @__PURE__ */ new Map();
|
|
9179
|
+
parentOf = fn("Git.parentOf")(function* (repo, branch, fallback) {
|
|
9180
|
+
const own = (yield* gitOrEmpty(repo, ["rev-list", `${fallback}..${branch}`])).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
9181
|
+
const tip = own[0];
|
|
9182
|
+
if (tip === void 0) return fallback;
|
|
9183
|
+
const key = `${repo} ${branch} ${tip} ${fallback}`;
|
|
9184
|
+
const known = parents.get(key);
|
|
9185
|
+
if (known !== void 0) return known;
|
|
9186
|
+
const tips = yield* branchTips(repo);
|
|
9187
|
+
const found = own.slice(1).flatMap((sha) => tips.get(sha) ?? []).find((name) => name !== branch);
|
|
9188
|
+
parents.set(key, found ?? fallback);
|
|
9189
|
+
return found ?? fallback;
|
|
9190
|
+
});
|
|
9191
|
+
splitLines = (text) => text.split("\n");
|
|
9192
|
+
absent = succeed$1(none());
|
|
9193
|
+
readText = fn("Git.readText")(function* (absolute, path) {
|
|
9194
|
+
return yield* tryPromise({
|
|
9195
|
+
try: () => readFile(absolute, "utf8"),
|
|
9196
|
+
catch: (cause) => new FileUnreadable({
|
|
9197
|
+
path,
|
|
9198
|
+
reason: String(cause)
|
|
9199
|
+
})
|
|
9200
|
+
}).pipe(map(some), catchTag("FileUnreadable", () => absent));
|
|
9201
|
+
});
|
|
9202
|
+
settled = (path) => promise(() => realpath(path).catch(() => resolve(path)));
|
|
9203
|
+
seenAs = fn("Git.seenAs")(function* (entry, base, opened) {
|
|
9204
|
+
const path = yield* settled(entry.path);
|
|
9205
|
+
return yield* toWorktree(entry, base, path === opened);
|
|
9206
|
+
});
|
|
9207
|
+
listWorktrees = fn("Git.worktrees")(function* (repo) {
|
|
9208
|
+
const porcelain = yield* gitOrEmpty(repo, [
|
|
9209
|
+
"worktree",
|
|
9210
|
+
"list",
|
|
9211
|
+
"--porcelain"
|
|
9212
|
+
]);
|
|
9213
|
+
const base = yield* defaultBranch(repo);
|
|
9214
|
+
const entries = readEntries(porcelain);
|
|
9215
|
+
const opened = yield* settled(repo);
|
|
9216
|
+
const read = (entry) => seenAs(entry, base, opened);
|
|
9217
|
+
return yield* forEach(entries, read, { concurrency: AT_ONCE$1 });
|
|
9218
|
+
});
|
|
9219
|
+
readDiff = fn("Git.diff")(function* (worktree, context, only) {
|
|
9220
|
+
const target = worktree.base.length > 0 ? worktree.base : "HEAD";
|
|
9221
|
+
const scope = only === void 0 ? [] : ["--", only];
|
|
9222
|
+
return yield* gitOrEmpty(worktree.path, [
|
|
9223
|
+
"diff",
|
|
9224
|
+
`-U${context}`,
|
|
9225
|
+
target,
|
|
9226
|
+
...scope
|
|
9227
|
+
]);
|
|
9228
|
+
});
|
|
9229
|
+
readStat = fn("Git.stat")(function* (worktree) {
|
|
9230
|
+
const raw = yield* gitOrEmpty(worktree.path, [
|
|
9231
|
+
"diff",
|
|
9232
|
+
"--shortstat",
|
|
9233
|
+
worktree.base
|
|
9234
|
+
]);
|
|
9235
|
+
return parseStat(raw);
|
|
9236
|
+
});
|
|
9237
|
+
readSource = fn("Git.source")(function* (worktree, path) {
|
|
9238
|
+
const text = yield* readText(join(worktree.path, path), path);
|
|
9239
|
+
return map$4(text, splitLines);
|
|
9240
|
+
});
|
|
9241
|
+
readBlob = fn("Git.blob")(function* (worktree, path) {
|
|
9242
|
+
const target = worktree.base.length > 0 ? worktree.base : "HEAD";
|
|
9243
|
+
const raw = yield* gitOrEmpty(worktree.path, ["show", `${target}:${path}`]);
|
|
9244
|
+
return raw.length === 0 ? none() : some(splitLines(raw));
|
|
9245
|
+
});
|
|
9246
|
+
readGrep = fn("Git.grep")(function* (worktree, term) {
|
|
9247
|
+
return yield* gitOrEmpty(worktree.path, [
|
|
9248
|
+
"grep",
|
|
9249
|
+
"--no-color",
|
|
9250
|
+
"-n",
|
|
9251
|
+
"-I",
|
|
9252
|
+
"-F",
|
|
9253
|
+
"-i",
|
|
9254
|
+
"-w",
|
|
9255
|
+
"-C",
|
|
9256
|
+
String(GREP_CONTEXT),
|
|
9257
|
+
"-e",
|
|
9258
|
+
term
|
|
9259
|
+
]);
|
|
9260
|
+
});
|
|
9261
|
+
shape = {
|
|
9262
|
+
worktrees: listWorktrees,
|
|
9263
|
+
repoOf: fn("Git.repoOf")(function* (worktree) {
|
|
9264
|
+
const trimmed = (yield* gitOrEmpty(worktree, [
|
|
9265
|
+
"rev-parse",
|
|
9266
|
+
"--path-format=absolute",
|
|
9267
|
+
"--git-common-dir"
|
|
9268
|
+
])).trim();
|
|
9269
|
+
return trimmed.length === 0 ? resolve(worktree) : resolve(trimmed, "..");
|
|
9270
|
+
}),
|
|
9271
|
+
diff: readDiff,
|
|
9272
|
+
stat: readStat,
|
|
9273
|
+
source: readSource,
|
|
9274
|
+
blob: readBlob,
|
|
9275
|
+
grep: readGrep,
|
|
9276
|
+
defaultBranch,
|
|
9277
|
+
stackParent: (repo, branch) => defaultBranch(repo).pipe(flatMap((fallback) => parentOf(repo, branch, fallback))),
|
|
9278
|
+
resolves: fn("Git.resolves")(function* (repo, ref) {
|
|
9279
|
+
return (yield* gitOrEmpty(repo, [
|
|
9280
|
+
"rev-parse",
|
|
9281
|
+
"--verify",
|
|
9282
|
+
`${ref}^{commit}`
|
|
9283
|
+
])).trim().length > 0;
|
|
9284
|
+
}),
|
|
9285
|
+
sharedWith: fn("Git.sharedWith")(function* (repo, branch, ref) {
|
|
9286
|
+
return (yield* gitOrEmpty(repo, [
|
|
9287
|
+
"merge-base",
|
|
9288
|
+
branch,
|
|
9289
|
+
ref
|
|
9290
|
+
])).trim();
|
|
9291
|
+
})
|
|
9292
|
+
};
|
|
9293
|
+
GitLive = succeed$2(Git)(shape);
|
|
9294
|
+
}));
|
|
9295
|
+
//#endregion
|
|
9296
|
+
//#region src/service/git/index.ts
|
|
9297
|
+
var init_git = __esmMin((() => {
|
|
9298
|
+
init_service();
|
|
9299
|
+
init_error$1();
|
|
9300
|
+
}));
|
|
9301
|
+
//#endregion
|
|
9302
|
+
//#region src/domain/review/vouch.ts
|
|
9303
|
+
var isVouched, vouch;
|
|
9304
|
+
var init_vouch = __esmMin((() => {
|
|
9305
|
+
isVouched = (vouches, path, blob) => vouches[path] === blob;
|
|
9306
|
+
vouch = (vouches, path, blob) => {
|
|
9307
|
+
if (isVouched(vouches, path, blob)) {
|
|
9308
|
+
const { [path]: _cleared, ...rest } = vouches;
|
|
9309
|
+
return rest;
|
|
9310
|
+
}
|
|
9311
|
+
return {
|
|
9312
|
+
...vouches,
|
|
9313
|
+
[path]: blob
|
|
9088
9314
|
};
|
|
9089
9315
|
};
|
|
9090
|
-
|
|
9091
|
-
|
|
9316
|
+
}));
|
|
9317
|
+
var init_model$3 = __esmMin((() => {
|
|
9318
|
+
init_dist();
|
|
9319
|
+
String$1.pipe(brand("@adiff/CommentId"));
|
|
9092
9320
|
}));
|
|
9093
9321
|
//#endregion
|
|
9094
|
-
//#region src/
|
|
9095
|
-
var
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
init_paths();
|
|
9322
|
+
//#region src/domain/review/index.ts
|
|
9323
|
+
var init_review = __esmMin((() => {
|
|
9324
|
+
init_dist();
|
|
9325
|
+
init_vouch();
|
|
9099
9326
|
init_model$3();
|
|
9100
9327
|
}));
|
|
9101
9328
|
//#endregion
|
|
@@ -9151,8 +9378,8 @@ var init_preferences = __esmMin((() => {
|
|
|
9151
9378
|
}));
|
|
9152
9379
|
//#endregion
|
|
9153
9380
|
//#region src/cli/error.ts
|
|
9154
|
-
var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, NoLayers, InitUnwritable;
|
|
9155
|
-
var init_error
|
|
9381
|
+
var UnknownBranch, UnknownBase, UnknownFile, UnknownComment, UnknownPreference, UnknownPreferenceValue, UnselectableRange, UnknownCommand, MissingOption, UnknownWorktree, MalformedLayers, UnknownDraft, NothingDrafted, PullMoved, NoLayers, InitUnwritable;
|
|
9382
|
+
var init_error = __esmMin((() => {
|
|
9156
9383
|
init_dist();
|
|
9157
9384
|
UnknownBranch = class extends TaggedError("UnknownBranch") {};
|
|
9158
9385
|
UnknownBase = class extends TaggedError("UnknownBase") {};
|
|
@@ -9165,9 +9392,12 @@ var init_error$1 = __esmMin((() => {
|
|
|
9165
9392
|
MissingOption = class extends TaggedError("MissingOption") {};
|
|
9166
9393
|
UnknownWorktree = class extends TaggedError("UnknownWorktree") {};
|
|
9167
9394
|
MalformedLayers = class extends TaggedError("MalformedLayers") {};
|
|
9395
|
+
UnknownDraft = class extends TaggedError("UnknownDraft") {};
|
|
9396
|
+
NothingDrafted = class extends TaggedError("NothingDrafted") {};
|
|
9397
|
+
PullMoved = class extends TaggedError("PullMoved") {};
|
|
9168
9398
|
NoLayers = class extends TaggedError("NoLayers") {};
|
|
9169
9399
|
InitUnwritable = class extends TaggedError("InitUnwritable") {};
|
|
9170
|
-
})), CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, AT_ONCE, summaryOf, summaryFor, listBranches, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, sentIn, listSent, commentIn, submitComment, without$1, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, setBase, clearBase, markRead;
|
|
9400
|
+
})), CONTEXT, WHOLE_FILE$1, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, rowsCovering, waitingOn, AT_ONCE, summaryOf, summaryFor, listBranches, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, sentIn, listSent, anchorIn, commentIn, submitComment, without$1, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, setBase, clearBase, markRead;
|
|
9171
9401
|
var init_commands = __esmMin((() => {
|
|
9172
9402
|
init_dist();
|
|
9173
9403
|
init_patch();
|
|
@@ -9175,12 +9405,12 @@ var init_commands = __esmMin((() => {
|
|
|
9175
9405
|
init_review();
|
|
9176
9406
|
init_store();
|
|
9177
9407
|
init_preferences();
|
|
9178
|
-
init_error
|
|
9408
|
+
init_error();
|
|
9179
9409
|
CONTEXT = 3;
|
|
9180
9410
|
WHOLE_FILE$1 = 1e5;
|
|
9181
9411
|
POLL = "500 millis";
|
|
9182
9412
|
AUTO = "auto";
|
|
9183
|
-
askedFor = (asked, held) => {
|
|
9413
|
+
askedFor$1 = (asked, held) => {
|
|
9184
9414
|
if (asked !== void 0 && asked !== AUTO) return {
|
|
9185
9415
|
ref: asked,
|
|
9186
9416
|
basis: "set"
|
|
@@ -9200,7 +9430,7 @@ var init_commands = __esmMin((() => {
|
|
|
9200
9430
|
basedOn = fn("Cli.basedOn")(function* (repo, worktree, asked) {
|
|
9201
9431
|
const git = yield* Git;
|
|
9202
9432
|
const held = (yield* (yield* Store).state(worktree.path)).base;
|
|
9203
|
-
const wanted = askedFor(asked, held);
|
|
9433
|
+
const wanted = askedFor$1(asked, held);
|
|
9204
9434
|
const fallback = yield* git.defaultBranch(repo);
|
|
9205
9435
|
const guessed = wanted.ref.length === 0;
|
|
9206
9436
|
const ref = guessed ? yield* git.stackParent(repo, worktree.branch) : wanted.ref;
|
|
@@ -9414,8 +9644,7 @@ var init_commands = __esmMin((() => {
|
|
|
9414
9644
|
listSent = fn("Cli.listSent")(function* (repo, branch, base) {
|
|
9415
9645
|
return yield* sentIn(yield* readingOf(repo, branch, base));
|
|
9416
9646
|
});
|
|
9417
|
-
|
|
9418
|
-
const store = yield* Store;
|
|
9647
|
+
anchorIn = fn("Cli.anchorIn")(function* (worktree, request) {
|
|
9419
9648
|
const only = yield* patchesOf(worktree, WHOLE_FILE$1, request.file);
|
|
9420
9649
|
const patches = only.length > 0 ? only : yield* patchesOf(worktree, WHOLE_FILE$1);
|
|
9421
9650
|
const patch = findPatch(patches, request.file);
|
|
@@ -9430,7 +9659,7 @@ var init_commands = __esmMin((() => {
|
|
|
9430
9659
|
const first = rows[0];
|
|
9431
9660
|
const last = rows.at(-1);
|
|
9432
9661
|
const anchor = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
|
|
9433
|
-
|
|
9662
|
+
return yield* match$3(anchor, {
|
|
9434
9663
|
onNone: () => new UnselectableRange({
|
|
9435
9664
|
file: request.file,
|
|
9436
9665
|
start: request.start,
|
|
@@ -9438,6 +9667,10 @@ var init_commands = __esmMin((() => {
|
|
|
9438
9667
|
}),
|
|
9439
9668
|
onSome: succeed$1
|
|
9440
9669
|
});
|
|
9670
|
+
});
|
|
9671
|
+
commentIn = fn("Cli.commentIn")(function* (worktree, request) {
|
|
9672
|
+
const store = yield* Store;
|
|
9673
|
+
const chosen = yield* anchorIn(worktree, request);
|
|
9441
9674
|
const batch = {
|
|
9442
9675
|
id: request.id,
|
|
9443
9676
|
at: request.at,
|
|
@@ -9674,11 +9907,104 @@ var init_commands = __esmMin((() => {
|
|
|
9674
9907
|
});
|
|
9675
9908
|
}));
|
|
9676
9909
|
//#endregion
|
|
9910
|
+
//#region src/cli/drafts.ts
|
|
9911
|
+
var reported, listDrafts, addDraft, editDraft, dropDraft, sameCommit, commentOf, dispatchDrafts;
|
|
9912
|
+
var init_drafts = __esmMin((() => {
|
|
9913
|
+
init_dist();
|
|
9914
|
+
init_forge();
|
|
9915
|
+
init_store();
|
|
9916
|
+
init_commands();
|
|
9917
|
+
init_error();
|
|
9918
|
+
reported = (draft) => ({
|
|
9919
|
+
id: draft.id,
|
|
9920
|
+
file: draft.anchor.path,
|
|
9921
|
+
side: draft.anchor.side,
|
|
9922
|
+
start: draft.anchor.start,
|
|
9923
|
+
end: draft.anchor.end,
|
|
9924
|
+
body: draft.body,
|
|
9925
|
+
at: draft.at,
|
|
9926
|
+
wroteBy: draft.wroteBy
|
|
9927
|
+
});
|
|
9928
|
+
listDrafts = fn("Cli.listDrafts")(function* (repo, branch) {
|
|
9929
|
+
const store = yield* Store;
|
|
9930
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9931
|
+
return (yield* store.drafts(worktree.path)).map(reported);
|
|
9932
|
+
});
|
|
9933
|
+
addDraft = fn("Cli.addDraft")(function* (request) {
|
|
9934
|
+
const store = yield* Store;
|
|
9935
|
+
const worktree = yield* findBranch(request.repo, request.branch);
|
|
9936
|
+
const anchor = yield* anchorIn(worktree, request);
|
|
9937
|
+
const held = yield* store.drafts(worktree.path);
|
|
9938
|
+
const one = {
|
|
9939
|
+
id: request.id,
|
|
9940
|
+
anchor,
|
|
9941
|
+
body: request.body,
|
|
9942
|
+
at: request.at,
|
|
9943
|
+
wroteBy: request.wroteBy
|
|
9944
|
+
};
|
|
9945
|
+
yield* store.saveDrafts(worktree.path, [...held, one]);
|
|
9946
|
+
return reported(one);
|
|
9947
|
+
});
|
|
9948
|
+
editDraft = fn("Cli.editDraft")(function* (repo, branch, id, body) {
|
|
9949
|
+
const store = yield* Store;
|
|
9950
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9951
|
+
const held = yield* store.drafts(worktree.path);
|
|
9952
|
+
const found = held.find((one) => one.id === id);
|
|
9953
|
+
if (found === void 0) return yield* new UnknownDraft({ id });
|
|
9954
|
+
const said = {
|
|
9955
|
+
...found,
|
|
9956
|
+
body
|
|
9957
|
+
};
|
|
9958
|
+
const next = held.map((one) => one.id === id ? said : one);
|
|
9959
|
+
yield* store.saveDrafts(worktree.path, next);
|
|
9960
|
+
return reported(said);
|
|
9961
|
+
});
|
|
9962
|
+
dropDraft = fn("Cli.dropDraft")(function* (repo, branch, id) {
|
|
9963
|
+
const store = yield* Store;
|
|
9964
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9965
|
+
const held = yield* store.drafts(worktree.path);
|
|
9966
|
+
if (!held.some((one) => one.id === id)) return yield* new UnknownDraft({ id });
|
|
9967
|
+
yield* store.saveDrafts(worktree.path, held.filter((one) => one.id !== id));
|
|
9968
|
+
return { dropped: id };
|
|
9969
|
+
});
|
|
9970
|
+
sameCommit = (one, two) => {
|
|
9971
|
+
const short = one.length <= two.length ? one : two;
|
|
9972
|
+
const long = one.length <= two.length ? two : one;
|
|
9973
|
+
return short.length > 0 && long.startsWith(short);
|
|
9974
|
+
};
|
|
9975
|
+
commentOf = (draft) => ({
|
|
9976
|
+
path: draft.anchor.path,
|
|
9977
|
+
line: draft.anchor.end,
|
|
9978
|
+
side: draft.anchor.side,
|
|
9979
|
+
body: draft.body
|
|
9980
|
+
});
|
|
9981
|
+
dispatchDrafts = fn("Cli.dispatchDrafts")(function* (repo, branch) {
|
|
9982
|
+
const store = yield* Store;
|
|
9983
|
+
const forge = yield* Forge;
|
|
9984
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9985
|
+
const held = yield* store.drafts(worktree.path);
|
|
9986
|
+
if (held.length === 0) return yield* new NothingDrafted({ branch });
|
|
9987
|
+
const head = yield* forge.head(repo, branch);
|
|
9988
|
+
if (!sameCommit(worktree.head, head)) return yield* new PullMoved({
|
|
9989
|
+
branch,
|
|
9990
|
+
was: worktree.head,
|
|
9991
|
+
now: head
|
|
9992
|
+
});
|
|
9993
|
+
const sent = yield* forge.review(repo, branch, held.map(commentOf));
|
|
9994
|
+
yield* store.saveDrafts(worktree.path, []);
|
|
9995
|
+
return {
|
|
9996
|
+
sent: sent.landed.length,
|
|
9997
|
+
url: sent.url,
|
|
9998
|
+
held: 0
|
|
9999
|
+
};
|
|
10000
|
+
});
|
|
10001
|
+
}));
|
|
10002
|
+
//#endregion
|
|
9677
10003
|
//#region src/cli/init.ts
|
|
9678
10004
|
var BEGIN, END, REACH, INSTRUCTIONS, IMPORT, blockIn, replaced, appended, planFor, readAt, writeAt, settle, skillSource, shippedSkill, settleSkill, SKILL_AT, refreshAt, settledRoot, refreshSkill, initRepository;
|
|
9679
10005
|
var init_init = __esmMin((() => {
|
|
9680
10006
|
init_dist();
|
|
9681
|
-
init_error
|
|
10007
|
+
init_error();
|
|
9682
10008
|
BEGIN = "<!-- adiff:begin -->";
|
|
9683
10009
|
END = "<!-- adiff:end -->";
|
|
9684
10010
|
REACH = 5;
|
|
@@ -9824,10 +10150,10 @@ var init_init = __esmMin((() => {
|
|
|
9824
10150
|
}));
|
|
9825
10151
|
//#endregion
|
|
9826
10152
|
//#region src/cli/pane.ts
|
|
9827
|
-
var TIMEOUT_MS
|
|
10153
|
+
var TIMEOUT_MS, set, splitters, onBranch, selfInvocation, ran, split, openPane;
|
|
9828
10154
|
var init_pane = __esmMin((() => {
|
|
9829
10155
|
init_dist();
|
|
9830
|
-
TIMEOUT_MS
|
|
10156
|
+
TIMEOUT_MS = 5e3;
|
|
9831
10157
|
set = (name) => (process.env[name] ?? "").length > 0;
|
|
9832
10158
|
splitters = [
|
|
9833
10159
|
{
|
|
@@ -9902,7 +10228,7 @@ var init_pane = __esmMin((() => {
|
|
|
9902
10228
|
];
|
|
9903
10229
|
};
|
|
9904
10230
|
ran = (binary, args) => callback$1((resume) => {
|
|
9905
|
-
execFile(binary, [...args], { timeout: TIMEOUT_MS
|
|
10231
|
+
execFile(binary, [...args], { timeout: TIMEOUT_MS }, (cause) => resume(succeed$1(cause === null)));
|
|
9906
10232
|
});
|
|
9907
10233
|
split = fn("Cli.split")(function* (chosen, repo, branch) {
|
|
9908
10234
|
return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo, branch)));
|
|
@@ -9924,10 +10250,10 @@ var init_pane = __esmMin((() => {
|
|
|
9924
10250
|
}));
|
|
9925
10251
|
//#endregion
|
|
9926
10252
|
//#region package.json
|
|
9927
|
-
|
|
10253
|
+
init_drafts();
|
|
9928
10254
|
init_init();
|
|
9929
10255
|
init_pane();
|
|
9930
|
-
var version$1 = "0.1.0-alpha.
|
|
10256
|
+
var version$1 = "0.1.0-alpha.108";
|
|
9931
10257
|
//#endregion
|
|
9932
10258
|
//#region src/cli/upgrade.ts
|
|
9933
10259
|
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, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
|
|
@@ -10127,6 +10453,7 @@ var HIT, NEAR$1, rowOf, readRows, near, byChangedFirst, searchIn, searchBranch;
|
|
|
10127
10453
|
var init_search = __esmMin((() => {
|
|
10128
10454
|
init_dist();
|
|
10129
10455
|
init_git();
|
|
10456
|
+
init_commands();
|
|
10130
10457
|
HIT = /^(.+?):(\d+):(.*)$/;
|
|
10131
10458
|
NEAR$1 = /^(.+?)-(\d+)-(.*)$/;
|
|
10132
10459
|
rowOf = (line) => {
|
|
@@ -10325,7 +10652,7 @@ var init_layers = __esmMin((() => {
|
|
|
10325
10652
|
init_git();
|
|
10326
10653
|
init_store();
|
|
10327
10654
|
init_commands();
|
|
10328
|
-
init_error
|
|
10655
|
+
init_error();
|
|
10329
10656
|
STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
|
|
10330
10657
|
unique = (paths) => [...new Set(paths)];
|
|
10331
10658
|
spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
|
|
@@ -10532,14 +10859,14 @@ var init_layers = __esmMin((() => {
|
|
|
10532
10859
|
}));
|
|
10533
10860
|
//#endregion
|
|
10534
10861
|
//#region src/cli/threads.ts
|
|
10535
|
-
var stateOf
|
|
10862
|
+
var stateOf, spoken$1, turnsOf, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleIn, settleThread, removeIn, removeComment, without, restoreComment, settleRead;
|
|
10536
10863
|
var init_threads = __esmMin((() => {
|
|
10537
10864
|
init_dist();
|
|
10538
10865
|
init_store();
|
|
10539
10866
|
init_commands();
|
|
10540
10867
|
init_layers();
|
|
10541
|
-
init_error
|
|
10542
|
-
stateOf
|
|
10868
|
+
init_error();
|
|
10869
|
+
stateOf = (turns, asked, isSettled, isRemoved) => {
|
|
10543
10870
|
if (isRemoved) return "removed";
|
|
10544
10871
|
if (isSettled) return "done";
|
|
10545
10872
|
const last = turns.at(-1);
|
|
@@ -10574,7 +10901,7 @@ var init_threads = __esmMin((() => {
|
|
|
10574
10901
|
start: comment.anchor.start,
|
|
10575
10902
|
end: comment.anchor.end,
|
|
10576
10903
|
body: comment.body,
|
|
10577
|
-
state: stateOf
|
|
10904
|
+
state: stateOf(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(reading.removed, comment.id)),
|
|
10578
10905
|
stale: batch.head !== reading.head,
|
|
10579
10906
|
outside: !reading.shown.has(comment.anchor.path),
|
|
10580
10907
|
unread: Math.max(0, mine.length - seen),
|
|
@@ -10703,7 +11030,7 @@ var init_threads = __esmMin((() => {
|
|
|
10703
11030
|
var optionsFrom, required, numeric;
|
|
10704
11031
|
var init_parse = __esmMin((() => {
|
|
10705
11032
|
init_dist();
|
|
10706
|
-
init_error
|
|
11033
|
+
init_error();
|
|
10707
11034
|
optionsFrom = (argv) => {
|
|
10708
11035
|
const options = {};
|
|
10709
11036
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -10729,7 +11056,7 @@ var init_parse = __esmMin((() => {
|
|
|
10729
11056
|
}));
|
|
10730
11057
|
//#endregion
|
|
10731
11058
|
//#region src/cli/catalog.ts
|
|
10732
|
-
var worktreeOf, repoOf, branchOf, addressing, baseOf, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
|
|
11059
|
+
var worktreeOf, repoOf, branchOf, addressing, baseOf, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, catalog, commandNames, findCommand, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
|
|
10733
11060
|
var init_catalog = __esmMin((() => {
|
|
10734
11061
|
worktreeOf = {
|
|
10735
11062
|
name: "worktree",
|
|
@@ -10810,6 +11137,7 @@ var init_catalog = __esmMin((() => {
|
|
|
10810
11137
|
WRITE_COMMENTS = "Write comments";
|
|
10811
11138
|
ANSWER_COMMENTS = "Answer comments, in the worktree";
|
|
10812
11139
|
FOLLOW_UP = "Follow up";
|
|
11140
|
+
DRAFTS = "Draft a review of somebody else's pull request";
|
|
10813
11141
|
SET_UP = "Set up";
|
|
10814
11142
|
catalog = [
|
|
10815
11143
|
{
|
|
@@ -10999,6 +11327,75 @@ var init_catalog = __esmMin((() => {
|
|
|
10999
11327
|
dataKey: "layers",
|
|
11000
11328
|
example: "adiff layers show --worktree . --fields layers,uncovered"
|
|
11001
11329
|
},
|
|
11330
|
+
{
|
|
11331
|
+
name: "draft list",
|
|
11332
|
+
about: "The comments held for this pull request, in the order they were written",
|
|
11333
|
+
group: DRAFTS,
|
|
11334
|
+
addresses: "review",
|
|
11335
|
+
safety: "read",
|
|
11336
|
+
options: [...addressing],
|
|
11337
|
+
dataKey: "drafts",
|
|
11338
|
+
example: "adiff draft list --repo . --branch their-change"
|
|
11339
|
+
},
|
|
11340
|
+
{
|
|
11341
|
+
name: "draft add",
|
|
11342
|
+
about: "Hold one comment against a line range, to be sent with the rest",
|
|
11343
|
+
group: DRAFTS,
|
|
11344
|
+
addresses: "review",
|
|
11345
|
+
safety: "write",
|
|
11346
|
+
options: [...addressing, ...range],
|
|
11347
|
+
dataKey: "draft",
|
|
11348
|
+
example: "adiff draft add --repo . --branch their-change --file src/api.ts --start 4 --end 5 --body \"why\""
|
|
11349
|
+
},
|
|
11350
|
+
{
|
|
11351
|
+
name: "draft edit",
|
|
11352
|
+
about: "Rewrite a held comment before it is sent",
|
|
11353
|
+
group: DRAFTS,
|
|
11354
|
+
addresses: "review",
|
|
11355
|
+
safety: "write",
|
|
11356
|
+
options: [
|
|
11357
|
+
...addressing,
|
|
11358
|
+
{
|
|
11359
|
+
name: "id",
|
|
11360
|
+
required: true,
|
|
11361
|
+
value: "id",
|
|
11362
|
+
about: "The draft, as `draft list` reports it"
|
|
11363
|
+
},
|
|
11364
|
+
{
|
|
11365
|
+
name: "body",
|
|
11366
|
+
required: true,
|
|
11367
|
+
value: "text",
|
|
11368
|
+
about: "What it should say instead"
|
|
11369
|
+
}
|
|
11370
|
+
],
|
|
11371
|
+
dataKey: "draft",
|
|
11372
|
+
example: "adiff draft edit --repo . --branch their-change --id d1 --body \"softer\""
|
|
11373
|
+
},
|
|
11374
|
+
{
|
|
11375
|
+
name: "draft drop",
|
|
11376
|
+
about: "Throw away a held comment rather than sending it",
|
|
11377
|
+
group: DRAFTS,
|
|
11378
|
+
addresses: "review",
|
|
11379
|
+
safety: "write",
|
|
11380
|
+
options: [...addressing, {
|
|
11381
|
+
name: "id",
|
|
11382
|
+
required: true,
|
|
11383
|
+
value: "id",
|
|
11384
|
+
about: "The draft, as `draft list` reports it"
|
|
11385
|
+
}],
|
|
11386
|
+
dataKey: "dropped",
|
|
11387
|
+
example: "adiff draft drop --repo . --branch their-change --id d1"
|
|
11388
|
+
},
|
|
11389
|
+
{
|
|
11390
|
+
name: "draft send",
|
|
11391
|
+
about: "Send every held comment to the pull request, as one review",
|
|
11392
|
+
group: DRAFTS,
|
|
11393
|
+
addresses: "review",
|
|
11394
|
+
safety: "write",
|
|
11395
|
+
options: [...addressing],
|
|
11396
|
+
dataKey: "dispatched",
|
|
11397
|
+
example: "adiff draft send --repo . --branch their-change"
|
|
11398
|
+
},
|
|
11002
11399
|
{
|
|
11003
11400
|
name: "comment list",
|
|
11004
11401
|
about: "Every comment on a review, with its answers and whether it is settled",
|
|
@@ -11263,6 +11660,21 @@ var init_report$1 = __esmMin((() => {
|
|
|
11263
11660
|
suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment list` reports every id on a review.",
|
|
11264
11661
|
retriable: false
|
|
11265
11662
|
},
|
|
11663
|
+
UnknownDraft: {
|
|
11664
|
+
exit: 3,
|
|
11665
|
+
suggestion: "No held comment carries that id. `adiff draft list` reports the drafts waiting on a review.",
|
|
11666
|
+
retriable: false
|
|
11667
|
+
},
|
|
11668
|
+
NothingDrafted: {
|
|
11669
|
+
exit: 3,
|
|
11670
|
+
suggestion: "Nothing is being held for this review. Write a comment on the pull request first; `adiff draft list` reports what is waiting.",
|
|
11671
|
+
retriable: false
|
|
11672
|
+
},
|
|
11673
|
+
PullMoved: {
|
|
11674
|
+
exit: 1,
|
|
11675
|
+
suggestion: "The pull request has moved since these comments were written, so they name lines that may no longer be there. Nothing was sent and nothing was lost. Read the diff again and check each draft still says what you mean.",
|
|
11676
|
+
retriable: false
|
|
11677
|
+
},
|
|
11266
11678
|
InitUnwritable: {
|
|
11267
11679
|
exit: 1,
|
|
11268
11680
|
suggestion: "adiff init writes AGENTS.md and CLAUDE.md in the repository you point --repo at. Check that path is a directory you can write to.",
|
|
@@ -11330,7 +11742,7 @@ var init_cli = __esmMin((() => {
|
|
|
11330
11742
|
init_parse();
|
|
11331
11743
|
init_catalog();
|
|
11332
11744
|
init_report$1();
|
|
11333
|
-
init_error
|
|
11745
|
+
init_error();
|
|
11334
11746
|
}));
|
|
11335
11747
|
//#endregion
|
|
11336
11748
|
//#region src/cli/help.ts
|
|
@@ -11384,7 +11796,7 @@ const usageOf = (command) => {
|
|
|
11384
11796
|
const parts = command.addresses === "review" ? [REVIEW, ...own] : own;
|
|
11385
11797
|
return [`adiff ${command.name}`, ...parts].join(" ");
|
|
11386
11798
|
};
|
|
11387
|
-
const FIELDS
|
|
11799
|
+
const FIELDS = {
|
|
11388
11800
|
name: "fields",
|
|
11389
11801
|
required: false,
|
|
11390
11802
|
value: "a,b",
|
|
@@ -11395,7 +11807,7 @@ const answers$1 = (command) => command.dataKey === "" ? ["Answers by handing the
|
|
|
11395
11807
|
const helpFor = (name) => {
|
|
11396
11808
|
const command = findCommand(name);
|
|
11397
11809
|
if (command === void 0) return void 0;
|
|
11398
|
-
const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS
|
|
11810
|
+
const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS];
|
|
11399
11811
|
return [
|
|
11400
11812
|
`adiff ${command.name}`,
|
|
11401
11813
|
"",
|
|
@@ -11434,109 +11846,6 @@ const helpUnder = (noun) => {
|
|
|
11434
11846
|
].join("\n");
|
|
11435
11847
|
};
|
|
11436
11848
|
//#endregion
|
|
11437
|
-
//#region src/service/forge/error.ts
|
|
11438
|
-
var ForgeUnavailable;
|
|
11439
|
-
var init_error = __esmMin((() => {
|
|
11440
|
-
init_dist();
|
|
11441
|
-
ForgeUnavailable = class extends TaggedError("ForgeUnavailable") {};
|
|
11442
|
-
}));
|
|
11443
|
-
//#endregion
|
|
11444
|
-
//#region src/service/forge/service.ts
|
|
11445
|
-
var Forge, LIMIT, TIMEOUT_MS, FIELDS, Row, decode, stateOf, ask, show, read, pulls, openPull, ForgeLive;
|
|
11446
|
-
var init_service = __esmMin((() => {
|
|
11447
|
-
init_dist();
|
|
11448
|
-
init_error();
|
|
11449
|
-
Forge = class extends Service()("adiff/Forge") {};
|
|
11450
|
-
LIMIT = "200";
|
|
11451
|
-
TIMEOUT_MS = 4e3;
|
|
11452
|
-
FIELDS = "headRefName,state,isDraft";
|
|
11453
|
-
Row = Struct({
|
|
11454
|
-
headRefName: String$1,
|
|
11455
|
-
state: String$1,
|
|
11456
|
-
isDraft: Boolean
|
|
11457
|
-
});
|
|
11458
|
-
decode = decodeUnknownEffect(ArraySchema(Row));
|
|
11459
|
-
stateOf = (row) => {
|
|
11460
|
-
if (row.isDraft && row.state === "OPEN") return "draft";
|
|
11461
|
-
if (row.state === "MERGED") return "merged";
|
|
11462
|
-
if (row.state === "CLOSED") return "closed";
|
|
11463
|
-
return "open";
|
|
11464
|
-
};
|
|
11465
|
-
ask = (repo) => callback$1((resume) => {
|
|
11466
|
-
execFile("gh", [
|
|
11467
|
-
"pr",
|
|
11468
|
-
"list",
|
|
11469
|
-
"--state",
|
|
11470
|
-
"all",
|
|
11471
|
-
"--limit",
|
|
11472
|
-
LIMIT,
|
|
11473
|
-
"--json",
|
|
11474
|
-
FIELDS
|
|
11475
|
-
], {
|
|
11476
|
-
cwd: repo,
|
|
11477
|
-
timeout: TIMEOUT_MS,
|
|
11478
|
-
encoding: "utf8"
|
|
11479
|
-
}, (error, stdout) => {
|
|
11480
|
-
if (error === null) return resume(succeed$1(stdout));
|
|
11481
|
-
resume(fail(new ForgeUnavailable({
|
|
11482
|
-
repo,
|
|
11483
|
-
reason: error.message
|
|
11484
|
-
})));
|
|
11485
|
-
});
|
|
11486
|
-
});
|
|
11487
|
-
show = (repo, branch) => callback$1((resume) => {
|
|
11488
|
-
execFile("gh", [
|
|
11489
|
-
"pr",
|
|
11490
|
-
"view",
|
|
11491
|
-
branch,
|
|
11492
|
-
"--web"
|
|
11493
|
-
], {
|
|
11494
|
-
cwd: repo,
|
|
11495
|
-
timeout: TIMEOUT_MS,
|
|
11496
|
-
encoding: "utf8"
|
|
11497
|
-
}, (error) => {
|
|
11498
|
-
if (error === null) return resume(void_);
|
|
11499
|
-
resume(fail(new ForgeUnavailable({
|
|
11500
|
-
repo,
|
|
11501
|
-
reason: error.message
|
|
11502
|
-
})));
|
|
11503
|
-
});
|
|
11504
|
-
});
|
|
11505
|
-
read = fn("Forge.read")(function* (repo, raw) {
|
|
11506
|
-
const parsed = yield* try_({
|
|
11507
|
-
try: () => JSON.parse(raw),
|
|
11508
|
-
catch: (cause) => new ForgeUnavailable({
|
|
11509
|
-
repo,
|
|
11510
|
-
reason: String(cause)
|
|
11511
|
-
})
|
|
11512
|
-
});
|
|
11513
|
-
return (yield* mapError(decode(parsed), (cause) => new ForgeUnavailable({
|
|
11514
|
-
repo,
|
|
11515
|
-
reason: String(cause)
|
|
11516
|
-
}))).map((row) => ({
|
|
11517
|
-
branch: row.headRefName,
|
|
11518
|
-
state: stateOf(row)
|
|
11519
|
-
}));
|
|
11520
|
-
});
|
|
11521
|
-
pulls = fn("Forge.pulls")(function* (repo) {
|
|
11522
|
-
const raw = yield* ask(repo);
|
|
11523
|
-
return yield* read(repo, raw);
|
|
11524
|
-
});
|
|
11525
|
-
openPull = fn("Forge.openPull")(function* (repo, branch) {
|
|
11526
|
-
yield* show(repo, branch);
|
|
11527
|
-
});
|
|
11528
|
-
ForgeLive = succeed$2(Forge)({
|
|
11529
|
-
pulls,
|
|
11530
|
-
openPull
|
|
11531
|
-
});
|
|
11532
|
-
}));
|
|
11533
|
-
//#endregion
|
|
11534
|
-
//#region src/service/forge/index.ts
|
|
11535
|
-
var init_forge = __esmMin((() => {
|
|
11536
|
-
init_service();
|
|
11537
|
-
init_error();
|
|
11538
|
-
}));
|
|
11539
|
-
//#endregion
|
|
11540
11849
|
//#region src/tui/gaps.ts
|
|
11541
11850
|
var sourceLength, markerText, lastNewLine, spansOf, linesFrom, push, markGap, openOf, countOf, openAbove, openBelow, makeRows, compose, cache, keyOf$1, shownOf, gapAtRow, gapNumbered, gapRowSet;
|
|
11542
11851
|
var init_gaps = __esmMin((() => {
|
|
@@ -12879,6 +13188,13 @@ var init_command = __esmMin((() => {
|
|
|
12879
13188
|
whenReviewed: true,
|
|
12880
13189
|
rank: 3
|
|
12881
13190
|
}),
|
|
13191
|
+
command({
|
|
13192
|
+
action: "layers.ask",
|
|
13193
|
+
title: "Ask the agent for a reading order",
|
|
13194
|
+
category: "Files",
|
|
13195
|
+
keys: ["L"],
|
|
13196
|
+
screens: ["review"]
|
|
13197
|
+
}),
|
|
12882
13198
|
command({
|
|
12883
13199
|
action: "rail.toggle",
|
|
12884
13200
|
panes: ["tree", "diff"],
|
|
@@ -13609,6 +13925,7 @@ var init_reduce = __esmMin((() => {
|
|
|
13609
13925
|
panelIndex: 0
|
|
13610
13926
|
}),
|
|
13611
13927
|
"rail.toggle": toggleRail,
|
|
13928
|
+
"layers.ask": (state) => state,
|
|
13612
13929
|
"file.vouch": (state) => state,
|
|
13613
13930
|
"file.vouch.next": (state) => state,
|
|
13614
13931
|
"tree.collapse": (state) => fold(state, true),
|
|
@@ -16196,7 +16513,7 @@ var init_upgrade = __esmMin((() => {
|
|
|
16196
16513
|
return due ? `adiff ${latest} is out · adiff upgrade` : "";
|
|
16197
16514
|
}).pipe(withSpan("Tui.upgradeHint"));
|
|
16198
16515
|
upgradeHint = worded.pipe(orElseSucceed(() => ""));
|
|
16199
|
-
})), LOOK_MS, LEAVING_SAID, 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, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
|
|
16516
|
+
})), LOOK_MS, LEAVING_SAID, 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, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
|
|
16200
16517
|
var init_app = __esmMin((() => {
|
|
16201
16518
|
init_dist();
|
|
16202
16519
|
init_report();
|
|
@@ -16216,6 +16533,12 @@ var init_app = __esmMin((() => {
|
|
|
16216
16533
|
init_upgrade();
|
|
16217
16534
|
LOOK_MS = 110;
|
|
16218
16535
|
LEAVING_SAID = "press ctrl+c again to leave";
|
|
16536
|
+
layersAsk = (state) => {
|
|
16537
|
+
if (state.layers.length === 0) return "Please write a reading order for this branch with `adiff layers set`, so the diff can be read in the order the change was made rather than by filename.";
|
|
16538
|
+
if (state.layersStale) return "The reading order on this branch describes an older commit. Please read the diff again and write a new one with `adiff layers set`.";
|
|
16539
|
+
return "Please revise the reading order on this branch with `adiff layers set`.";
|
|
16540
|
+
};
|
|
16541
|
+
askedFor = (state) => state.layers.length === 0 ? "asked for a reading order" : "asked for a new reading order";
|
|
16219
16542
|
alongFrom = (state) => {
|
|
16220
16543
|
const along = nextUnreviewed(state, state.patchIndex);
|
|
16221
16544
|
return along === void 0 ? withNotice(state, "every file reviewed") : atFile(state, along);
|
|
@@ -16690,6 +17013,7 @@ var init_app = __esmMin((() => {
|
|
|
16690
17013
|
"cursor.next": () => this.stepped(1),
|
|
16691
17014
|
"cursor.prev": () => this.stepped(-1),
|
|
16692
17015
|
"rail.toggle": () => this.commitSynced("rail.toggle"),
|
|
17016
|
+
"layers.ask": () => this.askForLayers(),
|
|
16693
17017
|
"file.vouch": () => this.vouch(false),
|
|
16694
17018
|
"file.vouch.next": () => this.vouch(true),
|
|
16695
17019
|
"thread.settle": () => this.settleHere(),
|
|
@@ -17367,6 +17691,26 @@ var init_app = __esmMin((() => {
|
|
|
17367
17691
|
}, sent), "sent to the agent"));
|
|
17368
17692
|
});
|
|
17369
17693
|
}
|
|
17694
|
+
askForLayers() {
|
|
17695
|
+
return gen({ self: this }, function* () {
|
|
17696
|
+
const patch = selectedPatch(this.state);
|
|
17697
|
+
const branch = selectedBranch(this.state);
|
|
17698
|
+
if (patch === void 0 || branch === void 0) return;
|
|
17699
|
+
yield* this.commenting(branch.branch, {
|
|
17700
|
+
repo: this.repo,
|
|
17701
|
+
branch: branch.branch,
|
|
17702
|
+
file: patch.path,
|
|
17703
|
+
side: "new",
|
|
17704
|
+
start: 1,
|
|
17705
|
+
end: 1,
|
|
17706
|
+
body: layersAsk(this.state),
|
|
17707
|
+
id: randomUUID(),
|
|
17708
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17709
|
+
});
|
|
17710
|
+
const sent = yield* this.loadSent(branch.branch);
|
|
17711
|
+
this.commit(withNotice(withSent(this.state, sent), askedFor(this.state)));
|
|
17712
|
+
});
|
|
17713
|
+
}
|
|
17370
17714
|
sendComment() {
|
|
17371
17715
|
return gen({ self: this }, function* () {
|
|
17372
17716
|
const patch = selectedPatch(this.state);
|
|
@@ -17577,6 +17921,37 @@ const commentSend = fn("Main.commentSend")(function* (options) {
|
|
|
17577
17921
|
});
|
|
17578
17922
|
yield* answer(options, { batch });
|
|
17579
17923
|
});
|
|
17924
|
+
const draftList = fn("Main.draftList")(function* (options) {
|
|
17925
|
+
const drafts = yield* listDrafts(yield* required(options, "repo"), yield* required(options, "branch"));
|
|
17926
|
+
yield* answer(options, { drafts });
|
|
17927
|
+
});
|
|
17928
|
+
const draftAdd = fn("Main.draftAdd")(function* (options) {
|
|
17929
|
+
const draft = yield* addDraft({
|
|
17930
|
+
repo: yield* required(options, "repo"),
|
|
17931
|
+
branch: yield* required(options, "branch"),
|
|
17932
|
+
file: yield* required(options, "file"),
|
|
17933
|
+
start: yield* numeric(options, "start"),
|
|
17934
|
+
end: yield* numeric(options, "end"),
|
|
17935
|
+
body: yield* required(options, "body"),
|
|
17936
|
+
side: options["side"] === "old" ? "old" : "new",
|
|
17937
|
+
id: options["id"] ?? randomUUID(),
|
|
17938
|
+
at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
17939
|
+
wroteBy: "agent"
|
|
17940
|
+
});
|
|
17941
|
+
yield* answer(options, { draft });
|
|
17942
|
+
});
|
|
17943
|
+
const draftEdit = fn("Main.draftEdit")(function* (options) {
|
|
17944
|
+
const draft = yield* editDraft(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), yield* required(options, "body"));
|
|
17945
|
+
yield* answer(options, { draft });
|
|
17946
|
+
});
|
|
17947
|
+
const draftDrop = fn("Main.draftDrop")(function* (options) {
|
|
17948
|
+
const dropped = yield* dropDraft(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
|
|
17949
|
+
yield* answer(options, { dropped });
|
|
17950
|
+
});
|
|
17951
|
+
const draftSend = fn("Main.draftSend")(function* (options) {
|
|
17952
|
+
const dispatched = yield* dispatchDrafts(yield* required(options, "repo"), yield* required(options, "branch"));
|
|
17953
|
+
yield* answer(options, { dispatched });
|
|
17954
|
+
});
|
|
17580
17955
|
const commentReply = fn("Main.commentReply")(function* (options) {
|
|
17581
17956
|
const batch = yield* submitReply({
|
|
17582
17957
|
repo: yield* required(options, "repo"),
|
|
@@ -17713,6 +18088,11 @@ const routes = {
|
|
|
17713
18088
|
"comment take": commentTake,
|
|
17714
18089
|
"comment answer": commentAnswer,
|
|
17715
18090
|
"comment list": commentList,
|
|
18091
|
+
"draft list": draftList,
|
|
18092
|
+
"draft add": draftAdd,
|
|
18093
|
+
"draft edit": draftEdit,
|
|
18094
|
+
"draft drop": draftDrop,
|
|
18095
|
+
"draft send": draftSend,
|
|
17716
18096
|
"comment resolve": commentResolve,
|
|
17717
18097
|
"comment remove": commentRemove,
|
|
17718
18098
|
"comment restore": commentRestore,
|