@eliya-oss/agent-diff 0.1.0-alpha.107 → 0.1.0-alpha.109
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 +30 -0
- package/dist/main.js +1386 -768
- 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) {
|
|
@@ -9067,35 +8833,496 @@ var init_service$1 = __esmMin((() => {
|
|
|
9067
8833
|
})
|
|
9068
8834
|
};
|
|
9069
8835
|
};
|
|
9070
|
-
makeStore = (root) => {
|
|
9071
|
-
const { submit, inbox } = inboxOps(root);
|
|
9072
|
-
const { state, saveState } = stateOps(root);
|
|
9073
|
-
const talk = answerOps(root);
|
|
9074
|
-
const cursors = cursorOps(state, inbox, talk.answers);
|
|
8836
|
+
makeStore = (root) => {
|
|
8837
|
+
const { submit, inbox } = inboxOps(root);
|
|
8838
|
+
const { state, saveState } = stateOps(root);
|
|
8839
|
+
const talk = answerOps(root);
|
|
8840
|
+
const cursors = cursorOps(state, inbox, talk.answers);
|
|
8841
|
+
return {
|
|
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
|
+
}
|
|
9075
9311
|
return {
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
submit,
|
|
9079
|
-
inbox,
|
|
9080
|
-
state,
|
|
9081
|
-
saveState,
|
|
9082
|
-
saveReport: reportOps(root),
|
|
9083
|
-
...settingsOps(root),
|
|
9084
|
-
...upgradeOps(root),
|
|
9085
|
-
...talk,
|
|
9086
|
-
...layersOps(root),
|
|
9087
|
-
...cursors
|
|
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, UnknownField, UnknownOption, BadOption, 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,15 @@ 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
|
+
UnknownField = class extends TaggedError("UnknownField") {};
|
|
9396
|
+
UnknownOption = class extends TaggedError("UnknownOption") {};
|
|
9397
|
+
BadOption = class extends TaggedError("BadOption") {};
|
|
9398
|
+
UnknownDraft = class extends TaggedError("UnknownDraft") {};
|
|
9399
|
+
NothingDrafted = class extends TaggedError("NothingDrafted") {};
|
|
9400
|
+
PullMoved = class extends TaggedError("PullMoved") {};
|
|
9168
9401
|
NoLayers = class extends TaggedError("NoLayers") {};
|
|
9169
9402
|
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;
|
|
9403
|
+
})), 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
9404
|
var init_commands = __esmMin((() => {
|
|
9172
9405
|
init_dist();
|
|
9173
9406
|
init_patch();
|
|
@@ -9175,12 +9408,12 @@ var init_commands = __esmMin((() => {
|
|
|
9175
9408
|
init_review();
|
|
9176
9409
|
init_store();
|
|
9177
9410
|
init_preferences();
|
|
9178
|
-
init_error
|
|
9411
|
+
init_error();
|
|
9179
9412
|
CONTEXT = 3;
|
|
9180
9413
|
WHOLE_FILE$1 = 1e5;
|
|
9181
9414
|
POLL = "500 millis";
|
|
9182
9415
|
AUTO = "auto";
|
|
9183
|
-
askedFor = (asked, held) => {
|
|
9416
|
+
askedFor$1 = (asked, held) => {
|
|
9184
9417
|
if (asked !== void 0 && asked !== AUTO) return {
|
|
9185
9418
|
ref: asked,
|
|
9186
9419
|
basis: "set"
|
|
@@ -9200,7 +9433,7 @@ var init_commands = __esmMin((() => {
|
|
|
9200
9433
|
basedOn = fn("Cli.basedOn")(function* (repo, worktree, asked) {
|
|
9201
9434
|
const git = yield* Git;
|
|
9202
9435
|
const held = (yield* (yield* Store).state(worktree.path)).base;
|
|
9203
|
-
const wanted = askedFor(asked, held);
|
|
9436
|
+
const wanted = askedFor$1(asked, held);
|
|
9204
9437
|
const fallback = yield* git.defaultBranch(repo);
|
|
9205
9438
|
const guessed = wanted.ref.length === 0;
|
|
9206
9439
|
const ref = guessed ? yield* git.stackParent(repo, worktree.branch) : wanted.ref;
|
|
@@ -9414,8 +9647,7 @@ var init_commands = __esmMin((() => {
|
|
|
9414
9647
|
listSent = fn("Cli.listSent")(function* (repo, branch, base) {
|
|
9415
9648
|
return yield* sentIn(yield* readingOf(repo, branch, base));
|
|
9416
9649
|
});
|
|
9417
|
-
|
|
9418
|
-
const store = yield* Store;
|
|
9650
|
+
anchorIn = fn("Cli.anchorIn")(function* (worktree, request) {
|
|
9419
9651
|
const only = yield* patchesOf(worktree, WHOLE_FILE$1, request.file);
|
|
9420
9652
|
const patches = only.length > 0 ? only : yield* patchesOf(worktree, WHOLE_FILE$1);
|
|
9421
9653
|
const patch = findPatch(patches, request.file);
|
|
@@ -9430,7 +9662,7 @@ var init_commands = __esmMin((() => {
|
|
|
9430
9662
|
const first = rows[0];
|
|
9431
9663
|
const last = rows.at(-1);
|
|
9432
9664
|
const anchor = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
|
|
9433
|
-
|
|
9665
|
+
return yield* match$3(anchor, {
|
|
9434
9666
|
onNone: () => new UnselectableRange({
|
|
9435
9667
|
file: request.file,
|
|
9436
9668
|
start: request.start,
|
|
@@ -9438,6 +9670,10 @@ var init_commands = __esmMin((() => {
|
|
|
9438
9670
|
}),
|
|
9439
9671
|
onSome: succeed$1
|
|
9440
9672
|
});
|
|
9673
|
+
});
|
|
9674
|
+
commentIn = fn("Cli.commentIn")(function* (worktree, request) {
|
|
9675
|
+
const store = yield* Store;
|
|
9676
|
+
const chosen = yield* anchorIn(worktree, request);
|
|
9441
9677
|
const batch = {
|
|
9442
9678
|
id: request.id,
|
|
9443
9679
|
at: request.at,
|
|
@@ -9674,11 +9910,104 @@ var init_commands = __esmMin((() => {
|
|
|
9674
9910
|
});
|
|
9675
9911
|
}));
|
|
9676
9912
|
//#endregion
|
|
9913
|
+
//#region src/cli/drafts.ts
|
|
9914
|
+
var reported, listDrafts, addDraft, editDraft, dropDraft, sameCommit, commentOf, dispatchDrafts;
|
|
9915
|
+
var init_drafts = __esmMin((() => {
|
|
9916
|
+
init_dist();
|
|
9917
|
+
init_forge();
|
|
9918
|
+
init_store();
|
|
9919
|
+
init_commands();
|
|
9920
|
+
init_error();
|
|
9921
|
+
reported = (draft) => ({
|
|
9922
|
+
id: draft.id,
|
|
9923
|
+
file: draft.anchor.path,
|
|
9924
|
+
side: draft.anchor.side,
|
|
9925
|
+
start: draft.anchor.start,
|
|
9926
|
+
end: draft.anchor.end,
|
|
9927
|
+
body: draft.body,
|
|
9928
|
+
at: draft.at,
|
|
9929
|
+
wroteBy: draft.wroteBy
|
|
9930
|
+
});
|
|
9931
|
+
listDrafts = fn("Cli.listDrafts")(function* (repo, branch) {
|
|
9932
|
+
const store = yield* Store;
|
|
9933
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9934
|
+
return (yield* store.drafts(worktree.path)).map(reported);
|
|
9935
|
+
});
|
|
9936
|
+
addDraft = fn("Cli.addDraft")(function* (request) {
|
|
9937
|
+
const store = yield* Store;
|
|
9938
|
+
const worktree = yield* findBranch(request.repo, request.branch);
|
|
9939
|
+
const anchor = yield* anchorIn(worktree, request);
|
|
9940
|
+
const held = yield* store.drafts(worktree.path);
|
|
9941
|
+
const one = {
|
|
9942
|
+
id: request.id,
|
|
9943
|
+
anchor,
|
|
9944
|
+
body: request.body,
|
|
9945
|
+
at: request.at,
|
|
9946
|
+
wroteBy: request.wroteBy
|
|
9947
|
+
};
|
|
9948
|
+
yield* store.saveDrafts(worktree.path, [...held, one]);
|
|
9949
|
+
return reported(one);
|
|
9950
|
+
});
|
|
9951
|
+
editDraft = fn("Cli.editDraft")(function* (repo, branch, id, body) {
|
|
9952
|
+
const store = yield* Store;
|
|
9953
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9954
|
+
const held = yield* store.drafts(worktree.path);
|
|
9955
|
+
const found = held.find((one) => one.id === id);
|
|
9956
|
+
if (found === void 0) return yield* new UnknownDraft({ id });
|
|
9957
|
+
const said = {
|
|
9958
|
+
...found,
|
|
9959
|
+
body
|
|
9960
|
+
};
|
|
9961
|
+
const next = held.map((one) => one.id === id ? said : one);
|
|
9962
|
+
yield* store.saveDrafts(worktree.path, next);
|
|
9963
|
+
return reported(said);
|
|
9964
|
+
});
|
|
9965
|
+
dropDraft = fn("Cli.dropDraft")(function* (repo, branch, id) {
|
|
9966
|
+
const store = yield* Store;
|
|
9967
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9968
|
+
const held = yield* store.drafts(worktree.path);
|
|
9969
|
+
if (!held.some((one) => one.id === id)) return yield* new UnknownDraft({ id });
|
|
9970
|
+
yield* store.saveDrafts(worktree.path, held.filter((one) => one.id !== id));
|
|
9971
|
+
return { dropped: id };
|
|
9972
|
+
});
|
|
9973
|
+
sameCommit = (one, two) => {
|
|
9974
|
+
const short = one.length <= two.length ? one : two;
|
|
9975
|
+
const long = one.length <= two.length ? two : one;
|
|
9976
|
+
return short.length > 0 && long.startsWith(short);
|
|
9977
|
+
};
|
|
9978
|
+
commentOf = (draft) => ({
|
|
9979
|
+
path: draft.anchor.path,
|
|
9980
|
+
line: draft.anchor.end,
|
|
9981
|
+
side: draft.anchor.side,
|
|
9982
|
+
body: draft.body
|
|
9983
|
+
});
|
|
9984
|
+
dispatchDrafts = fn("Cli.dispatchDrafts")(function* (repo, branch) {
|
|
9985
|
+
const store = yield* Store;
|
|
9986
|
+
const forge = yield* Forge;
|
|
9987
|
+
const worktree = yield* findBranch(repo, branch);
|
|
9988
|
+
const held = yield* store.drafts(worktree.path);
|
|
9989
|
+
if (held.length === 0) return yield* new NothingDrafted({ branch });
|
|
9990
|
+
const head = yield* forge.head(repo, branch);
|
|
9991
|
+
if (!sameCommit(worktree.head, head)) return yield* new PullMoved({
|
|
9992
|
+
branch,
|
|
9993
|
+
was: worktree.head,
|
|
9994
|
+
now: head
|
|
9995
|
+
});
|
|
9996
|
+
const sent = yield* forge.review(repo, branch, held.map(commentOf));
|
|
9997
|
+
yield* store.saveDrafts(worktree.path, []);
|
|
9998
|
+
return {
|
|
9999
|
+
sent: sent.landed.length,
|
|
10000
|
+
url: sent.url,
|
|
10001
|
+
held: 0
|
|
10002
|
+
};
|
|
10003
|
+
});
|
|
10004
|
+
}));
|
|
10005
|
+
//#endregion
|
|
9677
10006
|
//#region src/cli/init.ts
|
|
9678
10007
|
var BEGIN, END, REACH, INSTRUCTIONS, IMPORT, blockIn, replaced, appended, planFor, readAt, writeAt, settle, skillSource, shippedSkill, settleSkill, SKILL_AT, refreshAt, settledRoot, refreshSkill, initRepository;
|
|
9679
10008
|
var init_init = __esmMin((() => {
|
|
9680
10009
|
init_dist();
|
|
9681
|
-
init_error
|
|
10010
|
+
init_error();
|
|
9682
10011
|
BEGIN = "<!-- adiff:begin -->";
|
|
9683
10012
|
END = "<!-- adiff:end -->";
|
|
9684
10013
|
REACH = 5;
|
|
@@ -9824,10 +10153,10 @@ var init_init = __esmMin((() => {
|
|
|
9824
10153
|
}));
|
|
9825
10154
|
//#endregion
|
|
9826
10155
|
//#region src/cli/pane.ts
|
|
9827
|
-
var TIMEOUT_MS
|
|
10156
|
+
var TIMEOUT_MS, set, splitters, onBranch, selfInvocation, ran, split, openPane;
|
|
9828
10157
|
var init_pane = __esmMin((() => {
|
|
9829
10158
|
init_dist();
|
|
9830
|
-
TIMEOUT_MS
|
|
10159
|
+
TIMEOUT_MS = 5e3;
|
|
9831
10160
|
set = (name) => (process.env[name] ?? "").length > 0;
|
|
9832
10161
|
splitters = [
|
|
9833
10162
|
{
|
|
@@ -9902,7 +10231,7 @@ var init_pane = __esmMin((() => {
|
|
|
9902
10231
|
];
|
|
9903
10232
|
};
|
|
9904
10233
|
ran = (binary, args) => callback$1((resume) => {
|
|
9905
|
-
execFile(binary, [...args], { timeout: TIMEOUT_MS
|
|
10234
|
+
execFile(binary, [...args], { timeout: TIMEOUT_MS }, (cause) => resume(succeed$1(cause === null)));
|
|
9906
10235
|
});
|
|
9907
10236
|
split = fn("Cli.split")(function* (chosen, repo, branch) {
|
|
9908
10237
|
return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo, branch)));
|
|
@@ -9924,10 +10253,10 @@ var init_pane = __esmMin((() => {
|
|
|
9924
10253
|
}));
|
|
9925
10254
|
//#endregion
|
|
9926
10255
|
//#region package.json
|
|
9927
|
-
|
|
10256
|
+
init_drafts();
|
|
9928
10257
|
init_init();
|
|
9929
10258
|
init_pane();
|
|
9930
|
-
var version$1 = "0.1.0-alpha.
|
|
10259
|
+
var version$1 = "0.1.0-alpha.109";
|
|
9931
10260
|
//#endregion
|
|
9932
10261
|
//#region src/cli/upgrade.ts
|
|
9933
10262
|
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 +10456,7 @@ var HIT, NEAR$1, rowOf, readRows, near, byChangedFirst, searchIn, searchBranch;
|
|
|
10127
10456
|
var init_search = __esmMin((() => {
|
|
10128
10457
|
init_dist();
|
|
10129
10458
|
init_git();
|
|
10459
|
+
init_commands();
|
|
10130
10460
|
HIT = /^(.+?):(\d+):(.*)$/;
|
|
10131
10461
|
NEAR$1 = /^(.+?)-(\d+)-(.*)$/;
|
|
10132
10462
|
rowOf = (line) => {
|
|
@@ -10325,7 +10655,7 @@ var init_layers = __esmMin((() => {
|
|
|
10325
10655
|
init_git();
|
|
10326
10656
|
init_store();
|
|
10327
10657
|
init_commands();
|
|
10328
|
-
init_error
|
|
10658
|
+
init_error();
|
|
10329
10659
|
STALE_ADVICE = "These layers describe an older commit. Read the diff again and write a new revision with layers set.";
|
|
10330
10660
|
unique = (paths) => [...new Set(paths)];
|
|
10331
10661
|
spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
|
|
@@ -10532,14 +10862,14 @@ var init_layers = __esmMin((() => {
|
|
|
10532
10862
|
}));
|
|
10533
10863
|
//#endregion
|
|
10534
10864
|
//#region src/cli/threads.ts
|
|
10535
|
-
var stateOf
|
|
10865
|
+
var stateOf, spoken$1, turnsOf, threadOf, threadsIn, idsIn, isKnown, listThreads, answerComment, settleIn, settleThread, removeIn, removeComment, without, restoreComment, settleRead;
|
|
10536
10866
|
var init_threads = __esmMin((() => {
|
|
10537
10867
|
init_dist();
|
|
10538
10868
|
init_store();
|
|
10539
10869
|
init_commands();
|
|
10540
10870
|
init_layers();
|
|
10541
|
-
init_error
|
|
10542
|
-
stateOf
|
|
10871
|
+
init_error();
|
|
10872
|
+
stateOf = (turns, asked, isSettled, isRemoved) => {
|
|
10543
10873
|
if (isRemoved) return "removed";
|
|
10544
10874
|
if (isSettled) return "done";
|
|
10545
10875
|
const last = turns.at(-1);
|
|
@@ -10574,7 +10904,7 @@ var init_threads = __esmMin((() => {
|
|
|
10574
10904
|
start: comment.anchor.start,
|
|
10575
10905
|
end: comment.anchor.end,
|
|
10576
10906
|
body: comment.body,
|
|
10577
|
-
state: stateOf
|
|
10907
|
+
state: stateOf(turns, mine.at(-1)?.asks === true, settled, Object.hasOwn(reading.removed, comment.id)),
|
|
10578
10908
|
stale: batch.head !== reading.head,
|
|
10579
10909
|
outside: !reading.shown.has(comment.anchor.path),
|
|
10580
10910
|
unread: Math.max(0, mine.length - seen),
|
|
@@ -10700,19 +11030,68 @@ var init_threads = __esmMin((() => {
|
|
|
10700
11030
|
}));
|
|
10701
11031
|
//#endregion
|
|
10702
11032
|
//#region src/cli/parse.ts
|
|
10703
|
-
var optionsFrom, required, numeric;
|
|
11033
|
+
var FLAG, flagOn, tokenOn, optionsFrom, onlyKnown, oneOf, required, numeric;
|
|
10704
11034
|
var init_parse = __esmMin((() => {
|
|
10705
11035
|
init_dist();
|
|
10706
|
-
init_error
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
11036
|
+
init_error();
|
|
11037
|
+
FLAG = /^--(?<name>[^=]+)(?:=(?<value>[\s\S]*))?$/;
|
|
11038
|
+
flagOn = (taken, token, valued) => {
|
|
11039
|
+
const found = FLAG.exec(token)?.groups;
|
|
11040
|
+
if (found === void 0) return taken;
|
|
11041
|
+
const name = found["name"] ?? "";
|
|
11042
|
+
const given = found["value"];
|
|
11043
|
+
if (given !== void 0) return {
|
|
11044
|
+
options: {
|
|
11045
|
+
...taken.options,
|
|
11046
|
+
[name]: given
|
|
11047
|
+
},
|
|
11048
|
+
held: void 0
|
|
11049
|
+
};
|
|
11050
|
+
if (valued.has(name)) return {
|
|
11051
|
+
options: taken.options,
|
|
11052
|
+
held: name
|
|
11053
|
+
};
|
|
11054
|
+
return {
|
|
11055
|
+
options: {
|
|
11056
|
+
...taken.options,
|
|
11057
|
+
[name]: "true"
|
|
11058
|
+
},
|
|
11059
|
+
held: void 0
|
|
11060
|
+
};
|
|
11061
|
+
};
|
|
11062
|
+
tokenOn = (taken, token, valued) => taken.held === void 0 ? flagOn(taken, token, valued) : {
|
|
11063
|
+
options: {
|
|
11064
|
+
...taken.options,
|
|
11065
|
+
[taken.held]: token
|
|
11066
|
+
},
|
|
11067
|
+
held: void 0
|
|
11068
|
+
};
|
|
11069
|
+
optionsFrom = (argv, valued = /* @__PURE__ */ new Set()) => {
|
|
11070
|
+
const taken = argv.reduce((held, token) => tokenOn(held, token, valued), {
|
|
11071
|
+
options: {},
|
|
11072
|
+
held: void 0
|
|
11073
|
+
});
|
|
11074
|
+
return taken.held === void 0 ? taken.options : {
|
|
11075
|
+
...taken.options,
|
|
11076
|
+
[taken.held]: ""
|
|
11077
|
+
};
|
|
11078
|
+
};
|
|
11079
|
+
onlyKnown = (options, known) => {
|
|
11080
|
+
const strange = Object.keys(options).find((name) => !known.has(name));
|
|
11081
|
+
return strange === void 0 ? succeed$1(options) : fail(new UnknownOption({
|
|
11082
|
+
option: strange,
|
|
11083
|
+
known: [...known].toSorted()
|
|
11084
|
+
}));
|
|
11085
|
+
};
|
|
11086
|
+
oneOf = (options, name, allowed, byDefault) => {
|
|
11087
|
+
const given = options[name];
|
|
11088
|
+
if (given === void 0) return succeed$1(byDefault);
|
|
11089
|
+
const found = allowed.find((one) => one === given);
|
|
11090
|
+
return found === void 0 ? fail(new BadOption({
|
|
11091
|
+
option: name,
|
|
11092
|
+
given,
|
|
11093
|
+
allowed
|
|
11094
|
+
})) : succeed$1(found);
|
|
10716
11095
|
};
|
|
10717
11096
|
required = fn("Cli.required")(function* (options, name) {
|
|
10718
11097
|
const value = fromNullishOr(options[name]);
|
|
@@ -10724,12 +11103,16 @@ var init_parse = __esmMin((() => {
|
|
|
10724
11103
|
numeric = fn("Cli.numeric")(function* (options, name) {
|
|
10725
11104
|
const raw = yield* required(options, name);
|
|
10726
11105
|
const parsed = Number(raw);
|
|
10727
|
-
return yield* Number.
|
|
11106
|
+
return yield* Number.isInteger(parsed) && parsed >= 1 ? succeed$1(parsed) : new BadOption({
|
|
11107
|
+
option: name,
|
|
11108
|
+
given: raw,
|
|
11109
|
+
allowed: ["a whole number of 1 or more"]
|
|
11110
|
+
});
|
|
10728
11111
|
});
|
|
10729
11112
|
}));
|
|
10730
11113
|
//#endregion
|
|
10731
11114
|
//#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;
|
|
11115
|
+
var worktreeOf, repoOf, branchOf, fieldsOption, addressing, baseOf, based, repo, opening$2, file, range, READ_A_BRANCH, WRITE_COMMENTS, ANSWER_COMMENTS, FOLLOW_UP, DRAFTS, SET_UP, withFields, commands$1, catalog, commandNames, findCommand, VALUED_ANYWHERE, KNOWN_ANYWHERE, valuedIn, knownIn, verbsUnder, groups, NEAR, distance, NEAR_ENOUGH, nearestCommand;
|
|
10733
11116
|
var init_catalog = __esmMin((() => {
|
|
10734
11117
|
worktreeOf = {
|
|
10735
11118
|
name: "worktree",
|
|
@@ -10749,6 +11132,12 @@ var init_catalog = __esmMin((() => {
|
|
|
10749
11132
|
value: "name",
|
|
10750
11133
|
about: "Branch to act on, as `branch list` reports it. Give this with --repo, or give --worktree"
|
|
10751
11134
|
};
|
|
11135
|
+
fieldsOption = {
|
|
11136
|
+
name: "fields",
|
|
11137
|
+
required: false,
|
|
11138
|
+
value: "names",
|
|
11139
|
+
about: "Keep only these fields of the answer, comma separated. An unknown name is refused"
|
|
11140
|
+
};
|
|
10752
11141
|
addressing = [
|
|
10753
11142
|
worktreeOf,
|
|
10754
11143
|
repoOf,
|
|
@@ -10810,8 +11199,13 @@ var init_catalog = __esmMin((() => {
|
|
|
10810
11199
|
WRITE_COMMENTS = "Write comments";
|
|
10811
11200
|
ANSWER_COMMENTS = "Answer comments, in the worktree";
|
|
10812
11201
|
FOLLOW_UP = "Follow up";
|
|
11202
|
+
DRAFTS = "Draft a review of somebody else's pull request";
|
|
10813
11203
|
SET_UP = "Set up";
|
|
10814
|
-
|
|
11204
|
+
withFields = (command) => command.dataKey.length === 0 ? command : {
|
|
11205
|
+
...command,
|
|
11206
|
+
options: [...command.options, fieldsOption]
|
|
11207
|
+
};
|
|
11208
|
+
commands$1 = [
|
|
10815
11209
|
{
|
|
10816
11210
|
name: "branch list",
|
|
10817
11211
|
about: "Branches with changes against their merge base, and how large each is",
|
|
@@ -10945,9 +11339,84 @@ var init_catalog = __esmMin((() => {
|
|
|
10945
11339
|
example: "adiff comment take --worktree . --wait 300"
|
|
10946
11340
|
},
|
|
10947
11341
|
{
|
|
10948
|
-
name: "comment answer",
|
|
10949
|
-
about: "Say what was done about a comment, or ask the reviewer something back",
|
|
10950
|
-
group: ANSWER_COMMENTS,
|
|
11342
|
+
name: "comment answer",
|
|
11343
|
+
about: "Say what was done about a comment, or ask the reviewer something back",
|
|
11344
|
+
group: ANSWER_COMMENTS,
|
|
11345
|
+
addresses: "review",
|
|
11346
|
+
safety: "write",
|
|
11347
|
+
options: [
|
|
11348
|
+
...addressing,
|
|
11349
|
+
{
|
|
11350
|
+
name: "id",
|
|
11351
|
+
required: true,
|
|
11352
|
+
value: "id",
|
|
11353
|
+
about: "The comment being answered, as `comment take` reported it"
|
|
11354
|
+
},
|
|
11355
|
+
{
|
|
11356
|
+
name: "body",
|
|
11357
|
+
required: true,
|
|
11358
|
+
value: "text",
|
|
11359
|
+
about: "What was done, or what is being asked"
|
|
11360
|
+
},
|
|
11361
|
+
{
|
|
11362
|
+
name: "question",
|
|
11363
|
+
required: false,
|
|
11364
|
+
value: "flag",
|
|
11365
|
+
about: "The answer is a question, and the work waits for a reply"
|
|
11366
|
+
}
|
|
11367
|
+
],
|
|
11368
|
+
dataKey: "answered",
|
|
11369
|
+
example: "adiff comment answer --worktree . --id c1 --body \"dropped it, and the import with it\""
|
|
11370
|
+
},
|
|
11371
|
+
{
|
|
11372
|
+
name: "layers set",
|
|
11373
|
+
about: "Write the reading order for this review's diff: ordered layers over spans of files",
|
|
11374
|
+
group: ANSWER_COMMENTS,
|
|
11375
|
+
addresses: "review",
|
|
11376
|
+
safety: "write",
|
|
11377
|
+
options: [...based, {
|
|
11378
|
+
name: "json",
|
|
11379
|
+
required: true,
|
|
11380
|
+
value: "file|-",
|
|
11381
|
+
about: "The document, as a file path or - to read stdin: {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"note\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}. A layer may carry blocks instead of spans, interleaving {\"kind\":\"prose\",\"markdown\":\"…\"} with {\"kind\":\"code\",\"path\":\"…\",\"start\":1,\"end\":9}"
|
|
11382
|
+
}],
|
|
11383
|
+
dataKey: "layers",
|
|
11384
|
+
example: "adiff layers set --worktree . --json -"
|
|
11385
|
+
},
|
|
11386
|
+
{
|
|
11387
|
+
name: "layers show",
|
|
11388
|
+
about: "The layers of a review, with the hunks no layer claims",
|
|
11389
|
+
group: ANSWER_COMMENTS,
|
|
11390
|
+
addresses: "review",
|
|
11391
|
+
safety: "read",
|
|
11392
|
+
options: [...based],
|
|
11393
|
+
dataKey: "layers",
|
|
11394
|
+
example: "adiff layers show --worktree . --fields layers,uncovered"
|
|
11395
|
+
},
|
|
11396
|
+
{
|
|
11397
|
+
name: "draft list",
|
|
11398
|
+
about: "The comments held for this pull request, in the order they were written",
|
|
11399
|
+
group: DRAFTS,
|
|
11400
|
+
addresses: "review",
|
|
11401
|
+
safety: "read",
|
|
11402
|
+
options: [...addressing],
|
|
11403
|
+
dataKey: "drafts",
|
|
11404
|
+
example: "adiff draft list --repo . --branch their-change"
|
|
11405
|
+
},
|
|
11406
|
+
{
|
|
11407
|
+
name: "draft add",
|
|
11408
|
+
about: "Hold one comment against a line range, to be sent with the rest",
|
|
11409
|
+
group: DRAFTS,
|
|
11410
|
+
addresses: "review",
|
|
11411
|
+
safety: "write",
|
|
11412
|
+
options: [...addressing, ...range],
|
|
11413
|
+
dataKey: "draft",
|
|
11414
|
+
example: "adiff draft add --repo . --branch their-change --file src/api.ts --start 4 --end 5 --body \"why\""
|
|
11415
|
+
},
|
|
11416
|
+
{
|
|
11417
|
+
name: "draft edit",
|
|
11418
|
+
about: "Rewrite a held comment before it is sent",
|
|
11419
|
+
group: DRAFTS,
|
|
10951
11420
|
addresses: "review",
|
|
10952
11421
|
safety: "write",
|
|
10953
11422
|
options: [
|
|
@@ -10956,48 +11425,42 @@ var init_catalog = __esmMin((() => {
|
|
|
10956
11425
|
name: "id",
|
|
10957
11426
|
required: true,
|
|
10958
11427
|
value: "id",
|
|
10959
|
-
about: "The
|
|
11428
|
+
about: "The draft, as `draft list` reports it"
|
|
10960
11429
|
},
|
|
10961
11430
|
{
|
|
10962
11431
|
name: "body",
|
|
10963
11432
|
required: true,
|
|
10964
11433
|
value: "text",
|
|
10965
|
-
about: "What
|
|
10966
|
-
},
|
|
10967
|
-
{
|
|
10968
|
-
name: "question",
|
|
10969
|
-
required: false,
|
|
10970
|
-
value: "flag",
|
|
10971
|
-
about: "The answer is a question, and the work waits for a reply"
|
|
11434
|
+
about: "What it should say instead"
|
|
10972
11435
|
}
|
|
10973
11436
|
],
|
|
10974
|
-
dataKey: "
|
|
10975
|
-
example: "adiff
|
|
11437
|
+
dataKey: "draft",
|
|
11438
|
+
example: "adiff draft edit --repo . --branch their-change --id d1 --body \"softer\""
|
|
10976
11439
|
},
|
|
10977
11440
|
{
|
|
10978
|
-
name: "
|
|
10979
|
-
about: "
|
|
10980
|
-
group:
|
|
11441
|
+
name: "draft drop",
|
|
11442
|
+
about: "Throw away a held comment rather than sending it",
|
|
11443
|
+
group: DRAFTS,
|
|
10981
11444
|
addresses: "review",
|
|
10982
11445
|
safety: "write",
|
|
10983
|
-
options: [...
|
|
10984
|
-
name: "
|
|
11446
|
+
options: [...addressing, {
|
|
11447
|
+
name: "id",
|
|
10985
11448
|
required: true,
|
|
10986
|
-
value: "
|
|
10987
|
-
about: "The
|
|
11449
|
+
value: "id",
|
|
11450
|
+
about: "The draft, as `draft list` reports it"
|
|
10988
11451
|
}],
|
|
10989
|
-
dataKey: "
|
|
10990
|
-
example: "adiff
|
|
11452
|
+
dataKey: "dropped",
|
|
11453
|
+
example: "adiff draft drop --repo . --branch their-change --id d1"
|
|
10991
11454
|
},
|
|
10992
11455
|
{
|
|
10993
|
-
name: "
|
|
10994
|
-
about: "
|
|
10995
|
-
group:
|
|
11456
|
+
name: "draft send",
|
|
11457
|
+
about: "Send every held comment to the pull request, as one review",
|
|
11458
|
+
group: DRAFTS,
|
|
10996
11459
|
addresses: "review",
|
|
10997
|
-
safety: "
|
|
10998
|
-
options: [...
|
|
10999
|
-
dataKey: "
|
|
11000
|
-
example: "adiff
|
|
11460
|
+
safety: "write",
|
|
11461
|
+
options: [...addressing],
|
|
11462
|
+
dataKey: "dispatched",
|
|
11463
|
+
example: "adiff draft send --repo . --branch their-change"
|
|
11001
11464
|
},
|
|
11002
11465
|
{
|
|
11003
11466
|
name: "comment list",
|
|
@@ -11174,8 +11637,23 @@ var init_catalog = __esmMin((() => {
|
|
|
11174
11637
|
example: "adiff describe --command 'comment send'"
|
|
11175
11638
|
}
|
|
11176
11639
|
];
|
|
11640
|
+
catalog = commands$1.map(withFields);
|
|
11177
11641
|
commandNames = catalog.map((command) => command.name);
|
|
11178
11642
|
findCommand = (name) => catalog.find((command) => command.name === name);
|
|
11643
|
+
VALUED_ANYWHERE = [
|
|
11644
|
+
"fields",
|
|
11645
|
+
"id",
|
|
11646
|
+
"at"
|
|
11647
|
+
];
|
|
11648
|
+
KNOWN_ANYWHERE = [
|
|
11649
|
+
...VALUED_ANYWHERE,
|
|
11650
|
+
"help",
|
|
11651
|
+
"json",
|
|
11652
|
+
"run",
|
|
11653
|
+
"quiet"
|
|
11654
|
+
];
|
|
11655
|
+
valuedIn = (name) => /* @__PURE__ */ new Set([...VALUED_ANYWHERE, ...(findCommand(name)?.options ?? []).filter((option) => option.value !== "flag").map((option) => option.name)]);
|
|
11656
|
+
knownIn = (name) => /* @__PURE__ */ new Set([...KNOWN_ANYWHERE, ...(findCommand(name)?.options ?? []).map((option) => option.name)]);
|
|
11179
11657
|
verbsUnder = (noun) => commandNames.filter((name) => name.startsWith(`${noun} `));
|
|
11180
11658
|
groups = [...new Set(catalog.map((command) => command.group))];
|
|
11181
11659
|
NEAR = 3;
|
|
@@ -11205,7 +11683,7 @@ var init_catalog = __esmMin((() => {
|
|
|
11205
11683
|
})).toSorted((left, right) => left.gap - right.gap)[0];
|
|
11206
11684
|
return scored !== void 0 && scored.gap <= room ? scored.known : void 0;
|
|
11207
11685
|
};
|
|
11208
|
-
})), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, sharpen, failure;
|
|
11686
|
+
})), ADVICE, FALLBACK, tagOf, project, fieldsOf, narrow, keysIn, strangeField, sharpen, failure;
|
|
11209
11687
|
var init_report$1 = __esmMin((() => {
|
|
11210
11688
|
ADVICE = {
|
|
11211
11689
|
UnknownCommand: {
|
|
@@ -11263,6 +11741,71 @@ var init_report$1 = __esmMin((() => {
|
|
|
11263
11741
|
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
11742
|
retriable: false
|
|
11265
11743
|
},
|
|
11744
|
+
UnknownField: {
|
|
11745
|
+
exit: 2,
|
|
11746
|
+
suggestion: "That is not a field this answer carries. The ones it does are named above.",
|
|
11747
|
+
retriable: false
|
|
11748
|
+
},
|
|
11749
|
+
UnknownOption: {
|
|
11750
|
+
exit: 2,
|
|
11751
|
+
suggestion: "That option is not one this command takes. `adiff <command> --help` lists the options it does.",
|
|
11752
|
+
retriable: false
|
|
11753
|
+
},
|
|
11754
|
+
BadOption: {
|
|
11755
|
+
exit: 2,
|
|
11756
|
+
suggestion: "That value is not one the option allows. The allowed ones are named above.",
|
|
11757
|
+
retriable: false
|
|
11758
|
+
},
|
|
11759
|
+
ForgeUnavailable: {
|
|
11760
|
+
exit: 1,
|
|
11761
|
+
suggestion: "The forge could not be reached. Check that `gh` is installed and authenticated, and that this repository has a remote on it. Nothing was sent.",
|
|
11762
|
+
retriable: false
|
|
11763
|
+
},
|
|
11764
|
+
NotARepository: {
|
|
11765
|
+
exit: 3,
|
|
11766
|
+
suggestion: "That path is not a git repository. Point --repo at one.",
|
|
11767
|
+
retriable: false
|
|
11768
|
+
},
|
|
11769
|
+
GitCommandFailed: {
|
|
11770
|
+
exit: 1,
|
|
11771
|
+
suggestion: "git refused the command adiff ran. The reason it gave is above.",
|
|
11772
|
+
retriable: false
|
|
11773
|
+
},
|
|
11774
|
+
FileUnreadable: {
|
|
11775
|
+
exit: 1,
|
|
11776
|
+
suggestion: "That file could not be read. Check it is still there and that you can read it.",
|
|
11777
|
+
retriable: false
|
|
11778
|
+
},
|
|
11779
|
+
StoreUnreadable: {
|
|
11780
|
+
exit: 1,
|
|
11781
|
+
suggestion: "A file adiff keeps this review in could not be read. The path is above; move it aside to start the review's history again, or repair the line that is malformed.",
|
|
11782
|
+
retriable: false
|
|
11783
|
+
},
|
|
11784
|
+
StoreUnwritable: {
|
|
11785
|
+
exit: 1,
|
|
11786
|
+
suggestion: "A file adiff keeps this review in could not be written. Check the path above is a directory you can write to.",
|
|
11787
|
+
retriable: false
|
|
11788
|
+
},
|
|
11789
|
+
WatchUnavailable: {
|
|
11790
|
+
exit: 1,
|
|
11791
|
+
suggestion: "adiff could not watch that path for changes. The reason it gave is above.",
|
|
11792
|
+
retriable: false
|
|
11793
|
+
},
|
|
11794
|
+
UnknownDraft: {
|
|
11795
|
+
exit: 3,
|
|
11796
|
+
suggestion: "No held comment carries that id. `adiff draft list` reports the drafts waiting on a review.",
|
|
11797
|
+
retriable: false
|
|
11798
|
+
},
|
|
11799
|
+
NothingDrafted: {
|
|
11800
|
+
exit: 3,
|
|
11801
|
+
suggestion: "Nothing is being held for this review. Write a comment on the pull request first; `adiff draft list` reports what is waiting.",
|
|
11802
|
+
retriable: false
|
|
11803
|
+
},
|
|
11804
|
+
PullMoved: {
|
|
11805
|
+
exit: 1,
|
|
11806
|
+
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.",
|
|
11807
|
+
retriable: false
|
|
11808
|
+
},
|
|
11266
11809
|
InitUnwritable: {
|
|
11267
11810
|
exit: 1,
|
|
11268
11811
|
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.",
|
|
@@ -11291,6 +11834,21 @@ var init_report$1 = __esmMin((() => {
|
|
|
11291
11834
|
return raw === void 0 || raw === "true" ? [] : raw.split(",").map((field) => field.trim());
|
|
11292
11835
|
};
|
|
11293
11836
|
narrow = (value, fields) => fields.length === 0 ? value : project(value, fields);
|
|
11837
|
+
keysIn = (value) => {
|
|
11838
|
+
if (Array.isArray(value)) return value.flatMap((one) => keysIn(one));
|
|
11839
|
+
if (typeof value !== "object" || value === null) return [];
|
|
11840
|
+
return Object.keys(value);
|
|
11841
|
+
};
|
|
11842
|
+
strangeField = (body, fields) => {
|
|
11843
|
+
if (fields.length === 0) return void 0;
|
|
11844
|
+
const known = [...new Set(Object.values(body).flatMap((value) => keysIn(value)))];
|
|
11845
|
+
if (known.length === 0) return void 0;
|
|
11846
|
+
const field = fields.find((one) => !known.includes(one));
|
|
11847
|
+
return field === void 0 ? void 0 : {
|
|
11848
|
+
field,
|
|
11849
|
+
known: known.toSorted()
|
|
11850
|
+
};
|
|
11851
|
+
};
|
|
11294
11852
|
sharpen = (tag, detail, fallback) => {
|
|
11295
11853
|
const meant = detail["didYouMean"];
|
|
11296
11854
|
const named = detail["name"];
|
|
@@ -11330,7 +11888,7 @@ var init_cli = __esmMin((() => {
|
|
|
11330
11888
|
init_parse();
|
|
11331
11889
|
init_catalog();
|
|
11332
11890
|
init_report$1();
|
|
11333
|
-
init_error
|
|
11891
|
+
init_error();
|
|
11334
11892
|
}));
|
|
11335
11893
|
//#endregion
|
|
11336
11894
|
//#region src/cli/help.ts
|
|
@@ -11384,7 +11942,7 @@ const usageOf = (command) => {
|
|
|
11384
11942
|
const parts = command.addresses === "review" ? [REVIEW, ...own] : own;
|
|
11385
11943
|
return [`adiff ${command.name}`, ...parts].join(" ");
|
|
11386
11944
|
};
|
|
11387
|
-
const FIELDS
|
|
11945
|
+
const FIELDS = {
|
|
11388
11946
|
name: "fields",
|
|
11389
11947
|
required: false,
|
|
11390
11948
|
value: "a,b",
|
|
@@ -11395,7 +11953,7 @@ const answers$1 = (command) => command.dataKey === "" ? ["Answers by handing the
|
|
|
11395
11953
|
const helpFor = (name) => {
|
|
11396
11954
|
const command = findCommand(name);
|
|
11397
11955
|
if (command === void 0) return void 0;
|
|
11398
|
-
const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS
|
|
11956
|
+
const shown = command.dataKey === "" ? command.options : [...command.options, FIELDS];
|
|
11399
11957
|
return [
|
|
11400
11958
|
`adiff ${command.name}`,
|
|
11401
11959
|
"",
|
|
@@ -11434,109 +11992,6 @@ const helpUnder = (noun) => {
|
|
|
11434
11992
|
].join("\n");
|
|
11435
11993
|
};
|
|
11436
11994
|
//#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
11995
|
//#region src/tui/gaps.ts
|
|
11541
11996
|
var sourceLength, markerText, lastNewLine, spansOf, linesFrom, push, markGap, openOf, countOf, openAbove, openBelow, makeRows, compose, cache, keyOf$1, shownOf, gapAtRow, gapNumbered, gapRowSet;
|
|
11542
11997
|
var init_gaps = __esmMin((() => {
|
|
@@ -11803,7 +12258,7 @@ var init_tree = __esmMin((() => {
|
|
|
11803
12258
|
return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
|
|
11804
12259
|
};
|
|
11805
12260
|
crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
|
|
11806
|
-
})), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip$1, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, layerBody, layerRows, nearFirst, layerFitted, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, replyTarget, pickedText, selectedLines, shownMatches, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, spokeLast, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
|
|
12261
|
+
})), nothingReviewed, initialState, TREE_MAX, TREE_ROOMY, TREE_WIDE, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, tooSmall, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, clip$1, TITLE_ROWS, titleRows, shortDir, fileRow$1, shownFiles, dirOf, fileRows, layerRead, layerDone, countRow, layerBody, layerRows, nearFirst, layerFitted, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, replyTarget, pickedText, selectedLines, shownMatches, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, spokeLast, sectionOf, sentEntry, panelEntries, panelEntry, threadChosen, spokenSince, hunkStarts, openingRow, changeAround, nextUnreviewed, reviewedCount, fileOrder, filePlace, readingOrder, placeIn, layerFile, layerAfter, selectionRange;
|
|
11807
12262
|
var init_model = __esmMin((() => {
|
|
11808
12263
|
init_dist();
|
|
11809
12264
|
init_patch();
|
|
@@ -11839,6 +12294,7 @@ var init_model = __esmMin((() => {
|
|
|
11839
12294
|
anchorRow: 0,
|
|
11840
12295
|
selecting: false,
|
|
11841
12296
|
draft: "",
|
|
12297
|
+
draftAt: "",
|
|
11842
12298
|
notice: "",
|
|
11843
12299
|
waiting: "",
|
|
11844
12300
|
query: "",
|
|
@@ -11885,6 +12341,7 @@ var init_model = __esmMin((() => {
|
|
|
11885
12341
|
const wanted = Math.min(spare >= TREE_WIDE ? TREE_WIDE : spare >= TREE_ROOMY ? TREE_ROOMY : TREE_MAX, Math.max(TREE_MIN, Math.floor(room * TREE_SHARE)));
|
|
11886
12342
|
return Math.max(0, Math.min(wanted, room - DIFF_MIN));
|
|
11887
12343
|
};
|
|
12344
|
+
tooSmall = (columns, rows) => columns < 24 || rows < 6;
|
|
11888
12345
|
reviewWidth = () => 36;
|
|
11889
12346
|
panelFits = (state) => bodyRoom(state.columns) - treeWidth(state.columns) - reviewWidth() >= DIFF_ROOMY;
|
|
11890
12347
|
panelShown = (state) => state.screen !== "branches" && state.panelOpen && panelFits(state);
|
|
@@ -12193,7 +12650,8 @@ var init_model = __esmMin((() => {
|
|
|
12193
12650
|
const patch = selectedPatch(state);
|
|
12194
12651
|
if (patch === void 0) return [];
|
|
12195
12652
|
const [from, to] = selectionRange(state);
|
|
12196
|
-
|
|
12653
|
+
const rows = patch.rows.slice(from, to + 1);
|
|
12654
|
+
return (rows.every((row) => row.kind === "removed") ? rows : rows.filter((row) => row.kind !== "removed")).map((row) => row.text);
|
|
12197
12655
|
};
|
|
12198
12656
|
shownMatches = (state) => {
|
|
12199
12657
|
const wanted = state.query.trim().toLowerCase();
|
|
@@ -12341,7 +12799,7 @@ var init_model = __esmMin((() => {
|
|
|
12341
12799
|
const start = Math.max(0, order.indexOf(from));
|
|
12342
12800
|
return [...order.slice(start + 1), ...order.slice(0, start + 1)].find((index) => !isReviewed(state, index));
|
|
12343
12801
|
};
|
|
12344
|
-
reviewedCount = (state) => `${state.vouched.length}
|
|
12802
|
+
reviewedCount = (state) => `${state.vouched.length} reviewed`;
|
|
12345
12803
|
fileOrder = (state) => onLayers(state) ? state.layers.flatMap((_, at) => layerFiles(state, at)) : flattenTree(treeOf(state), []).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
|
|
12346
12804
|
filePlace = (state) => {
|
|
12347
12805
|
const order = [...new Set(fileOrder(state))];
|
|
@@ -12879,6 +13337,13 @@ var init_command = __esmMin((() => {
|
|
|
12879
13337
|
whenReviewed: true,
|
|
12880
13338
|
rank: 3
|
|
12881
13339
|
}),
|
|
13340
|
+
command({
|
|
13341
|
+
action: "layers.ask",
|
|
13342
|
+
title: "Ask the agent for a reading order",
|
|
13343
|
+
category: "Files",
|
|
13344
|
+
keys: ["L"],
|
|
13345
|
+
screens: ["review"]
|
|
13346
|
+
}),
|
|
12882
13347
|
command({
|
|
12883
13348
|
action: "rail.toggle",
|
|
12884
13349
|
panes: ["tree", "diff"],
|
|
@@ -13118,7 +13583,7 @@ var init_match = __esmMin((() => {
|
|
|
13118
13583
|
}));
|
|
13119
13584
|
//#endregion
|
|
13120
13585
|
//#region src/tui/reduce.ts
|
|
13121
|
-
var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, landingOn, revealing, atTheEnd, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, revealsAfter, gapShown, gapOpened, panBy, withSent, withArrived, withColumns, laidOver, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, withDraft, paletteMoved, paletteClosed, withWaiting, withFinder, withMatches, withNoticeHere, withNotice;
|
|
13586
|
+
var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, restingOn, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, landingOn, revealing, atTheEnd, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, draftMark, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, resumedAt, atFile, withContext, withFull, revealsAfter, gapShown, gapOpened, panBy, withSent, withArrived, withColumns, laidOver, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, withDraft, paletteMoved, paletteClosed, withWaiting, withFinder, withMatches, withNoticeHere, withNotice;
|
|
13122
13587
|
var init_reduce = __esmMin((() => {
|
|
13123
13588
|
init_dist();
|
|
13124
13589
|
init_patch();
|
|
@@ -13451,14 +13916,21 @@ var init_reduce = __esmMin((() => {
|
|
|
13451
13916
|
selecting: true,
|
|
13452
13917
|
anchorRow: state.cursor
|
|
13453
13918
|
});
|
|
13919
|
+
draftMark = (state) => {
|
|
13920
|
+
const [from, to] = selectionRange(state);
|
|
13921
|
+
return `${selectedPatch(state)?.path ?? ""}:${from}-${to}`;
|
|
13922
|
+
};
|
|
13454
13923
|
openCompose = (state) => {
|
|
13455
13924
|
const patch = selectedPatch(state);
|
|
13456
13925
|
const [from, to] = selectionRange(state);
|
|
13457
13926
|
if (!(patch !== void 0 && isSome(anchorFor(patch, from, to)))) return withNoticeHere(state, "no line here to comment on");
|
|
13927
|
+
const mark = draftMark(state);
|
|
13928
|
+
const kept = state.draftAt === mark ? state.draft : "";
|
|
13458
13929
|
return {
|
|
13459
13930
|
...state,
|
|
13460
13931
|
screen: "compose",
|
|
13461
|
-
draft:
|
|
13932
|
+
draft: kept,
|
|
13933
|
+
draftAt: mark,
|
|
13462
13934
|
replyTo: void 0,
|
|
13463
13935
|
anchorRow: state.selecting ? state.anchorRow : state.cursor
|
|
13464
13936
|
};
|
|
@@ -13489,7 +13961,6 @@ var init_reduce = __esmMin((() => {
|
|
|
13489
13961
|
if (state.screen === "compose") return {
|
|
13490
13962
|
...state,
|
|
13491
13963
|
screen: "review",
|
|
13492
|
-
draft: "",
|
|
13493
13964
|
replyTo: void 0
|
|
13494
13965
|
};
|
|
13495
13966
|
if (state.selecting) return {
|
|
@@ -13609,6 +14080,7 @@ var init_reduce = __esmMin((() => {
|
|
|
13609
14080
|
panelIndex: 0
|
|
13610
14081
|
}),
|
|
13611
14082
|
"rail.toggle": toggleRail,
|
|
14083
|
+
"layers.ask": (state) => state,
|
|
13612
14084
|
"file.vouch": (state) => state,
|
|
13613
14085
|
"file.vouch.next": (state) => state,
|
|
13614
14086
|
"tree.collapse": (state) => fold(state, true),
|
|
@@ -13987,7 +14459,19 @@ var init_theme = __esmMin((() => {
|
|
|
13987
14459
|
addedBg: "#0f2a19",
|
|
13988
14460
|
removedBg: "#2e1418",
|
|
13989
14461
|
addedGutter: "#1d4a2b",
|
|
13990
|
-
removedGutter: "#4a1f26"
|
|
14462
|
+
removedGutter: "#4a1f26",
|
|
14463
|
+
pickedOn: "#2b3854",
|
|
14464
|
+
pickedOnAdded: "#22432f",
|
|
14465
|
+
pickedOnRemoved: "#4a2733",
|
|
14466
|
+
pickedGutter: "#38496b",
|
|
14467
|
+
pickedGutterAdded: "#2d5c3f",
|
|
14468
|
+
pickedGutterRemoved: "#63323f",
|
|
14469
|
+
cursorOn: "#243a4f",
|
|
14470
|
+
cursorOnAdded: "#1a3d26",
|
|
14471
|
+
cursorOnRemoved: "#40202a",
|
|
14472
|
+
cursorGutter: "#2f4a68",
|
|
14473
|
+
cursorGutterAdded: "#27573a",
|
|
14474
|
+
cursorGutterRemoved: "#5a2b36"
|
|
13991
14475
|
};
|
|
13992
14476
|
syntaxTheme = {
|
|
13993
14477
|
keyword: { fg: violet },
|
|
@@ -14015,15 +14499,9 @@ var init_theme = __esmMin((() => {
|
|
|
14015
14499
|
"punctuation.delimiter": { fg: inkFaint },
|
|
14016
14500
|
gap: { fg: inkFaint },
|
|
14017
14501
|
picked: { bg: "#2b3854" },
|
|
14018
|
-
note: {
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
},
|
|
14022
|
-
prose: { fg: "#a9b4cc" },
|
|
14023
|
-
"note.sent": {
|
|
14024
|
-
fg: "#6d7893",
|
|
14025
|
-
italic: true
|
|
14026
|
-
},
|
|
14502
|
+
note: { fg: "#c8d0dc" },
|
|
14503
|
+
prose: { fg: "#8b95a7" },
|
|
14504
|
+
"note.sent": { fg: "#c8d0dc" },
|
|
14027
14505
|
"note.label": { fg: "#7aa2f7" },
|
|
14028
14506
|
default: { fg: ink }
|
|
14029
14507
|
};
|
|
@@ -14133,7 +14611,7 @@ var init_diffview = __esmMin((() => {
|
|
|
14133
14611
|
this.numbers = new LineNumberRenderable(renderer, {
|
|
14134
14612
|
id: "diff-lines",
|
|
14135
14613
|
target: this.code,
|
|
14136
|
-
fg: palette.
|
|
14614
|
+
fg: palette.muted,
|
|
14137
14615
|
minWidth: 4,
|
|
14138
14616
|
paddingRight: 1,
|
|
14139
14617
|
flexGrow: 1,
|
|
@@ -14173,6 +14651,9 @@ var init_diffview = __esmMin((() => {
|
|
|
14173
14651
|
room() {
|
|
14174
14652
|
return this.noteRoom();
|
|
14175
14653
|
}
|
|
14654
|
+
paneWidth() {
|
|
14655
|
+
return this.numbers.width;
|
|
14656
|
+
}
|
|
14176
14657
|
gutterWidth() {
|
|
14177
14658
|
return Math.max(0, this.code.x - this.numbers.x) + SIGN_WIDTH;
|
|
14178
14659
|
}
|
|
@@ -14320,14 +14801,14 @@ var init_diffview = __esmMin((() => {
|
|
|
14320
14801
|
return [...(this.ownSpans() ?? highlights).filter((highlight) => !spans.some(([from, to]) => highlight[0] < to && highlight[1] > from)), ...spans];
|
|
14321
14802
|
};
|
|
14322
14803
|
}
|
|
14323
|
-
setWrap(on) {
|
|
14804
|
+
setWrap(on, pane) {
|
|
14324
14805
|
if (on !== this.wrapped) {
|
|
14325
14806
|
this.wrapped = on;
|
|
14326
14807
|
this.code.wrapMode = on ? "word" : "none";
|
|
14327
14808
|
this.code.requestRender();
|
|
14328
14809
|
this.numbers.requestRender();
|
|
14329
14810
|
}
|
|
14330
|
-
this.fitWrapWidth();
|
|
14811
|
+
this.fitWrapWidth(pane);
|
|
14331
14812
|
}
|
|
14332
14813
|
panLimit() {
|
|
14333
14814
|
return this.wrapped ? 0 : Math.max(this.code.maxScrollX, this.pinned.maxScrollX);
|
|
@@ -14341,8 +14822,8 @@ var init_diffview = __esmMin((() => {
|
|
|
14341
14822
|
if (this.code.scrollX !== wanted) this.code.scrollX = wanted;
|
|
14342
14823
|
if (this.pinned.scrollX !== wanted) this.pinned.scrollX = wanted;
|
|
14343
14824
|
}
|
|
14344
|
-
fitWrapWidth() {
|
|
14345
|
-
const room =
|
|
14825
|
+
fitWrapWidth(pane) {
|
|
14826
|
+
const room = pane - Math.max(0, this.code.x - this.numbers.x);
|
|
14346
14827
|
const wanted = this.wrapped && room > 0 ? room : "100%";
|
|
14347
14828
|
if (this.code.width !== wanted) this.code.width = wanted;
|
|
14348
14829
|
}
|
|
@@ -14679,7 +15160,7 @@ var init_diffview = __esmMin((() => {
|
|
|
14679
15160
|
}));
|
|
14680
15161
|
//#endregion
|
|
14681
15162
|
//#region src/tui/render.ts
|
|
14682
|
-
var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint,
|
|
15163
|
+
var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, DIFF_FLOOR, CRAMPED, CRAMPED_ROWS, DIFF_CHROME_MOST, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_FIXED, STATE_MIN, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, longestState, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, PLAIN_PICKED, PICKED, PLAIN_CURSOR, UNDER_CURSOR, GAP_PAINT, frameRoot, crampedBar, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, asking, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, INDENT_MAX, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, SUMMARY_LINES, summaryLines, contextLabel, nameRoom, stateRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, placeLabel, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, GUTTER, DIR_LEAD, TITLE_LEAD, FILE_LEAD, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerMark, layerLead, layerGutter, layerText, litRow, leftOver, titlePaint, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, restingOrHere, FOUND_LEAST, nothingYet, foundTitle, fileRow, blockOf, aroundRow, windowedBlocks, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
|
|
14683
15164
|
var init_render = __esmMin((() => {
|
|
14684
15165
|
init_command();
|
|
14685
15166
|
init_layers$1();
|
|
@@ -14716,6 +15197,10 @@ var init_render = __esmMin((() => {
|
|
|
14716
15197
|
PANE_CHROME = 3;
|
|
14717
15198
|
PANE_EDGES = 2;
|
|
14718
15199
|
PANE_INSET = 1;
|
|
15200
|
+
DIFF_FLOOR = 24;
|
|
15201
|
+
CRAMPED = "adiff needs more room than this";
|
|
15202
|
+
CRAMPED_ROWS = 4;
|
|
15203
|
+
DIFF_CHROME_MOST = 16;
|
|
14719
15204
|
BRANCH_WIDTH = 82;
|
|
14720
15205
|
BRANCH_NAME_MIN = 12;
|
|
14721
15206
|
BRANCH_FIXED = 36;
|
|
@@ -14745,24 +15230,56 @@ var init_render = __esmMin((() => {
|
|
|
14745
15230
|
});
|
|
14746
15231
|
STICKY_MAX = 4;
|
|
14747
15232
|
pickPaint = (view, kind, flags) => {
|
|
14748
|
-
if (flags.cursor) return
|
|
14749
|
-
|
|
14750
|
-
content: CURSOR
|
|
14751
|
-
};
|
|
14752
|
-
if (flags.selected) return {
|
|
14753
|
-
gutter: SELECTION,
|
|
14754
|
-
content: SELECTION
|
|
14755
|
-
};
|
|
15233
|
+
if (flags.cursor) return UNDER_CURSOR[kind] ?? PLAIN_CURSOR;
|
|
15234
|
+
if (flags.selected) return PICKED[kind] ?? PLAIN_PICKED;
|
|
14756
15235
|
if (flags.gap) return GAP_PAINT;
|
|
14757
15236
|
return view.washOf(kind);
|
|
14758
15237
|
};
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
15238
|
+
PLAIN_PICKED = {
|
|
15239
|
+
gutter: RGBA.fromHex(palette.pickedGutter),
|
|
15240
|
+
content: RGBA.fromHex(palette.pickedOn)
|
|
15241
|
+
};
|
|
15242
|
+
PICKED = {
|
|
15243
|
+
added: {
|
|
15244
|
+
gutter: RGBA.fromHex(palette.pickedGutterAdded),
|
|
15245
|
+
content: RGBA.fromHex(palette.pickedOnAdded)
|
|
15246
|
+
},
|
|
15247
|
+
removed: {
|
|
15248
|
+
gutter: RGBA.fromHex(palette.pickedGutterRemoved),
|
|
15249
|
+
content: RGBA.fromHex(palette.pickedOnRemoved)
|
|
15250
|
+
}
|
|
15251
|
+
};
|
|
15252
|
+
PLAIN_CURSOR = {
|
|
15253
|
+
gutter: RGBA.fromHex(palette.cursorGutter),
|
|
15254
|
+
content: RGBA.fromHex(palette.cursorOn)
|
|
15255
|
+
};
|
|
15256
|
+
UNDER_CURSOR = {
|
|
15257
|
+
added: {
|
|
15258
|
+
gutter: RGBA.fromHex(palette.cursorGutterAdded),
|
|
15259
|
+
content: RGBA.fromHex(palette.cursorOnAdded)
|
|
15260
|
+
},
|
|
15261
|
+
removed: {
|
|
15262
|
+
gutter: RGBA.fromHex(palette.cursorGutterRemoved),
|
|
15263
|
+
content: RGBA.fromHex(palette.cursorOnRemoved)
|
|
15264
|
+
}
|
|
15265
|
+
};
|
|
14762
15266
|
GAP_PAINT = {
|
|
14763
15267
|
gutter: RGBA.fromHex(palette.overlay),
|
|
14764
15268
|
content: RGBA.fromHex(palette.overlay)
|
|
14765
15269
|
};
|
|
15270
|
+
frameRoot = (renderer) => {
|
|
15271
|
+
renderer.root.flexDirection = "column";
|
|
15272
|
+
renderer.root.paddingLeft = FRAME_PAD;
|
|
15273
|
+
renderer.root.paddingRight = FRAME_PAD;
|
|
15274
|
+
renderer.root.paddingTop = 0;
|
|
15275
|
+
renderer.root.paddingBottom = 0;
|
|
15276
|
+
};
|
|
15277
|
+
crampedBar = (renderer) => {
|
|
15278
|
+
const made = bar(renderer, "cramped", palette.muted);
|
|
15279
|
+
made.wrapMode = "word";
|
|
15280
|
+
made.height = CRAMPED_ROWS;
|
|
15281
|
+
return made;
|
|
15282
|
+
};
|
|
14766
15283
|
bar = (renderer, id, color) => new TextRenderable(renderer, {
|
|
14767
15284
|
id,
|
|
14768
15285
|
content: "",
|
|
@@ -15244,7 +15761,7 @@ var init_render = __esmMin((() => {
|
|
|
15244
15761
|
});
|
|
15245
15762
|
placeLabel = (state) => {
|
|
15246
15763
|
const place = filePlace(state);
|
|
15247
|
-
return
|
|
15764
|
+
return `file ${place.at} of ${place.of}`;
|
|
15248
15765
|
};
|
|
15249
15766
|
headerParts = (state, branch, path, pan) => [
|
|
15250
15767
|
branch,
|
|
@@ -15464,6 +15981,7 @@ var init_render = __esmMin((() => {
|
|
|
15464
15981
|
landingKeys;
|
|
15465
15982
|
hovered = -1;
|
|
15466
15983
|
lead = 0;
|
|
15984
|
+
chrome = 0;
|
|
15467
15985
|
shown;
|
|
15468
15986
|
chips = [];
|
|
15469
15987
|
composeTitle;
|
|
@@ -15471,6 +15989,7 @@ var init_render = __esmMin((() => {
|
|
|
15471
15989
|
composeBody;
|
|
15472
15990
|
composeActions;
|
|
15473
15991
|
footer;
|
|
15992
|
+
cramped;
|
|
15474
15993
|
palette;
|
|
15475
15994
|
paletteTitle;
|
|
15476
15995
|
paletteQuery;
|
|
@@ -15491,13 +16010,10 @@ var init_render = __esmMin((() => {
|
|
|
15491
16010
|
constructor(renderer, repo = "") {
|
|
15492
16011
|
this.renderer = renderer;
|
|
15493
16012
|
this.repo = repo;
|
|
15494
|
-
renderer
|
|
15495
|
-
renderer.root.paddingLeft = FRAME_PAD;
|
|
15496
|
-
renderer.root.paddingRight = FRAME_PAD;
|
|
15497
|
-
renderer.root.paddingTop = 0;
|
|
15498
|
-
renderer.root.paddingBottom = 0;
|
|
16013
|
+
frameRoot(renderer);
|
|
15499
16014
|
this.header = bar(renderer, "header", palette.ink);
|
|
15500
16015
|
this.footer = bar(renderer, "footer", palette.faint);
|
|
16016
|
+
this.cramped = crampedBar(renderer);
|
|
15501
16017
|
this.body = makeBody(renderer);
|
|
15502
16018
|
const list = makeListParts(renderer);
|
|
15503
16019
|
this.listPane = list.pane;
|
|
@@ -15649,15 +16165,24 @@ var init_render = __esmMin((() => {
|
|
|
15649
16165
|
this.landing.content = `${elide(shortPath(this.repo), room)} · ${many}`;
|
|
15650
16166
|
this.landingKeys.content = this.homeKeys(state);
|
|
15651
16167
|
this.diffPane.visible = state.screen !== "branches" && !atHome(state);
|
|
15652
|
-
if (this.diffPane.visible) this.paintDiff(state);
|
|
15653
16168
|
this.paintPanel(state);
|
|
15654
16169
|
this.paintPane(state);
|
|
16170
|
+
if (this.diffPane.visible) this.paintDiff(state);
|
|
15655
16171
|
this.paintCompose(state);
|
|
15656
16172
|
this.paintPalette(state);
|
|
15657
16173
|
this.paintKeys(state);
|
|
15658
16174
|
this.paintFound(state);
|
|
15659
16175
|
this.paintReport(state);
|
|
15660
16176
|
this.scrim.visible = state.screen !== "branches" && state.screen !== "review";
|
|
16177
|
+
this.paintCramped();
|
|
16178
|
+
}
|
|
16179
|
+
paintCramped() {
|
|
16180
|
+
const cramped = tooSmall(this.renderer.width, this.renderer.height);
|
|
16181
|
+
this.cramped.visible = cramped;
|
|
16182
|
+
this.body.visible = !cramped;
|
|
16183
|
+
this.header.visible = !cramped;
|
|
16184
|
+
this.footer.visible = !cramped;
|
|
16185
|
+
if (cramped) this.cramped.content = wrapped(CRAMPED, this.renderer.width - 1).join("\n");
|
|
15661
16186
|
}
|
|
15662
16187
|
paintPalette(state) {
|
|
15663
16188
|
this.palette.visible = state.screen === "palette";
|
|
@@ -15721,6 +16246,15 @@ var init_render = __esmMin((() => {
|
|
|
15721
16246
|
paneRoom() {
|
|
15722
16247
|
return treeWidth(this.renderer.width);
|
|
15723
16248
|
}
|
|
16249
|
+
railsRoom() {
|
|
16250
|
+
return (this.listPane.visible ? this.listPane.width : 0) + (this.panelPane.visible ? this.panelPane.width : 0);
|
|
16251
|
+
}
|
|
16252
|
+
diffRoom() {
|
|
16253
|
+
const measured = this.view.paneWidth();
|
|
16254
|
+
const settled = this.renderer.width - this.railsRoom() - measured;
|
|
16255
|
+
if (settled >= 0 && settled < DIFF_CHROME_MOST) this.chrome = settled;
|
|
16256
|
+
return Math.max(DIFF_FLOOR, this.renderer.width - this.railsRoom() - this.chrome);
|
|
16257
|
+
}
|
|
15724
16258
|
columns() {
|
|
15725
16259
|
return this.renderer.width;
|
|
15726
16260
|
}
|
|
@@ -15786,7 +16320,7 @@ var init_render = __esmMin((() => {
|
|
|
15786
16320
|
const shown = shownOf(state);
|
|
15787
16321
|
if (shown === void 0) return;
|
|
15788
16322
|
const patch = shown.patch;
|
|
15789
|
-
this.view.setWrap(state.wrap);
|
|
16323
|
+
this.view.setWrap(state.wrap, this.diffRoom());
|
|
15790
16324
|
this.view.setPan(state.pan);
|
|
15791
16325
|
this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
|
|
15792
16326
|
this.view.pick(state.picked);
|
|
@@ -15818,6 +16352,7 @@ var init_render = __esmMin((() => {
|
|
|
15818
16352
|
this.composeActions
|
|
15819
16353
|
]);
|
|
15820
16354
|
stack(renderer.root, [
|
|
16355
|
+
this.cramped,
|
|
15821
16356
|
this.header,
|
|
15822
16357
|
this.body,
|
|
15823
16358
|
this.footer,
|
|
@@ -16196,7 +16731,7 @@ var init_upgrade = __esmMin((() => {
|
|
|
16196
16731
|
return due ? `adiff ${latest} is out · adiff upgrade` : "";
|
|
16197
16732
|
}).pipe(withSpan("Tui.upgradeHint"));
|
|
16198
16733
|
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;
|
|
16734
|
+
})), LOOK_MS, LEAVING_SAID, NOTHING_WRITTEN, layersAsk, askedFor, alongFrom, NOTICE_MS, KEY_HISTORY, DRAIN_PASSES, TRAIL_HISTORY, clockOf, momentOf, noticeOf, COPIERS, wayland, seedFor, handOver, throughMultiplexer, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, OVER, overReview, writesInto, listens, LETTER, laidOut, ARROWS, SHIFTED, keyName, App, sentAway, turnedOver, settledPath, restsWhereItLanded, lonelyGaps, chosenIn, settingsHeld, firstBranches, missing, openingOn, launch, told, untilDestroyed, runOn, runTui;
|
|
16200
16735
|
var init_app = __esmMin((() => {
|
|
16201
16736
|
init_dist();
|
|
16202
16737
|
init_report();
|
|
@@ -16216,6 +16751,13 @@ var init_app = __esmMin((() => {
|
|
|
16216
16751
|
init_upgrade();
|
|
16217
16752
|
LOOK_MS = 110;
|
|
16218
16753
|
LEAVING_SAID = "press ctrl+c again to leave";
|
|
16754
|
+
NOTHING_WRITTEN = "nothing written yet";
|
|
16755
|
+
layersAsk = (state) => {
|
|
16756
|
+
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.";
|
|
16757
|
+
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`.";
|
|
16758
|
+
return "Please revise the reading order on this branch with `adiff layers set`.";
|
|
16759
|
+
};
|
|
16760
|
+
askedFor = (state) => state.layers.length === 0 ? "asked for a reading order" : "asked for a new reading order";
|
|
16219
16761
|
alongFrom = (state) => {
|
|
16220
16762
|
const along = nextUnreviewed(state, state.patchIndex);
|
|
16221
16763
|
return along === void 0 ? withNotice(state, "every file reviewed") : atFile(state, along);
|
|
@@ -16690,6 +17232,7 @@ var init_app = __esmMin((() => {
|
|
|
16690
17232
|
"cursor.next": () => this.stepped(1),
|
|
16691
17233
|
"cursor.prev": () => this.stepped(-1),
|
|
16692
17234
|
"rail.toggle": () => this.commitSynced("rail.toggle"),
|
|
17235
|
+
"layers.ask": () => this.askForLayers(),
|
|
16693
17236
|
"file.vouch": () => this.vouch(false),
|
|
16694
17237
|
"file.vouch.next": () => this.vouch(true),
|
|
16695
17238
|
"thread.settle": () => this.settleHere(),
|
|
@@ -16763,7 +17306,10 @@ var init_app = __esmMin((() => {
|
|
|
16763
17306
|
if (listens(next.screen) !== listens(this.state.screen) || next.screen !== this.state.screen) runSync(this.display.askOn(listens(next.screen) ? next.screen : void 0));
|
|
16764
17307
|
const was = writesInto(this.state.screen);
|
|
16765
17308
|
const now = writesInto(next.screen);
|
|
16766
|
-
if (was === now)
|
|
17309
|
+
if (was === now) {
|
|
17310
|
+
if (now && next.draftAt !== this.state.draftAt) runSync(this.display.write(next.draft));
|
|
17311
|
+
return;
|
|
17312
|
+
}
|
|
16767
17313
|
if (now) runSync(this.display.write(next.draft));
|
|
16768
17314
|
runSync(this.display.writeOn(now));
|
|
16769
17315
|
}
|
|
@@ -17351,7 +17897,11 @@ var init_app = __esmMin((() => {
|
|
|
17351
17897
|
sendReply(to) {
|
|
17352
17898
|
return gen({ self: this }, function* () {
|
|
17353
17899
|
const branch = selectedBranch(this.state);
|
|
17354
|
-
if (branch === void 0
|
|
17900
|
+
if (branch === void 0) return;
|
|
17901
|
+
if (this.state.draft.trim().length === 0) {
|
|
17902
|
+
this.commit(withNotice(this.state, NOTHING_WRITTEN));
|
|
17903
|
+
return;
|
|
17904
|
+
}
|
|
17355
17905
|
yield* submitReply({
|
|
17356
17906
|
repo: this.repo,
|
|
17357
17907
|
branch: branch.branch,
|
|
@@ -17361,10 +17911,27 @@ var init_app = __esmMin((() => {
|
|
|
17361
17911
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17362
17912
|
});
|
|
17363
17913
|
const sent = yield* this.loadSent(branch.branch);
|
|
17364
|
-
this.commit(withNotice(withSent(
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17914
|
+
this.commit(withNotice(sentAway(withSent(this.state, sent)), "sent to the agent"));
|
|
17915
|
+
});
|
|
17916
|
+
}
|
|
17917
|
+
askForLayers() {
|
|
17918
|
+
return gen({ self: this }, function* () {
|
|
17919
|
+
const patch = selectedPatch(this.state);
|
|
17920
|
+
const branch = selectedBranch(this.state);
|
|
17921
|
+
if (patch === void 0 || branch === void 0) return;
|
|
17922
|
+
yield* this.commenting(branch.branch, {
|
|
17923
|
+
repo: this.repo,
|
|
17924
|
+
branch: branch.branch,
|
|
17925
|
+
file: patch.path,
|
|
17926
|
+
side: "new",
|
|
17927
|
+
start: 1,
|
|
17928
|
+
end: 1,
|
|
17929
|
+
body: layersAsk(this.state),
|
|
17930
|
+
id: randomUUID(),
|
|
17931
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17932
|
+
});
|
|
17933
|
+
const sent = yield* this.loadSent(branch.branch);
|
|
17934
|
+
this.commit(withNotice(withSent(this.state, sent), askedFor(this.state)));
|
|
17368
17935
|
});
|
|
17369
17936
|
}
|
|
17370
17937
|
sendComment() {
|
|
@@ -17372,7 +17939,11 @@ var init_app = __esmMin((() => {
|
|
|
17372
17939
|
const patch = selectedPatch(this.state);
|
|
17373
17940
|
const branch = selectedBranch(this.state);
|
|
17374
17941
|
const [from, to] = selectionRange(this.state);
|
|
17375
|
-
if (patch === void 0 || branch === void 0
|
|
17942
|
+
if (patch === void 0 || branch === void 0) return;
|
|
17943
|
+
if (this.state.draft.trim().length === 0) {
|
|
17944
|
+
this.commit(withNotice(this.state, NOTHING_WRITTEN));
|
|
17945
|
+
return;
|
|
17946
|
+
}
|
|
17376
17947
|
const anchor = anchorFor(patch, from, to);
|
|
17377
17948
|
if (isNone(anchor)) {
|
|
17378
17949
|
this.commit(withNotice(this.state, "nothing selected"));
|
|
@@ -17390,10 +17961,17 @@ var init_app = __esmMin((() => {
|
|
|
17390
17961
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17391
17962
|
});
|
|
17392
17963
|
const sent = yield* this.loadSent(branch.branch);
|
|
17393
|
-
this.commit(withNotice(withSent(this.state, sent), "sent to the agent"));
|
|
17964
|
+
this.commit(withNotice(sentAway(withSent(this.state, sent)), "sent to the agent"));
|
|
17394
17965
|
});
|
|
17395
17966
|
}
|
|
17396
17967
|
};
|
|
17968
|
+
sentAway = (state) => ({
|
|
17969
|
+
...state,
|
|
17970
|
+
screen: "review",
|
|
17971
|
+
draft: "",
|
|
17972
|
+
draftAt: "",
|
|
17973
|
+
replyTo: void 0
|
|
17974
|
+
});
|
|
17397
17975
|
turnedOver = (state) => ({
|
|
17398
17976
|
...state,
|
|
17399
17977
|
picked: void 0,
|
|
@@ -17543,14 +18121,18 @@ init_git();
|
|
|
17543
18121
|
init_forge();
|
|
17544
18122
|
init_store();
|
|
17545
18123
|
const WAIT_UNIT = 1e3;
|
|
17546
|
-
const answer = (options, body) =>
|
|
18124
|
+
const answer = (options, body) => {
|
|
17547
18125
|
const fields = fieldsOf(options);
|
|
17548
|
-
const
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
18126
|
+
const strange = strangeField(body, fields);
|
|
18127
|
+
if (strange !== void 0) return fail(new UnknownField(strange));
|
|
18128
|
+
return sync(() => {
|
|
18129
|
+
const narrowed = Object.fromEntries(Object.entries(body).map(([key, value]) => [key, narrow(value, fields)]));
|
|
18130
|
+
process.stdout.write(`${JSON.stringify({
|
|
18131
|
+
ok: true,
|
|
18132
|
+
...narrowed
|
|
18133
|
+
})}\n`);
|
|
18134
|
+
});
|
|
18135
|
+
};
|
|
17554
18136
|
const branchList = fn("Main.branchList")(function* (options) {
|
|
17555
18137
|
const branches = yield* listBranches(yield* required(options, "repo"), options["base"]);
|
|
17556
18138
|
yield* answer(options, { branches });
|
|
@@ -17571,12 +18153,43 @@ const commentSend = fn("Main.commentSend")(function* (options) {
|
|
|
17571
18153
|
start: yield* numeric(options, "start"),
|
|
17572
18154
|
end: yield* numeric(options, "end"),
|
|
17573
18155
|
body: yield* required(options, "body"),
|
|
17574
|
-
side: options
|
|
18156
|
+
side: yield* oneOf(options, "side", ["old", "new"], "new"),
|
|
17575
18157
|
id: options["id"] ?? randomUUID(),
|
|
17576
18158
|
at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
17577
18159
|
});
|
|
17578
18160
|
yield* answer(options, { batch });
|
|
17579
18161
|
});
|
|
18162
|
+
const draftList = fn("Main.draftList")(function* (options) {
|
|
18163
|
+
const drafts = yield* listDrafts(yield* required(options, "repo"), yield* required(options, "branch"));
|
|
18164
|
+
yield* answer(options, { drafts });
|
|
18165
|
+
});
|
|
18166
|
+
const draftAdd = fn("Main.draftAdd")(function* (options) {
|
|
18167
|
+
const draft = yield* addDraft({
|
|
18168
|
+
repo: yield* required(options, "repo"),
|
|
18169
|
+
branch: yield* required(options, "branch"),
|
|
18170
|
+
file: yield* required(options, "file"),
|
|
18171
|
+
start: yield* numeric(options, "start"),
|
|
18172
|
+
end: yield* numeric(options, "end"),
|
|
18173
|
+
body: yield* required(options, "body"),
|
|
18174
|
+
side: yield* oneOf(options, "side", ["old", "new"], "new"),
|
|
18175
|
+
id: options["id"] ?? randomUUID(),
|
|
18176
|
+
at: options["at"] ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
18177
|
+
wroteBy: "agent"
|
|
18178
|
+
});
|
|
18179
|
+
yield* answer(options, { draft });
|
|
18180
|
+
});
|
|
18181
|
+
const draftEdit = fn("Main.draftEdit")(function* (options) {
|
|
18182
|
+
const draft = yield* editDraft(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"), yield* required(options, "body"));
|
|
18183
|
+
yield* answer(options, { draft });
|
|
18184
|
+
});
|
|
18185
|
+
const draftDrop = fn("Main.draftDrop")(function* (options) {
|
|
18186
|
+
const dropped = yield* dropDraft(yield* required(options, "repo"), yield* required(options, "branch"), yield* required(options, "id"));
|
|
18187
|
+
yield* answer(options, { dropped });
|
|
18188
|
+
});
|
|
18189
|
+
const draftSend = fn("Main.draftSend")(function* (options) {
|
|
18190
|
+
const dispatched = yield* dispatchDrafts(yield* required(options, "repo"), yield* required(options, "branch"));
|
|
18191
|
+
yield* answer(options, { dispatched });
|
|
18192
|
+
});
|
|
17580
18193
|
const commentReply = fn("Main.commentReply")(function* (options) {
|
|
17581
18194
|
const batch = yield* submitReply({
|
|
17582
18195
|
repo: yield* required(options, "repo"),
|
|
@@ -17713,6 +18326,11 @@ const routes = {
|
|
|
17713
18326
|
"comment take": commentTake,
|
|
17714
18327
|
"comment answer": commentAnswer,
|
|
17715
18328
|
"comment list": commentList,
|
|
18329
|
+
"draft list": draftList,
|
|
18330
|
+
"draft add": draftAdd,
|
|
18331
|
+
"draft edit": draftEdit,
|
|
18332
|
+
"draft drop": draftDrop,
|
|
18333
|
+
"draft send": draftSend,
|
|
17716
18334
|
"comment resolve": commentResolve,
|
|
17717
18335
|
"comment remove": commentRemove,
|
|
17718
18336
|
"comment restore": commentRestore,
|
|
@@ -17804,7 +18422,7 @@ const wanting = (name) => (error) => {
|
|
|
17804
18422
|
usage: usageOf(command)
|
|
17805
18423
|
}));
|
|
17806
18424
|
};
|
|
17807
|
-
const run = (name, options) => dispatch(name, options)
|
|
18425
|
+
const run = (name, options) => onlyKnown(options, knownIn(name)).pipe(flatMap(() => dispatch(name, options)), catchTag("MissingOption", wanting(name)));
|
|
17808
18426
|
const leading = (argv) => {
|
|
17809
18427
|
const stop = argv.findIndex((token) => token.startsWith("-"));
|
|
17810
18428
|
return stop === -1 ? argv : argv.slice(0, stop);
|
|
@@ -17849,6 +18467,6 @@ const reportFailure = (cause) => sync(() => {
|
|
|
17849
18467
|
process.stderr.write(`${reported.line}\n`);
|
|
17850
18468
|
process.exitCode = reported.exit;
|
|
17851
18469
|
});
|
|
17852
|
-
runFork(run(opening ? "review open" : nameOf(argv), opening ? { repo: "." } : optionsFrom(argv)).pipe(provide(layer), catchCause(reportFailure)));
|
|
18470
|
+
runFork(run(opening ? "review open" : nameOf(argv), opening ? { repo: "." } : optionsFrom(argv, valuedIn(nameOf(argv)))).pipe(provide(layer), catchCause(reportFailure)));
|
|
17853
18471
|
//#endregion
|
|
17854
18472
|
export {};
|