@disintegrator/raven-paseo 0.0.2 → 0.0.4
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/OVERVIEW.md +10 -3
- package/THIRD-PARTY-NOTICES.md +883 -1
- package/client/index.js +21553 -5882
- package/client/index.js.map +10 -22
- package/package.json +1 -1
- package/server/index.js +175 -8
- package/server/index.js.map +11 -11
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/core/src/engine.ts
|
|
2
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
2
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
|
|
3
3
|
import { existsSync as existsSync5 } from "node:fs";
|
|
4
4
|
import { mkdir as mkdir5, readFile as readFile8, writeFile as writeFile5 } from "node:fs/promises";
|
|
5
5
|
import { stat as stat4 } from "node:fs/promises";
|
|
@@ -1634,7 +1634,8 @@ var PreciseAnswer = z.object({
|
|
|
1634
1634
|
result: NavResult.optional(),
|
|
1635
1635
|
server: z.string().optional(),
|
|
1636
1636
|
note: z.string().optional(),
|
|
1637
|
-
own: z.string().optional()
|
|
1637
|
+
own: z.string().optional(),
|
|
1638
|
+
fault: z.boolean().optional()
|
|
1638
1639
|
});
|
|
1639
1640
|
var LspServer = z.object({
|
|
1640
1641
|
name: z.string(),
|
|
@@ -1771,6 +1772,27 @@ var Canvas = z2.object({
|
|
|
1771
1772
|
panes: z2.array(CanvasPane)
|
|
1772
1773
|
});
|
|
1773
1774
|
var emptyCanvas = () => ({ format: CANVAS_FORMAT, version: CANVAS_VERSION, mode: "outline", focus: "home", roots: [], panes: [] });
|
|
1775
|
+
var NoteStop = z2.object({
|
|
1776
|
+
id: z2.string(),
|
|
1777
|
+
path: z2.string(),
|
|
1778
|
+
line: z2.number().int().positive().optional(),
|
|
1779
|
+
endLine: z2.number().int().positive().optional(),
|
|
1780
|
+
body: z2.string(),
|
|
1781
|
+
author: z2.string().optional(),
|
|
1782
|
+
quote: z2.string().optional(),
|
|
1783
|
+
stale: z2.boolean().optional()
|
|
1784
|
+
});
|
|
1785
|
+
var Inquiry = z2.object({
|
|
1786
|
+
id: z2.string(),
|
|
1787
|
+
title: z2.string(),
|
|
1788
|
+
summary: z2.string().optional(),
|
|
1789
|
+
author: z2.string(),
|
|
1790
|
+
at: z2.string(),
|
|
1791
|
+
stops: z2.array(NoteStop)
|
|
1792
|
+
});
|
|
1793
|
+
var NOTES_FORMAT = "raven.notes";
|
|
1794
|
+
var NOTES_VERSION = 1;
|
|
1795
|
+
var Notes = z2.object({ format: z2.literal(NOTES_FORMAT), version: z2.literal(NOTES_VERSION), inquiries: z2.array(Inquiry) });
|
|
1774
1796
|
var SNAPSHOT_FORMAT = "raven.snapshot";
|
|
1775
1797
|
var SNAPSHOT_VERSION = 1;
|
|
1776
1798
|
var Snapshot = z2.object({
|
|
@@ -1828,6 +1850,32 @@ var methods = {
|
|
|
1828
1850
|
input: z3.object({ changeSetId: z3.string(), title: z3.string().optional(), pullRequest: z3.number().int().optional() }),
|
|
1829
1851
|
output: Snapshot
|
|
1830
1852
|
},
|
|
1853
|
+
"notes.get": { input: ChangeSetRef, output: z3.object({ inquiries: z3.array(Inquiry) }) },
|
|
1854
|
+
"notes.put": {
|
|
1855
|
+
input: z3.object({
|
|
1856
|
+
changeSetId: z3.string(),
|
|
1857
|
+
title: z3.string().min(1).max(200),
|
|
1858
|
+
summary: z3.string().max(4000).optional(),
|
|
1859
|
+
author: z3.string().max(80).optional(),
|
|
1860
|
+
stops: z3.array(z3.object({
|
|
1861
|
+
path: z3.string().min(1),
|
|
1862
|
+
line: z3.number().int().positive().optional(),
|
|
1863
|
+
endLine: z3.number().int().positive().optional(),
|
|
1864
|
+
body: z3.string().min(1).max(4000)
|
|
1865
|
+
})).min(1).max(40)
|
|
1866
|
+
}),
|
|
1867
|
+
output: Inquiry
|
|
1868
|
+
},
|
|
1869
|
+
"notes.add": {
|
|
1870
|
+
input: z3.object({
|
|
1871
|
+
changeSetId: z3.string(),
|
|
1872
|
+
inquiry: z3.string().optional(),
|
|
1873
|
+
title: z3.string().min(1).max(200).optional(),
|
|
1874
|
+
stop: z3.object({ path: z3.string().min(1), line: z3.number().int().positive().optional(), endLine: z3.number().int().positive().optional(), body: z3.string().min(1).max(4000) })
|
|
1875
|
+
}),
|
|
1876
|
+
output: Inquiry
|
|
1877
|
+
},
|
|
1878
|
+
"notes.remove": { input: z3.object({ changeSetId: z3.string(), id: z3.string(), stop: z3.string().optional() }), output: z3.object({}) },
|
|
1831
1879
|
"comment.upsert": {
|
|
1832
1880
|
input: z3.object({ changeSetId: z3.string(), id: z3.string().optional(), anchor: CommentAnchor, body: z3.string().min(1) }),
|
|
1833
1881
|
output: Comment
|
|
@@ -3108,7 +3156,7 @@ class Session {
|
|
|
3108
3156
|
this.child.on("error", (err) => this.end(`${basename(init.command.bin)} could not be started: ${err.message}`));
|
|
3109
3157
|
const gone = (code, signal) => {
|
|
3110
3158
|
const how = signal ? `was stopped by ${signal}` : `exited with code ${code}`;
|
|
3111
|
-
const said = this.stderr.
|
|
3159
|
+
const said = this.stderr.slice(-5).join(" ").slice(0, 500);
|
|
3112
3160
|
this.end(`${basename(init.command.bin)} ${how}${said ? `: ${said}` : ""}`);
|
|
3113
3161
|
};
|
|
3114
3162
|
this.child.on("exit", (code, signal) => {
|
|
@@ -3331,10 +3379,12 @@ class Session {
|
|
|
3331
3379
|
// packages/core/src/lsp/broker.ts
|
|
3332
3380
|
class Unavailable extends Error {
|
|
3333
3381
|
own;
|
|
3334
|
-
|
|
3382
|
+
fault;
|
|
3383
|
+
constructor(message, own, fault = false) {
|
|
3335
3384
|
super(message);
|
|
3336
3385
|
this.name = "Unavailable";
|
|
3337
3386
|
this.own = own;
|
|
3387
|
+
this.fault = fault;
|
|
3338
3388
|
}
|
|
3339
3389
|
}
|
|
3340
3390
|
var MISSING_RETRY_MS = 30000;
|
|
@@ -3418,7 +3468,7 @@ class Broker {
|
|
|
3418
3468
|
const refusal = this.refused.get(key);
|
|
3419
3469
|
if (refusal) {
|
|
3420
3470
|
if (refusal.until > Date.now())
|
|
3421
|
-
throw new Unavailable(refusal.reason, refusal.own);
|
|
3471
|
+
throw new Unavailable(refusal.reason, refusal.own, !refusal.own);
|
|
3422
3472
|
this.refused.delete(key);
|
|
3423
3473
|
}
|
|
3424
3474
|
let start = this.starting.get(key);
|
|
@@ -3430,7 +3480,7 @@ class Broker {
|
|
|
3430
3480
|
}
|
|
3431
3481
|
refuse(key, spec, folder, kind, reason, forMs, own) {
|
|
3432
3482
|
this.refused.set(key, { name: spec.name, folder, kind, reason, until: Date.now() + forMs, ...own ? { own } : {} });
|
|
3433
|
-
return new Unavailable(reason, own);
|
|
3483
|
+
return new Unavailable(reason, own, !own);
|
|
3434
3484
|
}
|
|
3435
3485
|
async reconsider(repoRoot, allowed) {
|
|
3436
3486
|
const inside = (folder) => folder === repoRoot || folder.startsWith(`${repoRoot}/`);
|
|
@@ -7538,6 +7588,16 @@ async function makeSnapshot(engine, changeSetId, about = {}) {
|
|
|
7538
7588
|
put("history.pullRequest", { number: commit.pr }, await engine.pullRequest(changeSetId, commit.pr).catch(() => ({ unavailable: "it could not be read when this review was shared" })));
|
|
7539
7589
|
}
|
|
7540
7590
|
};
|
|
7591
|
+
const inquiries = await engine.inquiries(changeSetId);
|
|
7592
|
+
put("notes.get", {}, { inquiries });
|
|
7593
|
+
const stop = async (path, line) => {
|
|
7594
|
+
const f = inChange.get(path);
|
|
7595
|
+
if (f && (f.newBlob || f.oldBlob))
|
|
7596
|
+
return file(path);
|
|
7597
|
+
const lines = placeLines(line);
|
|
7598
|
+
put("text.read", { path, ...lines }, await engine.read(changeSetId, path, lines.start, lines.end));
|
|
7599
|
+
};
|
|
7600
|
+
await Promise.all(inquiries.flatMap((q) => q.stops).map((s) => stop(s.path, s.line ?? 1).catch(() => {})));
|
|
7541
7601
|
await Promise.all(canvas.panes.map((p) => pane(p).catch(() => {})));
|
|
7542
7602
|
return {
|
|
7543
7603
|
format: SNAPSHOT_FORMAT,
|
|
@@ -7970,10 +8030,35 @@ class ReviewStore {
|
|
|
7970
8030
|
base;
|
|
7971
8031
|
writes = Promise.resolve();
|
|
7972
8032
|
canvasFile;
|
|
8033
|
+
notesFile;
|
|
7973
8034
|
constructor(commonDir, reviewId, root = stateRoot()) {
|
|
7974
8035
|
const name = join8(root, repoSlug(commonDir), reviewId.replace(/[^\w.-]/g, "_"));
|
|
7975
8036
|
this.file = `${name}.jsonl`;
|
|
7976
8037
|
this.canvasFile = `${name}.canvas.json`;
|
|
8038
|
+
this.notesFile = `${name}.notes.json`;
|
|
8039
|
+
}
|
|
8040
|
+
async inquiries() {
|
|
8041
|
+
if (!existsSync3(this.notesFile))
|
|
8042
|
+
return [];
|
|
8043
|
+
let record;
|
|
8044
|
+
try {
|
|
8045
|
+
record = JSON.parse(await readFile6(this.notesFile, "utf8"));
|
|
8046
|
+
} catch {
|
|
8047
|
+
return [];
|
|
8048
|
+
}
|
|
8049
|
+
if (versionOf(record, NOTES_FORMAT, NOTES_VERSION) === undefined)
|
|
8050
|
+
return [];
|
|
8051
|
+
const parsed = Notes.safeParse(record);
|
|
8052
|
+
return parsed.success ? parsed.data.inquiries : [];
|
|
8053
|
+
}
|
|
8054
|
+
async changeInquiries(change) {
|
|
8055
|
+
const done = this.writes.then(async () => {
|
|
8056
|
+
const inquiries = change(await this.inquiries());
|
|
8057
|
+
await writeWhole(this.notesFile, `${JSON.stringify({ format: NOTES_FORMAT, version: NOTES_VERSION, inquiries }, null, 1)}
|
|
8058
|
+
`);
|
|
8059
|
+
});
|
|
8060
|
+
this.writes = done.catch(() => {});
|
|
8061
|
+
await done;
|
|
7977
8062
|
}
|
|
7978
8063
|
load() {
|
|
7979
8064
|
this.loaded ??= (async () => {
|
|
@@ -8924,7 +9009,8 @@ class ReviewEngine {
|
|
|
8924
9009
|
entries.delete(key);
|
|
8925
9010
|
const err = entry.error;
|
|
8926
9011
|
const note = err instanceof Unavailable ? err.message : `The language server could not answer: ${err instanceof Error ? err.message : String(err)}`;
|
|
8927
|
-
|
|
9012
|
+
const fault = err instanceof Unavailable ? err.fault : true;
|
|
9013
|
+
return { status: "unavailable", note, ...server, ...err instanceof Unavailable && err.own ? { own: err.own } : {}, ...fault ? { fault } : {} };
|
|
8928
9014
|
}
|
|
8929
9015
|
const doing = entry.session ? entry.session.busy() : "Starting";
|
|
8930
9016
|
return { status: "pending", ...server, ...doing ? { note: doing } : {} };
|
|
@@ -9168,6 +9254,83 @@ class ReviewEngine {
|
|
|
9168
9254
|
this.sets.delete(changeSetId);
|
|
9169
9255
|
return this.open(set.target);
|
|
9170
9256
|
}
|
|
9257
|
+
async noteLines(set, stop) {
|
|
9258
|
+
const text = await this.headText(set, stop.path).catch(() => {
|
|
9259
|
+
return;
|
|
9260
|
+
});
|
|
9261
|
+
if (text === undefined)
|
|
9262
|
+
return;
|
|
9263
|
+
if (stop.line === undefined)
|
|
9264
|
+
return "";
|
|
9265
|
+
const lines = text.split(`
|
|
9266
|
+
`);
|
|
9267
|
+
if (lines.at(-1) === "")
|
|
9268
|
+
lines.pop();
|
|
9269
|
+
const end = stop.endLine ?? stop.line;
|
|
9270
|
+
return stop.line <= lines.length && end <= lines.length ? lines.slice(stop.line - 1, end).join(`
|
|
9271
|
+
`) : undefined;
|
|
9272
|
+
}
|
|
9273
|
+
async inquiries(changeSetId) {
|
|
9274
|
+
const set = this.get(changeSetId);
|
|
9275
|
+
const kept = await set.store.inquiries();
|
|
9276
|
+
return Promise.all(kept.map(async (inquiry) => ({
|
|
9277
|
+
...inquiry,
|
|
9278
|
+
stops: await Promise.all(inquiry.stops.map(async (stop) => {
|
|
9279
|
+
const now = await this.noteLines(set, stop);
|
|
9280
|
+
return now === undefined || stop.line !== undefined && now !== stop.quote ? { ...stop, stale: true } : stop;
|
|
9281
|
+
}))
|
|
9282
|
+
})));
|
|
9283
|
+
}
|
|
9284
|
+
async putInquiry(changeSetId, input) {
|
|
9285
|
+
const set = this.get(changeSetId);
|
|
9286
|
+
const stops = [];
|
|
9287
|
+
for (const [i, s] of input.stops.entries())
|
|
9288
|
+
stops.push(await this.noteStop(set, s, `Stop ${i + 1}`));
|
|
9289
|
+
const title = input.title.trim();
|
|
9290
|
+
const summary = input.summary?.trim();
|
|
9291
|
+
const inquiry = { id: randomUUID3().slice(0, 8), title, ...summary ? { summary } : {}, author: input.author?.trim() || await this.me(set.repo) || "Somebody", at: new Date().toISOString(), stops };
|
|
9292
|
+
await set.store.changeInquiries((all) => {
|
|
9293
|
+
const at = all.findIndex((q) => q.title === title);
|
|
9294
|
+
if (at < 0)
|
|
9295
|
+
return [...all, inquiry];
|
|
9296
|
+
inquiry.id = all[at].id;
|
|
9297
|
+
return all.map((q, k) => k === at ? inquiry : q);
|
|
9298
|
+
});
|
|
9299
|
+
return inquiry;
|
|
9300
|
+
}
|
|
9301
|
+
async noteStop(set, s, name) {
|
|
9302
|
+
const where = `${name} (${s.path}${s.line ? `:${s.line}` : ""})`;
|
|
9303
|
+
if (s.endLine !== undefined && (s.line === undefined || s.endLine < s.line))
|
|
9304
|
+
throw new Error(`${where}: endLine needs a line, and comes after it.`);
|
|
9305
|
+
const stop = { path: s.path.replace(/^\.\//, ""), ...s.line !== undefined ? { line: s.line } : {}, ...s.endLine !== undefined && s.endLine !== s.line ? { endLine: s.endLine } : {} };
|
|
9306
|
+
const quote = await this.noteLines(set, stop);
|
|
9307
|
+
if (quote === undefined)
|
|
9308
|
+
throw new Error(`${where}: ${await this.headText(set, stop.path).then(() => true, () => false) ? "the file has no such lines" : "there is no such file in the repository as it stands"}. Paths are from the repository's root.`);
|
|
9309
|
+
return { id: randomUUID3().slice(0, 8), ...stop, body: s.body.trim(), ...stop.line !== undefined ? { quote } : {} };
|
|
9310
|
+
}
|
|
9311
|
+
async addNote(changeSetId, input) {
|
|
9312
|
+
const set = this.get(changeSetId);
|
|
9313
|
+
const author = await this.me(set.repo) ?? "The reviewer";
|
|
9314
|
+
const stop = { ...await this.noteStop(set, input.stop, "The note"), author };
|
|
9315
|
+
const title = input.title?.trim() || "Notes";
|
|
9316
|
+
let out;
|
|
9317
|
+
await set.store.changeInquiries((all) => {
|
|
9318
|
+
const at = all.findIndex((q) => input.inquiry ? q.id === input.inquiry : q.title === title);
|
|
9319
|
+
if (input.inquiry && at < 0)
|
|
9320
|
+
throw new Error("That line of inquiry is not in this review any more.");
|
|
9321
|
+
out = at < 0 ? { id: randomUUID3().slice(0, 8), title, author, at: new Date().toISOString(), stops: [stop] } : { ...all[at], at: new Date().toISOString(), stops: [...all[at].stops, stop] };
|
|
9322
|
+
return at < 0 ? [...all, out] : all.map((q, k) => k === at ? out : q);
|
|
9323
|
+
});
|
|
9324
|
+
return out;
|
|
9325
|
+
}
|
|
9326
|
+
async removeInquiry(changeSetId, id, stop) {
|
|
9327
|
+
await this.get(changeSetId).store.changeInquiries((all) => all.flatMap((q) => {
|
|
9328
|
+
if (q.id !== id)
|
|
9329
|
+
return [q];
|
|
9330
|
+
const stops = stop ? q.stops.filter((s) => s.id !== stop) : [];
|
|
9331
|
+
return stops.length ? [{ ...q, stops }] : [];
|
|
9332
|
+
}));
|
|
9333
|
+
}
|
|
9171
9334
|
async upsertComment(changeSetId, input) {
|
|
9172
9335
|
const text = this.text(changeSetId, input.anchor.path, input.anchor.side);
|
|
9173
9336
|
const lines = text?.split(`
|
|
@@ -9274,6 +9437,10 @@ function handlers(engine) {
|
|
|
9274
9437
|
"canvas.get": ({ changeSetId }) => engine.canvas(changeSetId),
|
|
9275
9438
|
"canvas.set": async ({ changeSetId, canvas }) => (await engine.setCanvas(changeSetId, canvas), {}),
|
|
9276
9439
|
"snapshot.make": ({ changeSetId, title, pullRequest }) => engine.snapshot(changeSetId, { ...title ? { title } : {}, ...pullRequest ? { pullRequest } : {} }),
|
|
9440
|
+
"notes.get": async ({ changeSetId }) => ({ inquiries: await engine.inquiries(changeSetId) }),
|
|
9441
|
+
"notes.put": ({ changeSetId, ...inquiry }) => engine.putInquiry(changeSetId, inquiry),
|
|
9442
|
+
"notes.add": ({ changeSetId, inquiry, title, stop }) => engine.addNote(changeSetId, { ...inquiry ? { inquiry } : {}, ...title ? { title } : {}, stop }),
|
|
9443
|
+
"notes.remove": async ({ changeSetId, id, stop }) => (await engine.removeInquiry(changeSetId, id, stop), {}),
|
|
9277
9444
|
"comment.upsert": ({ changeSetId, id, anchor, body }) => engine.upsertComment(changeSetId, { ...id ? { id } : {}, anchor, body }),
|
|
9278
9445
|
"comment.remove": async ({ changeSetId, id }) => (await engine.removeComment(changeSetId, id), {}),
|
|
9279
9446
|
"text.read": ({ changeSetId, path, start, end }) => engine.read(changeSetId, path, start, end),
|
|
@@ -9440,5 +9607,5 @@ export {
|
|
|
9440
9607
|
contribute as default
|
|
9441
9608
|
};
|
|
9442
9609
|
|
|
9443
|
-
//# debugId=
|
|
9610
|
+
//# debugId=5148D0B0B4A5F32F64756E2164756E21
|
|
9444
9611
|
//# sourceMappingURL=index.js.map
|