@dev.fast/whiteboard 0.2.5-preview.20261013.112 → 0.2.5-preview.20261015.115
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/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/{account-alias-D0hF0sKk.js → account-alias-ChZR3RIU.js} +94 -8
- package/dist/{agent-cli-BBPxwUOd.js → agent-cli-CR2PnA9G.js} +9 -12
- package/dist/agent-cli-CRPPmS3l.js +2 -0
- package/dist/{agent-client-P3J4y8Zn.js → agent-client-DVd-prfp.js} +31 -14
- package/dist/{authoring-tools-D8WXsm_g.js → authoring-tools-BXKEwhfi.js} +5 -5
- package/dist/background-server-Cw7CcfaZ.js +156 -0
- package/dist/background-server-D2Rrr_e2.js +2 -0
- package/dist/build-info.json +1 -1
- package/dist/{cli-C0ziP6hg.js → cli-CSrz_wGk.js} +1 -1
- package/dist/{cli-runner-C1gY-HAI.js → cli-runner-PlGqBeMw.js} +368 -252
- package/dist/cli.js +3 -2
- package/dist/{client-DzcSt6pV.js → client-DhZzPePs.js} +5 -3
- package/dist/{process-error-telemetry-C0swByfp.js → headless-host-CVXTSIlx.js} +3285 -2585
- package/dist/headless-host-Cp37C-v0.js +2 -0
- package/dist/input-error-OLgB_h31.js +11 -0
- package/dist/{local-data-BlERtVm2.js → local-data-yfLp5PiJ.js} +237 -157
- package/dist/{mcp-t7VN9R3k.js → mcp-DBbDwG4y.js} +4 -4
- package/dist/{package-paths-B9PDoAl6.js → package-paths-BsuI4WUf.js} +1 -1
- package/dist/profile-BSOkA6A-.js +2 -0
- package/dist/{profile-BsYDBr7t.js → profile-pAzg7fxC.js} +3 -3
- package/dist/remote-attach-BAt2eZx3.js +137 -0
- package/dist/remote-extensions-2Cxf3hMo.js +2 -0
- package/dist/remote-extensions-BiNx6NQK.js +323 -0
- package/dist/remote-language-server-DQgWUNeV.js +252 -0
- package/dist/remote-uninstall-DLtDG0o7.js +153 -0
- package/dist/{request-origin-DA4K1qWY.js → request-origin-DaRIV3cB.js} +5 -2
- package/dist/review-app-launcher-D7I4DGoH.js +222 -0
- package/dist/{review-home-paths-Y9mYWkCI.js → review-home-paths-zwevIq4I.js} +7 -7
- package/dist/{review-telemetry-CmM6tCbj.js → review-telemetry-BqB4CiTD.js} +5 -5
- package/dist/{s3-SzLpeCG6.js → s3-77-qkEhs.js} +1 -1
- package/dist/{s3-config-BgxkSoOy.js → s3-config-0xuCh-F_.js} +1 -1
- package/dist/{s3-config-CAxhO9u_.js → s3-config-DDWWMh5x.js} +5 -1
- package/dist/server/desktop-host.js +1663 -266
- package/dist/{desktop-discovery-Ba3dD5Cn.js → server-discovery-CifQ3yQS.js} +88 -3
- package/dist/sharing/index.d.ts +88 -32
- package/dist/sharing/index.js +1 -1
- package/dist/{src-DiHP11l3.js → src-BMPuxWv4.js} +6 -11
- package/dist/{src-WCbabvdS.js → src-Bgvf1sEN.js} +128 -8
- package/dist/{stored-document-migration-u4L_1VZa.js → stored-document-migration-CFOvjRwW.js} +5 -18
- package/dist/{tool-failure-CJHBCHMh.js → tool-failure-BXWzQG8T.js} +2 -2
- package/instructions/authoring.md +16 -12
- package/instructions/file-lenses.md +4 -2
- package/package.json +9 -14
- package/src/agent-connect.ts +507 -0
- package/src/agent-selection.ts +4 -0
- package/src/ask/agents.ts +59 -13
- package/src/ask/pi-mcp.ts +7 -3
- package/src/ask/thread-state.ts +9 -4
- package/src/ask/thread.ts +88 -50
- package/src/ask/threads.ts +53 -7
- package/src/cli-install.ts +3 -1
- package/src/cli-runner.ts +472 -81
- package/src/cli.ts +1 -1
- package/src/connect-agents.ts +285 -0
- package/src/connect-prompts.ts +60 -6
- package/src/desktop-discovery.ts +24 -0
- package/src/pinned-download.ts +118 -0
- package/src/remote-attach.ts +130 -0
- package/src/remote-extensions.ts +359 -0
- package/src/remote-language-server.ts +428 -0
- package/src/remote-toolchains.ts +107 -0
- package/src/remote-uninstall.ts +280 -0
- package/src/review-api/README.md +1 -3
- package/src/review-api/agent-cli.ts +4 -4
- package/src/review-api/agent-client.ts +23 -0
- package/src/review-api/ask-history.ts +31 -16
- package/src/review-api/authoring-tools.ts +1 -1
- package/src/review-api/blocks/index.ts +2 -4
- package/src/review-api/document.ts +1 -4
- package/src/review-api/github-provider.ts +154 -0
- package/src/review-api/http.ts +265 -237
- package/src/review-api/local-data.ts +34 -17
- package/src/review-api/onboarding.ts +478 -0
- package/src/review-api/origin.ts +10 -6
- package/src/review-api/provider.ts +44 -0
- package/src/review-api/pull-request.ts +15 -146
- package/src/review-api/recent-folders.ts +173 -0
- package/src/review-api/store.ts +56 -10
- package/src/review-api/workspaces.ts +56 -11
- package/src/review-app-launcher.ts +61 -3
- package/src/review-stack.ts +162 -36
- package/src/server/background-server.ts +250 -0
- package/src/server/desktop-host-shutdown.ts +24 -0
- package/src/server/desktop-host.ts +39 -24
- package/src/server/desktop-server.ts +68 -118
- package/src/server/global-verb-relay.ts +16 -0
- package/src/server/headless-host.ts +128 -3
- package/src/server/hono-http.ts +6 -1
- package/src/server/legacy-tutorial-cleanup.ts +38 -0
- package/src/server/review-gateway-hosts.ts +379 -0
- package/src/server/review-gateway-list.ts +109 -0
- package/src/server/review-gateway-memory.ts +130 -0
- package/src/server/review-gateway-pushes.ts +142 -0
- package/src/server/review-gateway-streams.ts +415 -0
- package/src/server/review-gateway-transport.ts +204 -0
- package/src/server/review-gateway.ts +433 -0
- package/src/server/review-server-core.ts +36 -6
- package/src/server-discovery.ts +11 -0
- package/src/sharing/import.ts +1 -0
- package/src/ui-telemetry-events.ts +5 -1
- package/src/vsix.ts +122 -0
- package/dist/agent-cli-YSuhE5X8.js +0 -2
- package/dist/headless-host-BHD_Vg5F.js +0 -95
- package/dist/profile-j97aRTS7.js +0 -2
- package/dist/server-discovery-ZVi8Ay8J.js +0 -66
- package/src/fixtures/blocks/tutorial.json +0 -14
- package/src/review-api/blocks/tutorial.ts +0 -23
- package/src/server/tutorial-service.ts +0 -217
- package/tutorial/document.json +0 -216
- package/tutorial/lenses.json +0 -10
- package/tutorial/runtime-manifest.json +0 -11
- package/tutorial/sample-service/package.json +0 -9
- package/tutorial/sample-service/src/api/checkout-api.ts +0 -17
- package/tutorial/sample-service/src/app.ts +0 -26
- package/tutorial/sample-service/src/database/drizzle-orm.d.ts +0 -16
- package/tutorial/sample-service/src/database/schema.ts +0 -9
- package/tutorial/sample-service/src/fulfillment/fulfillment-queue.ts +0 -15
- package/tutorial/sample-service/src/fulfillment/fulfillment-worker.ts +0 -24
- package/tutorial/sample-service/src/inventory/forklift-mood.ts +0 -4
- package/tutorial/sample-service/src/inventory/inventory-service.ts +0 -28
- package/tutorial/sample-service/src/inventory/warehouse-lore.ts +0 -11
- package/tutorial/sample-service/src/orders/order-service.ts +0 -35
- package/tutorial/sample-service/src/orders/order.ts +0 -43
- package/tutorial/sample-service/src/orders/orders-repository.ts +0 -24
- package/tutorial/sample-service/src/payments/fraud-vibes.ts +0 -4
- package/tutorial/sample-service/src/payments/payment-gateway.ts +0 -29
- package/tutorial/sample-service/src/payments/raccoon-ledger.ts +0 -9
- package/tutorial/sample-service/src/shipping/shipping-gateway.ts +0 -15
- package/tutorial/sample-service/tsconfig.json +0 -12
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as parseGitRemote, a as diff, b as resolveRepoContextSync, c as diffFileSummariesWorkingTree, d as git, g as listTrackedFilesAtCommit, h as listCommitRange, i as detectLocalVcs, l as diffTrees, m as jjRevisionIsConflicted, n as createBlobBatchReader, p as gitCommonDir, s as diffFileSummariesTrees, t as LocalVcsToolsMissingError, u as diffWorkingTree, v as readFileAtCommit, x as resolveRevision, y as resolveRepoContext } from "./src-BMPuxWv4.js";
|
|
2
2
|
import { c as jsonString, o as jsonObject, u as parseJsonText } from "./src-X9phtB2j.js";
|
|
3
|
-
import {
|
|
4
|
-
import { s as safeStorageSegment } from "./review-home-paths-
|
|
5
|
-
import { $ as unionIntervals, A as applyLensEdit, C as resourceReferences, D as summarizeEdit, E as sourceReferences, F as checkSourcePath, I as fileLineRangeSchema, K as sourceAnchors, L as requireVisibleSource, N as lensSelections, O as checkReferences, P as SourceRangeError, Q as subtractIntervals, R as sliceSourceRange, S as resourceReference, X as intersectIntervals, Y as emptyCoverage, a as defineSoftwareMap, b as pinsSchema, c as traceSchema, d as applyEdit, et as updateCoverage, f as assignFreshIds, g as explicitPins, h as elements, i as SoftwareModelValidationError, j as lensEditSchema, l as textIncludesQuote, m as editSchema, n as migrateStoredDocument, p as documentSchema, q as coverageSchema, r as migrateStoredLenses, t as liftFileLenses, u as anchorPins, v as isUnit, w as reviewTargetSchema } from "./stored-document-migration-
|
|
6
|
-
import {
|
|
3
|
+
import { C as ReviewApiSelectionSourceSchema, M as structuralChangeCounts, O as ReviewSelectedDiffSchema, j as decodeStructuralDiffEvent, k as SCRATCHPAD_REVIEW_ID } from "./src-Bgvf1sEN.js";
|
|
4
|
+
import { s as safeStorageSegment } from "./review-home-paths-zwevIq4I.js";
|
|
5
|
+
import { $ as unionIntervals, A as applyLensEdit, C as resourceReferences, D as summarizeEdit, E as sourceReferences, F as checkSourcePath, I as fileLineRangeSchema, K as sourceAnchors, L as requireVisibleSource, N as lensSelections, O as checkReferences, P as SourceRangeError, Q as subtractIntervals, R as sliceSourceRange, S as resourceReference, X as intersectIntervals, Y as emptyCoverage, a as defineSoftwareMap, b as pinsSchema, c as traceSchema, d as applyEdit, et as updateCoverage, f as assignFreshIds, g as explicitPins, h as elements, i as SoftwareModelValidationError, j as lensEditSchema, l as textIncludesQuote, m as editSchema, n as migrateStoredDocument, p as documentSchema, q as coverageSchema, r as migrateStoredLenses, t as liftFileLenses, u as anchorPins, v as isUnit, w as reviewTargetSchema } from "./stored-document-migration-CFOvjRwW.js";
|
|
6
|
+
import { t as ReviewInputError } from "./input-error-OLgB_h31.js";
|
|
7
|
+
import { A as withFileLock, I as writePrivateJsonAtomic, O as processIsAlive } from "./s3-config-DDWWMh5x.js";
|
|
7
8
|
import { t as errorMessage } from "./error-message-OtiDonty.js";
|
|
8
9
|
import { r as isMissingFileError } from "./fs-utils-BMPLt0cr.js";
|
|
9
10
|
import { createRequire } from "node:module";
|
|
@@ -1231,8 +1232,6 @@ const mapInputSchema = z.strictObject({
|
|
|
1231
1232
|
});
|
|
1232
1233
|
//#endregion
|
|
1233
1234
|
//#region src/review-api/pull-request.ts
|
|
1234
|
-
const GH_TIMEOUT_MS = 2e4;
|
|
1235
|
-
const API_TIMEOUT_MS = 15e3;
|
|
1236
1235
|
const FETCH_TIMEOUT_MS = 12e4;
|
|
1237
1236
|
const LOCAL_TIMEOUT_MS = 3e4;
|
|
1238
1237
|
const defaultPullRequestDeps = {
|
|
@@ -1255,82 +1254,9 @@ const defaultPullRequestDeps = {
|
|
|
1255
1254
|
}),
|
|
1256
1255
|
fetch: (input, init) => fetch(input, init)
|
|
1257
1256
|
};
|
|
1258
|
-
/**
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
const [, owner, repo, , number] = pathname.split("/");
|
|
1262
|
-
return {
|
|
1263
|
-
host: hostname,
|
|
1264
|
-
slug: `${owner}/${repo}`,
|
|
1265
|
-
number: Number(number)
|
|
1266
|
-
};
|
|
1267
|
-
}
|
|
1268
|
-
const metadataSchema = z.object({
|
|
1269
|
-
number: z.number().int().positive(),
|
|
1270
|
-
title: z.string(),
|
|
1271
|
-
baseRefName: z.string().min(1),
|
|
1272
|
-
baseRefOid: z.string().optional()
|
|
1273
|
-
});
|
|
1274
|
-
/** gh first (it carries the user's auth), then, for github.com only, GitHub's
|
|
1275
|
-
* public REST API: Enterprise hosts require gh. */
|
|
1276
|
-
async function readPullRequest(url, deps) {
|
|
1277
|
-
const { host, slug, number } = pullRequestAddress(url);
|
|
1278
|
-
let ghFailure;
|
|
1279
|
-
try {
|
|
1280
|
-
const stdout = await deps.run("gh", [
|
|
1281
|
-
"pr",
|
|
1282
|
-
"view",
|
|
1283
|
-
String(number),
|
|
1284
|
-
"--repo",
|
|
1285
|
-
`${host}/${slug}`,
|
|
1286
|
-
"--json",
|
|
1287
|
-
"number,title,baseRefName,baseRefOid"
|
|
1288
|
-
], { timeoutMs: GH_TIMEOUT_MS });
|
|
1289
|
-
return {
|
|
1290
|
-
host,
|
|
1291
|
-
slug,
|
|
1292
|
-
...metadataSchema.parse(JSON.parse(stdout))
|
|
1293
|
-
};
|
|
1294
|
-
} catch (error) {
|
|
1295
|
-
ghFailure = firstLine(errorMessage(error));
|
|
1296
|
-
}
|
|
1297
|
-
if (host !== "github.com") throw new ReviewInputError(`Could not read ${url}: gh failed (${ghFailure}). Run \`gh auth login --hostname ${host}\` with an account that can read the repository, then retry.`, 409);
|
|
1298
|
-
let response;
|
|
1299
|
-
try {
|
|
1300
|
-
response = await deps.fetch(`https://api.github.com/repos/${slug}/pulls/${number}`, {
|
|
1301
|
-
headers: {
|
|
1302
|
-
Accept: "application/vnd.github+json",
|
|
1303
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
1304
|
-
},
|
|
1305
|
-
signal: AbortSignal.timeout(API_TIMEOUT_MS)
|
|
1306
|
-
});
|
|
1307
|
-
} catch (error) {
|
|
1308
|
-
throw unreadable(url, ghFailure, `the GitHub API is unreachable (${firstLine(errorMessage(error))})`);
|
|
1309
|
-
}
|
|
1310
|
-
if (response.status === 404) throw new ReviewInputError(`${url} was not found: it does not exist, or it is private and gh is not signed in to an account that can read it (run \`gh auth status\`). gh said: ${ghFailure}`, 404);
|
|
1311
|
-
if (response.status === 403 || response.status === 429) throw unreadable(url, ghFailure, response.headers.get("x-ratelimit-remaining") === "0" || response.status === 429 ? "the unauthenticated GitHub API rate limit is exhausted" : "the GitHub API refused the request");
|
|
1312
|
-
if (!response.ok) throw unreadable(url, ghFailure, `the GitHub API returned HTTP ${response.status}`);
|
|
1313
|
-
const parsed = z.object({
|
|
1314
|
-
number: z.number(),
|
|
1315
|
-
title: z.string(),
|
|
1316
|
-
base: z.object({
|
|
1317
|
-
ref: z.string().min(1),
|
|
1318
|
-
sha: z.string()
|
|
1319
|
-
})
|
|
1320
|
-
}).safeParse(await response.json().catch(() => void 0));
|
|
1321
|
-
if (!parsed.success) throw unreadable(url, ghFailure, "the GitHub API response was malformed");
|
|
1322
|
-
return {
|
|
1323
|
-
host,
|
|
1324
|
-
slug,
|
|
1325
|
-
number: parsed.data.number,
|
|
1326
|
-
title: parsed.data.title,
|
|
1327
|
-
baseRefName: parsed.data.base.ref,
|
|
1328
|
-
baseRefOid: parsed.data.base.sha
|
|
1329
|
-
};
|
|
1330
|
-
}
|
|
1331
|
-
/** Remotes by the host and owner/repo their configured URL names. The
|
|
1332
|
-
* configured URL, not the insteadOf rewrite: a mirror still names its repo. */
|
|
1333
|
-
async function githubRemotes(gitDir, deps) {
|
|
1257
|
+
/** Remotes by their configured URL, not the insteadOf rewrite: a mirror
|
|
1258
|
+
* still names its repo. */
|
|
1259
|
+
async function remoteUrls(gitDir, deps) {
|
|
1334
1260
|
return (await deps.run("git", [
|
|
1335
1261
|
"--git-dir",
|
|
1336
1262
|
gitDir,
|
|
@@ -1339,17 +1265,15 @@ async function githubRemotes(gitDir, deps) {
|
|
|
1339
1265
|
String.raw`^remote\..*\.url$`
|
|
1340
1266
|
], { timeoutMs: LOCAL_TIMEOUT_MS }).catch(() => "")).split("\n").flatMap((line) => {
|
|
1341
1267
|
const match = /^remote\.(.+)\.url\s+(\S+)/.exec(line.trim());
|
|
1342
|
-
|
|
1343
|
-
return match && remote ? [{
|
|
1268
|
+
return match ? [{
|
|
1344
1269
|
name: match[1],
|
|
1345
|
-
|
|
1346
|
-
slug: remote.slug
|
|
1270
|
+
url: match[2]
|
|
1347
1271
|
}] : [];
|
|
1348
1272
|
});
|
|
1349
1273
|
}
|
|
1350
1274
|
/** Refs Review owns for one PR; the user's branches and bookmarks never move. */
|
|
1351
|
-
function pullRequestRefs(pr) {
|
|
1352
|
-
const prefix = `refs/review
|
|
1275
|
+
function pullRequestRefs(provider, pr) {
|
|
1276
|
+
const prefix = `refs/review/${provider}/${`${pr.host === "github.com" ? "" : `${pr.host}/`}${pr.slug}`.toLowerCase()}/pull/${pr.number}`;
|
|
1353
1277
|
return {
|
|
1354
1278
|
head: `${prefix}/head`,
|
|
1355
1279
|
base: `${prefix}/base`,
|
|
@@ -1369,7 +1293,7 @@ function pullRequestRefs(pr) {
|
|
|
1369
1293
|
*/
|
|
1370
1294
|
async function fetchPullRequest(input, deps) {
|
|
1371
1295
|
const { pullRequest: pr } = input;
|
|
1372
|
-
const refs = pullRequestRefs(pr);
|
|
1296
|
+
const refs = pullRequestRefs(input.provider, pr);
|
|
1373
1297
|
const git = (args, timeoutMs = LOCAL_TIMEOUT_MS) => deps.run("git", [
|
|
1374
1298
|
"--git-dir",
|
|
1375
1299
|
input.gitDir,
|
|
@@ -1401,11 +1325,11 @@ async function fetchPullRequest(input, deps) {
|
|
|
1401
1325
|
};
|
|
1402
1326
|
let baseTip;
|
|
1403
1327
|
try {
|
|
1404
|
-
await fetchRefs(
|
|
1328
|
+
await fetchRefs(`+${pr.headRef}:${refs.head}`, `+refs/heads/${pr.baseRefName}:${refs.base}`);
|
|
1405
1329
|
baseTip = await commit(refs.base);
|
|
1406
1330
|
} catch (error) {
|
|
1407
1331
|
try {
|
|
1408
|
-
await fetchRefs(
|
|
1332
|
+
await fetchRefs(`+${pr.headRef}:${refs.head}`);
|
|
1409
1333
|
} catch {
|
|
1410
1334
|
throw new ReviewInputError(`Could not fetch PR #${pr.number} from remote "${input.remote}" (${pr.slug}). Check \`git fetch ${input.remote}\` works with your Git credentials, then retry. Git said: ${firstLine(errorMessage(error))}`, 409);
|
|
1411
1335
|
}
|
|
@@ -1460,11 +1384,115 @@ async function indexForJj(rootPath, commits, git, deps) {
|
|
|
1460
1384
|
await jjImport().catch(() => void 0);
|
|
1461
1385
|
}
|
|
1462
1386
|
}
|
|
1387
|
+
function firstLine(text) {
|
|
1388
|
+
return text.split("\n")[0].slice(0, 300);
|
|
1389
|
+
}
|
|
1390
|
+
//#endregion
|
|
1391
|
+
//#region src/review-api/github-provider.ts
|
|
1392
|
+
const GH_TIMEOUT_MS = 2e4;
|
|
1393
|
+
const API_TIMEOUT_MS = 15e3;
|
|
1394
|
+
const GITHUB_PR_REGEX = /^https:\/\/([a-z0-9.-]+)\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/pull\/([1-9]\d*)$/;
|
|
1395
|
+
const metadataSchema = z.object({
|
|
1396
|
+
number: z.number().int().positive(),
|
|
1397
|
+
title: z.string(),
|
|
1398
|
+
baseRefName: z.string().min(1),
|
|
1399
|
+
baseRefOid: z.string().optional()
|
|
1400
|
+
});
|
|
1463
1401
|
function unreadable(url, ghFailure, fallback) {
|
|
1464
1402
|
return new ReviewInputError(`Could not read ${url}: gh failed (${ghFailure}) and ${fallback}. Run \`gh auth status\` and sign in with an account that can read the repository, then retry.`, 409);
|
|
1465
1403
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1404
|
+
//#endregion
|
|
1405
|
+
//#region src/review-api/provider.ts
|
|
1406
|
+
const providers = [{
|
|
1407
|
+
id: "github",
|
|
1408
|
+
parseUrl(url) {
|
|
1409
|
+
const match = GITHUB_PR_REGEX.exec(url);
|
|
1410
|
+
const number = Number(match?.[4]);
|
|
1411
|
+
if (!match || !Number.isSafeInteger(number)) return void 0;
|
|
1412
|
+
return {
|
|
1413
|
+
host: match[1],
|
|
1414
|
+
slug: `${match[2]}/${match[3]}`,
|
|
1415
|
+
number
|
|
1416
|
+
};
|
|
1417
|
+
},
|
|
1418
|
+
/** gh first (it carries the user's auth), then, for github.com only, GitHub's
|
|
1419
|
+
* public REST API: Enterprise hosts require gh. */
|
|
1420
|
+
async readPullRequest({ host, slug, number }, deps) {
|
|
1421
|
+
const url = `https://${host}/${slug}/pull/${number}`;
|
|
1422
|
+
const headRef = `refs/pull/${number}/head`;
|
|
1423
|
+
let ghFailure;
|
|
1424
|
+
try {
|
|
1425
|
+
const stdout = await deps.run("gh", [
|
|
1426
|
+
"pr",
|
|
1427
|
+
"view",
|
|
1428
|
+
String(number),
|
|
1429
|
+
"--repo",
|
|
1430
|
+
`${host}/${slug}`,
|
|
1431
|
+
"--json",
|
|
1432
|
+
"number,title,baseRefName,baseRefOid"
|
|
1433
|
+
], { timeoutMs: GH_TIMEOUT_MS });
|
|
1434
|
+
return {
|
|
1435
|
+
host,
|
|
1436
|
+
slug,
|
|
1437
|
+
headRef,
|
|
1438
|
+
...metadataSchema.parse(JSON.parse(stdout))
|
|
1439
|
+
};
|
|
1440
|
+
} catch (error) {
|
|
1441
|
+
ghFailure = firstLine(errorMessage(error));
|
|
1442
|
+
}
|
|
1443
|
+
if (host !== "github.com") throw new ReviewInputError(`Could not read ${url}: gh failed (${ghFailure}). Run \`gh auth login --hostname ${host}\` with an account that can read the repository, then retry.`, 409);
|
|
1444
|
+
let response;
|
|
1445
|
+
try {
|
|
1446
|
+
response = await deps.fetch(`https://api.github.com/repos/${slug}/pulls/${number}`, {
|
|
1447
|
+
headers: {
|
|
1448
|
+
Accept: "application/vnd.github+json",
|
|
1449
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
1450
|
+
},
|
|
1451
|
+
signal: AbortSignal.timeout(API_TIMEOUT_MS)
|
|
1452
|
+
});
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
throw unreadable(url, ghFailure, `the GitHub API is unreachable (${firstLine(errorMessage(error))})`);
|
|
1455
|
+
}
|
|
1456
|
+
if (response.status === 404) throw new ReviewInputError(`${url} was not found: it does not exist, or it is private and gh is not signed in to an account that can read it (run \`gh auth status\`). gh said: ${ghFailure}`, 404);
|
|
1457
|
+
if (response.status === 403 || response.status === 429) throw unreadable(url, ghFailure, response.headers.get("x-ratelimit-remaining") === "0" || response.status === 429 ? "the unauthenticated GitHub API rate limit is exhausted" : "the GitHub API refused the request");
|
|
1458
|
+
if (!response.ok) throw unreadable(url, ghFailure, `the GitHub API returned HTTP ${response.status}`);
|
|
1459
|
+
const parsed = z.object({
|
|
1460
|
+
number: z.number(),
|
|
1461
|
+
title: z.string(),
|
|
1462
|
+
base: z.object({
|
|
1463
|
+
ref: z.string().min(1),
|
|
1464
|
+
sha: z.string()
|
|
1465
|
+
})
|
|
1466
|
+
}).safeParse(await response.json().catch(() => void 0));
|
|
1467
|
+
if (!parsed.success) throw unreadable(url, ghFailure, "the GitHub API response was malformed");
|
|
1468
|
+
return {
|
|
1469
|
+
host,
|
|
1470
|
+
slug,
|
|
1471
|
+
headRef,
|
|
1472
|
+
number: parsed.data.number,
|
|
1473
|
+
title: parsed.data.title,
|
|
1474
|
+
baseRefName: parsed.data.base.ref,
|
|
1475
|
+
baseRefOid: parsed.data.base.sha
|
|
1476
|
+
};
|
|
1477
|
+
},
|
|
1478
|
+
matchesRemote(remoteUrl, address) {
|
|
1479
|
+
const remote = parseGitRemote(remoteUrl);
|
|
1480
|
+
return remote?.host === address.host && remote.slug.toLowerCase() === address.slug.toLowerCase();
|
|
1481
|
+
}
|
|
1482
|
+
}];
|
|
1483
|
+
function pullRequestProvider(url) {
|
|
1484
|
+
for (const provider of providers) {
|
|
1485
|
+
const address = provider.parseUrl(url);
|
|
1486
|
+
if (address) return {
|
|
1487
|
+
provider,
|
|
1488
|
+
address
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
function resolvePullRequest(url) {
|
|
1493
|
+
const resolution = pullRequestProvider(url);
|
|
1494
|
+
if (!resolution) throw new ReviewInputError(`Unsupported pull request URL: ${url}`, 400);
|
|
1495
|
+
return resolution;
|
|
1468
1496
|
}
|
|
1469
1497
|
//#endregion
|
|
1470
1498
|
//#region src/review-api/activity.ts
|
|
@@ -1638,26 +1666,30 @@ var ReviewActivity = class {
|
|
|
1638
1666
|
};
|
|
1639
1667
|
/** A semantic selection, independent of comment/thread creation. */
|
|
1640
1668
|
const AgentSelectionSchema = z.strictObject({
|
|
1641
|
-
target: z.discriminatedUnion("kind", [
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1669
|
+
target: z.discriminatedUnion("kind", [
|
|
1670
|
+
z.strictObject({
|
|
1671
|
+
kind: z.literal("text"),
|
|
1672
|
+
quote: z.string(),
|
|
1673
|
+
/** Where the quote is: characters `start` to `end` of the text of the
|
|
1674
|
+
* review block `blockId`, which was `text` then. The block keeps its
|
|
1675
|
+
* id across versions; comparing its text then and now finds the quote
|
|
1676
|
+
* again, or tells that it changed. */
|
|
1677
|
+
anchor: z.strictObject({
|
|
1678
|
+
blockId: z.string().min(1).max(200),
|
|
1679
|
+
start: z.number().int().nonnegative(),
|
|
1680
|
+
end: z.number().int().positive(),
|
|
1681
|
+
text: z.string().max(2e4)
|
|
1682
|
+
}).refine((anchor) => anchor.start < anchor.end, "an empty anchor").optional()
|
|
1683
|
+
}),
|
|
1684
|
+
z.strictObject({
|
|
1685
|
+
kind: z.literal("code"),
|
|
1686
|
+
path: z.string(),
|
|
1687
|
+
side: z.enum(["base", "head"]),
|
|
1688
|
+
startLine: z.number().int().positive(),
|
|
1689
|
+
endLine: z.number().int().positive()
|
|
1690
|
+
}),
|
|
1691
|
+
z.strictObject({ kind: z.literal("review") })
|
|
1692
|
+
]),
|
|
1661
1693
|
title: z.string().max(500),
|
|
1662
1694
|
detail: z.string().max(24e3).optional(),
|
|
1663
1695
|
revision: z.string().max(200).optional(),
|
|
@@ -1667,6 +1699,7 @@ const AgentSelectionSchema = z.strictObject({
|
|
|
1667
1699
|
function selectionMarkdown(selection, sourceExcerpt = "", diffPaths) {
|
|
1668
1700
|
const target = selection.target;
|
|
1669
1701
|
if (selection.selectedDiff) return selectedDiffMarkdown(selection.selectedDiff, diffPaths);
|
|
1702
|
+
if (target.kind === "review") return "";
|
|
1670
1703
|
if (target.kind === "text") return target.quote.split(/\r?\n/).map((line) => `> ${line}`).join("\n");
|
|
1671
1704
|
return [
|
|
1672
1705
|
`## ${selection.title}`,
|
|
@@ -1845,6 +1878,13 @@ const statusSchema = z.enum([
|
|
|
1845
1878
|
"idle",
|
|
1846
1879
|
"failed"
|
|
1847
1880
|
]);
|
|
1881
|
+
/** What an agent may do without asking: nothing that changes the checkout,
|
|
1882
|
+
* what its own judgment calls safe, or everything. */
|
|
1883
|
+
const askPermissionsSchema = z.enum([
|
|
1884
|
+
"read-only",
|
|
1885
|
+
"auto",
|
|
1886
|
+
"bypass"
|
|
1887
|
+
]);
|
|
1848
1888
|
/** Everything the Ask panel renders. A watcher gets it whole once, then
|
|
1849
1889
|
* follows it through `AskChange`s. */
|
|
1850
1890
|
const askThreadStateSchema = z.object({
|
|
@@ -1857,8 +1897,7 @@ const askThreadStateSchema = z.object({
|
|
|
1857
1897
|
signIn: z.string().optional(),
|
|
1858
1898
|
/** The mode that keeps the agent from changing files was accepted. */
|
|
1859
1899
|
readOnly: z.boolean(),
|
|
1860
|
-
|
|
1861
|
-
bypass: z.boolean(),
|
|
1900
|
+
permissions: askPermissionsSchema,
|
|
1862
1901
|
head: z.string(),
|
|
1863
1902
|
/** The checkout the agent works in. */
|
|
1864
1903
|
cwd: z.string(),
|
|
@@ -1886,7 +1925,7 @@ const askChangeSchema = z.discriminatedUnion("type", [
|
|
|
1886
1925
|
type: z.literal("set"),
|
|
1887
1926
|
status: statusSchema.optional(),
|
|
1888
1927
|
readOnly: z.boolean().optional(),
|
|
1889
|
-
|
|
1928
|
+
permissions: askPermissionsSchema.optional(),
|
|
1890
1929
|
choices: askChoicesSchema.optional(),
|
|
1891
1930
|
commands: z.array(askCommandSchema).optional(),
|
|
1892
1931
|
accepts: askAcceptsSchema.optional(),
|
|
@@ -1942,7 +1981,7 @@ function applyAskChange(state, change) {
|
|
|
1942
1981
|
...rest,
|
|
1943
1982
|
status: change.status ?? state.status,
|
|
1944
1983
|
readOnly: change.readOnly ?? state.readOnly,
|
|
1945
|
-
|
|
1984
|
+
permissions: change.permissions ?? state.permissions
|
|
1946
1985
|
};
|
|
1947
1986
|
const choices = change.choices ?? state.choices;
|
|
1948
1987
|
if (choices) next.choices = choices;
|
|
@@ -2010,8 +2049,8 @@ const askRecordSchema = z.object({
|
|
|
2010
2049
|
cwd: z.string(),
|
|
2011
2050
|
/** What the panel showed last; absent until a turn ends or it closes. */
|
|
2012
2051
|
entries: z.array(askEntrySchema).optional(),
|
|
2013
|
-
/**
|
|
2014
|
-
|
|
2052
|
+
/** What the agent may do without asking, when it reopens. */
|
|
2053
|
+
permissions: askPermissionsSchema.optional()
|
|
2015
2054
|
});
|
|
2016
2055
|
const rowSchema = z.object({
|
|
2017
2056
|
id: z.string(),
|
|
@@ -2026,7 +2065,8 @@ const rowSchema = z.object({
|
|
|
2026
2065
|
created_at: z.string(),
|
|
2027
2066
|
updated_at: z.string(),
|
|
2028
2067
|
entries: z.string().nullable(),
|
|
2029
|
-
bypass: z.number()
|
|
2068
|
+
bypass: z.number(),
|
|
2069
|
+
permissions: z.string().nullable()
|
|
2030
2070
|
}).transform((row) => askRecordSchema.parse({
|
|
2031
2071
|
id: row.id,
|
|
2032
2072
|
reviewId: row.review_id,
|
|
@@ -2040,7 +2080,7 @@ const rowSchema = z.object({
|
|
|
2040
2080
|
createdAt: row.created_at,
|
|
2041
2081
|
updatedAt: row.updated_at,
|
|
2042
2082
|
entries: row.entries === null ? void 0 : JSON.parse(row.entries),
|
|
2043
|
-
|
|
2083
|
+
permissions: row.permissions ?? (row.bypass === 1 ? "bypass" : "read-only")
|
|
2044
2084
|
}));
|
|
2045
2085
|
/** Saved Ask conversations, per review. Shared reviews are not in
|
|
2046
2086
|
* `reviews`, so there is no foreign key; deleting a review deletes its rows. */
|
|
@@ -2066,9 +2106,12 @@ var AskHistory = class {
|
|
|
2066
2106
|
updated_at TEXT NOT NULL,
|
|
2067
2107
|
entries TEXT,
|
|
2068
2108
|
bypass INTEGER NOT NULL DEFAULT 0,
|
|
2109
|
+
permissions TEXT,
|
|
2069
2110
|
UNIQUE(agent, session_id));
|
|
2070
2111
|
CREATE INDEX IF NOT EXISTS ask_conversations_review ON ask_conversations(review_id, updated_at);`);
|
|
2071
|
-
|
|
2112
|
+
const columns = new Set(db.prepare("PRAGMA table_info(ask_conversations)").all().map((column) => String(column.name)));
|
|
2113
|
+
if (!columns.has("bypass")) db.exec("ALTER TABLE ask_conversations ADD COLUMN bypass INTEGER NOT NULL DEFAULT 0");
|
|
2114
|
+
if (!columns.has("permissions")) db.exec("ALTER TABLE ask_conversations ADD COLUMN permissions TEXT");
|
|
2072
2115
|
db.exec("CREATE TABLE IF NOT EXISTS ask_agent_offers(agent TEXT PRIMARY KEY, offer TEXT NOT NULL)");
|
|
2073
2116
|
db.exec("CREATE TABLE IF NOT EXISTS ask_agent_model_offers(agent TEXT NOT NULL, model TEXT NOT NULL, offer TEXT NOT NULL, PRIMARY KEY(agent, model))");
|
|
2074
2117
|
}
|
|
@@ -2086,13 +2129,13 @@ var AskHistory = class {
|
|
|
2086
2129
|
}
|
|
2087
2130
|
save(record) {
|
|
2088
2131
|
this.assertWritable(record.reviewId);
|
|
2089
|
-
this.db.prepare(`INSERT OR REPLACE INTO ask_conversations(id,review_id,agent,session_id,version,head,cwd,selection,title,created_at,updated_at,bypass)
|
|
2090
|
-
VALUES(
|
|
2132
|
+
this.db.prepare(`INSERT OR REPLACE INTO ask_conversations(id,review_id,agent,session_id,version,head,cwd,selection,title,created_at,updated_at,bypass,permissions)
|
|
2133
|
+
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)`).run(record.id, record.reviewId, record.agent, record.sessionId, record.version, record.head, record.cwd, JSON.stringify(record.selection), record.title, record.createdAt, record.updatedAt, record.permissions === "bypass" ? 1 : 0, record.permissions ?? null);
|
|
2091
2134
|
}
|
|
2092
|
-
/**
|
|
2093
|
-
|
|
2135
|
+
/** What the agent may do without asking when the conversation reopens. */
|
|
2136
|
+
setPermissions(id, permissions) {
|
|
2094
2137
|
this.assertThreadWritable(id);
|
|
2095
|
-
this.db.prepare("UPDATE ask_conversations SET bypass=? WHERE id=?").run(bypass ? 1 : 0, id);
|
|
2138
|
+
this.db.prepare("UPDATE ask_conversations SET bypass=?, permissions=? WHERE id=?").run(permissions === "bypass" ? 1 : 0, permissions, id);
|
|
2096
2139
|
}
|
|
2097
2140
|
/** Points a conversation at a new session, when its agent could not
|
|
2098
2141
|
* reopen the one it had. */
|
|
@@ -2133,7 +2176,7 @@ var AskHistory = class {
|
|
|
2133
2176
|
/** Newest first. */
|
|
2134
2177
|
list(reviewId) {
|
|
2135
2178
|
return this.db.prepare("SELECT * FROM ask_conversations WHERE review_id=? ORDER BY updated_at DESC").all(reviewId).map((row) => {
|
|
2136
|
-
const { reviewId: _reviewId, sessionId: _sessionId, version: _version, cwd: _cwd, entries,
|
|
2179
|
+
const { reviewId: _reviewId, sessionId: _sessionId, version: _version, cwd: _cwd, entries, permissions: _permissions, ...entry } = rowSchema.parse(row);
|
|
2137
2180
|
const question = entries?.find((entry) => entry.kind === "user")?.text;
|
|
2138
2181
|
if (question?.trim()) entry.question = question;
|
|
2139
2182
|
return entry;
|
|
@@ -2153,26 +2196,28 @@ var AskHistory = class {
|
|
|
2153
2196
|
};
|
|
2154
2197
|
//#endregion
|
|
2155
2198
|
//#region src/review-api/origin.ts
|
|
2156
|
-
const pullRequestUrl = z.string().
|
|
2199
|
+
const pullRequestUrl = z.string().refine((url) => pullRequestProvider(url) !== void 0, "Use a canonical GitHub PR URL: https://github.com/owner/repository/pull/123, or the same path on a GitHub Enterprise host.");
|
|
2157
2200
|
/** One key per PR: GitHub owner and repository names are case-insensitive,
|
|
2158
2201
|
* and the URL pattern admits only ASCII, so lowercasing is canonical. */
|
|
2159
2202
|
function pullRequestKey(url) {
|
|
2160
2203
|
return url.toLowerCase();
|
|
2161
2204
|
}
|
|
2162
2205
|
/** Omission preserves identity; null detaches it without changing import metadata. */
|
|
2163
|
-
function setPullRequest(snapshot, url) {
|
|
2206
|
+
function setPullRequest(snapshot, url, title) {
|
|
2164
2207
|
if (url === void 0) return;
|
|
2165
2208
|
if (url === null) {
|
|
2166
2209
|
if (snapshot.origin) {
|
|
2167
2210
|
delete snapshot.origin.pullRequestUrl;
|
|
2168
2211
|
delete snapshot.origin.pullRequestNumber;
|
|
2212
|
+
delete snapshot.origin.pullRequestTitle;
|
|
2169
2213
|
}
|
|
2170
2214
|
return;
|
|
2171
2215
|
}
|
|
2172
2216
|
snapshot.origin = {
|
|
2173
2217
|
...snapshot.origin,
|
|
2174
2218
|
pullRequestUrl: url,
|
|
2175
|
-
pullRequestNumber: Number(url.split("/").at(-1))
|
|
2219
|
+
pullRequestNumber: Number(url.split("/").at(-1)),
|
|
2220
|
+
pullRequestTitle: title ?? (snapshot.origin?.pullRequestUrl === url ? snapshot.origin.pullRequestTitle : void 0)
|
|
2176
2221
|
};
|
|
2177
2222
|
}
|
|
2178
2223
|
//#endregion
|
|
@@ -2650,8 +2695,8 @@ var ReviewStore = class {
|
|
|
2650
2695
|
listener();
|
|
2651
2696
|
} catch {}
|
|
2652
2697
|
}
|
|
2653
|
-
/**
|
|
2654
|
-
|
|
2698
|
+
/** Reviews of the tutorial earlier versions shipped, for their removal. */
|
|
2699
|
+
legacyTutorialIds() {
|
|
2655
2700
|
return this.db.prepare(`SELECT reviews.id FROM reviews JOIN versions ON versions.review_id=reviews.id AND versions.version=reviews.version WHERE json_extract(versions.snapshot,'$.origin.tutorial') = 1`).all().map((row) => String(row.id));
|
|
2656
2701
|
}
|
|
2657
2702
|
list(mode = "structural") {
|
|
@@ -2669,8 +2714,7 @@ var ReviewStore = class {
|
|
|
2669
2714
|
JOIN versions ON versions.review_id=reviews.id AND versions.version=reviews.version
|
|
2670
2715
|
LEFT JOIN review_attention ON review_attention.review_id=reviews.id
|
|
2671
2716
|
LEFT JOIN repositories ON repositories.id=json_extract(versions.snapshot,'$.pins.repositoryId')
|
|
2672
|
-
|
|
2673
|
-
${id === void 0 ? "" : "AND reviews.id=?"}
|
|
2717
|
+
${id === void 0 ? "" : "WHERE reviews.id=?"}
|
|
2674
2718
|
ORDER BY reviews.rowid`).all(...id === void 0 ? [] : [id]).map((row) => {
|
|
2675
2719
|
const summary = JSON.parse(String(row.summary));
|
|
2676
2720
|
if (summary.pins) summary.target ??= {
|
|
@@ -2736,13 +2780,14 @@ var ReviewStore = class {
|
|
|
2736
2780
|
inspect(id, targetId, version) {
|
|
2737
2781
|
return inspectSnapshot(this.read(id, version), targetId);
|
|
2738
2782
|
}
|
|
2739
|
-
/** The host can seed a
|
|
2783
|
+
/** The host can seed a document; transport callers only supply a command. */
|
|
2740
2784
|
execute(input, initial) {
|
|
2741
2785
|
if (this.closing) return Promise.reject(/* @__PURE__ */ new Error("Review store is closing."));
|
|
2742
2786
|
const command = commandSchema.parse(input);
|
|
2743
2787
|
if (initial && command.operation.type !== "create") throw new ReviewInputError("Initial content requires a create command.");
|
|
2744
2788
|
const pullRequest = this.startPullRequest(command);
|
|
2745
2789
|
pullRequest?.catch(() => {});
|
|
2790
|
+
const pullRequestTitle = pullRequest ? pullRequest.then(({ title }) => title || void 0, () => void 0) : this.startPullRequestTitle(command);
|
|
2746
2791
|
const run = this.pending.then(async () => {
|
|
2747
2792
|
const op = command.operation;
|
|
2748
2793
|
this.purgeExpired();
|
|
@@ -2794,7 +2839,7 @@ var ReviewStore = class {
|
|
|
2794
2839
|
}
|
|
2795
2840
|
const id = op.type !== "create" ? op.reviewId : op.kind === "scratchpad" ? SCRATCHPAD_ID : randomUUID();
|
|
2796
2841
|
const previous = op.type === "create" ? void 0 : this.read(id);
|
|
2797
|
-
let snapshot = op.type === "create" ? createdSnapshot(id, op, resolvedTarget, fromPullRequest
|
|
2842
|
+
let snapshot = op.type === "create" ? createdSnapshot(id, op, resolvedTarget, fromPullRequest && (fromPullRequest.title || `PR #${op.pullRequestUrl.split("/").at(-1)}`)) : structuredClone(previous);
|
|
2798
2843
|
delete snapshot.trashedAt;
|
|
2799
2844
|
delete snapshot.sourceUnavailable;
|
|
2800
2845
|
delete snapshot.lastEdit;
|
|
@@ -2812,6 +2857,10 @@ var ReviewStore = class {
|
|
|
2812
2857
|
};
|
|
2813
2858
|
}
|
|
2814
2859
|
}
|
|
2860
|
+
if (requestedTarget) snapshot.origin = {
|
|
2861
|
+
...snapshot.origin,
|
|
2862
|
+
baseBranch: requestedTarget.base === resolvedTarget?.pins.base ? void 0 : requestedTarget.base
|
|
2863
|
+
};
|
|
2815
2864
|
switch (op.type) {
|
|
2816
2865
|
case "create":
|
|
2817
2866
|
if (initial) {
|
|
@@ -2822,13 +2871,13 @@ var ReviewStore = class {
|
|
|
2822
2871
|
};
|
|
2823
2872
|
for (const block of snapshot.document) assignFreshIds(block, (prefix) => `${prefix}-${++nextId}`);
|
|
2824
2873
|
}
|
|
2825
|
-
setPullRequest(snapshot, op.pullRequestUrl);
|
|
2874
|
+
setPullRequest(snapshot, op.pullRequestUrl, await pullRequestTitle);
|
|
2826
2875
|
break;
|
|
2827
2876
|
case "rename":
|
|
2828
2877
|
snapshot.title = op.title;
|
|
2829
2878
|
break;
|
|
2830
2879
|
case "set_target":
|
|
2831
|
-
setPullRequest(snapshot, op.pullRequestUrl ?? (op.pullRequestUrl === null || snapshot.pins?.repositoryId !== resolvedTarget.pins.repositoryId ? null : void 0));
|
|
2880
|
+
setPullRequest(snapshot, op.pullRequestUrl ?? (op.pullRequestUrl === null || snapshot.pins?.repositoryId !== resolvedTarget.pins.repositoryId ? null : void 0), await pullRequestTitle);
|
|
2832
2881
|
snapshot.staleSources = [];
|
|
2833
2882
|
snapshot.target = resolvedTarget.target;
|
|
2834
2883
|
snapshot.pins = resolvedTarget.pins;
|
|
@@ -2915,12 +2964,16 @@ var ReviewStore = class {
|
|
|
2915
2964
|
preferred: existing && this.read(existing).pins?.repositoryId
|
|
2916
2965
|
});
|
|
2917
2966
|
}
|
|
2967
|
+
startPullRequestTitle(command) {
|
|
2968
|
+
const op = command.operation;
|
|
2969
|
+
if (op.type !== "create" && op.type !== "set_target" || !op.pullRequestUrl) return Promise.resolve(void 0);
|
|
2970
|
+
return this.providers.pullRequestTitle?.(op.pullRequestUrl) ?? Promise.resolve(void 0);
|
|
2971
|
+
}
|
|
2918
2972
|
/** Reviews whose PR is this one, newest version first. Summaries only. */
|
|
2919
2973
|
reviewsForPullRequest(url) {
|
|
2920
2974
|
return this.db.prepare(`SELECT reviews.id FROM reviews
|
|
2921
2975
|
JOIN versions ON versions.review_id=reviews.id AND versions.version=reviews.version
|
|
2922
2976
|
WHERE lower(json_extract(versions.snapshot,'$.origin.pullRequestUrl'))=?
|
|
2923
|
-
AND COALESCE(json_extract(versions.snapshot,'$.origin.tutorial'), 0) = 0
|
|
2924
2977
|
ORDER BY json_extract(versions.snapshot,'$.createdAt') DESC, reviews.rowid DESC`).all(pullRequestKey(url)).map((row) => String(row.id));
|
|
2925
2978
|
}
|
|
2926
2979
|
assertReusableReview(reviewId) {
|
|
@@ -3087,7 +3140,7 @@ function inspectSnapshot(snapshot, targetId) {
|
|
|
3087
3140
|
}
|
|
3088
3141
|
//#endregion
|
|
3089
3142
|
//#region src/review-api/workspaces.ts
|
|
3090
|
-
const OWNED_ELSEWHERE = "Another
|
|
3143
|
+
const OWNED_ELSEWHERE = "Another Whiteboard server is managing this review's language workspaces. Retry once it stops.";
|
|
3091
3144
|
/** Local lifecycle only: source and authored history never depend on preparation.
|
|
3092
3145
|
* Status/queue/process lifecycle follows #334, retaining the legacy prepare config
|
|
3093
3146
|
* and per-review managed checkout layout instead of a new settings system.
|
|
@@ -3120,10 +3173,20 @@ var ReviewWorkspaces = class {
|
|
|
3120
3173
|
this.db.close();
|
|
3121
3174
|
throw error;
|
|
3122
3175
|
}
|
|
3123
|
-
|
|
3176
|
+
const stopCatalog = store.subscribeCatalog(() => {
|
|
3124
3177
|
this.collect();
|
|
3125
3178
|
this.releaseTrashed();
|
|
3126
3179
|
});
|
|
3180
|
+
const stopDeleted = store.subscribe(({ reviewId, deleted }) => {
|
|
3181
|
+
if (!deleted) return;
|
|
3182
|
+
const repositories = this.repositoryDirs();
|
|
3183
|
+
repositories.catch(() => void 0);
|
|
3184
|
+
this.release(reviewId, repositories, () => !this.hasReview(reviewId));
|
|
3185
|
+
});
|
|
3186
|
+
this.stop = () => {
|
|
3187
|
+
stopCatalog();
|
|
3188
|
+
stopDeleted();
|
|
3189
|
+
};
|
|
3127
3190
|
this.collect();
|
|
3128
3191
|
this.releaseTrashed();
|
|
3129
3192
|
}
|
|
@@ -3142,7 +3205,11 @@ var ReviewWorkspaces = class {
|
|
|
3142
3205
|
if (!released.length) return;
|
|
3143
3206
|
const repositories = this.repositoryDirs();
|
|
3144
3207
|
repositories.catch(() => void 0);
|
|
3145
|
-
for (const reviewId of released) this.release(reviewId, repositories);
|
|
3208
|
+
for (const reviewId of released) this.release(reviewId, repositories, () => this.stillTrashed(reviewId));
|
|
3209
|
+
}
|
|
3210
|
+
/** Restored since the move to Trash: its checkouts may be in use. */
|
|
3211
|
+
stillTrashed(reviewId) {
|
|
3212
|
+
return this.store.trashedIds().includes(reviewId);
|
|
3146
3213
|
}
|
|
3147
3214
|
async repositoryDirs() {
|
|
3148
3215
|
const dirs = new Set(this.all().map((item) => item.repository));
|
|
@@ -3156,21 +3223,21 @@ var ReviewWorkspaces = class {
|
|
|
3156
3223
|
released(reviewId) {
|
|
3157
3224
|
return this.releasing.get(reviewId) ?? Promise.resolve();
|
|
3158
3225
|
}
|
|
3159
|
-
release(reviewId, repositories
|
|
3226
|
+
release(reviewId, repositories, stillReleased) {
|
|
3160
3227
|
const requests = [...this.requests.values()];
|
|
3161
3228
|
const done = this.cleanup.then(async () => {
|
|
3162
3229
|
await Promise.allSettled(requests);
|
|
3163
|
-
await this.releaseCheckouts(reviewId, await repositories);
|
|
3230
|
+
await this.releaseCheckouts(reviewId, await repositories, stillReleased);
|
|
3164
3231
|
}).catch((error) => {
|
|
3165
|
-
console.error(`Could not free the pinned checkouts of
|
|
3232
|
+
console.error(`Could not free the pinned checkouts of review ${reviewId}:`, error);
|
|
3166
3233
|
}).finally(() => {
|
|
3167
3234
|
if (this.releasing.get(reviewId) === done) this.releasing.delete(reviewId);
|
|
3168
3235
|
});
|
|
3169
3236
|
this.releasing.set(reviewId, done);
|
|
3170
3237
|
this.cleanup = done;
|
|
3171
3238
|
}
|
|
3172
|
-
async releaseCheckouts(reviewId, repositories) {
|
|
3173
|
-
if (!
|
|
3239
|
+
async releaseCheckouts(reviewId, repositories, stillReleased) {
|
|
3240
|
+
if (!stillReleased()) return;
|
|
3174
3241
|
const environments = this.all().filter((item) => item.reviewId === reviewId);
|
|
3175
3242
|
const checkouts = repositories.filter((repository) => existsSync(reviewManagedCheckoutRoot(repository, reviewId)));
|
|
3176
3243
|
if (!environments.length && !checkouts.length || !this.claim(reviewId)) return;
|
|
@@ -3265,7 +3332,7 @@ var ReviewWorkspaces = class {
|
|
|
3265
3332
|
async retryCleanup(id) {
|
|
3266
3333
|
const environment = this.get(id);
|
|
3267
3334
|
if (!environment || environment.state !== "cleanup-failed") throw new ReviewInputError("Cleanup failure not found.", 404);
|
|
3268
|
-
if (this.store.has(environment.reviewId)) this.release(environment.reviewId);
|
|
3335
|
+
if (this.store.has(environment.reviewId)) this.release(environment.reviewId, this.repositoryDirs(), () => this.stillTrashed(environment.reviewId));
|
|
3269
3336
|
else this.collect(id);
|
|
3270
3337
|
await this.cleanup;
|
|
3271
3338
|
}
|
|
@@ -3439,6 +3506,7 @@ var ReviewWorkspaces = class {
|
|
|
3439
3506
|
]);
|
|
3440
3507
|
}
|
|
3441
3508
|
if (environment.rootPath) await removeReviewPrepareArtifacts(environment.rootPath);
|
|
3509
|
+
if (environment.repository && !this.all().some((other) => other.id !== environment.id && other.reviewId === environment.reviewId && other.repository === environment.repository)) await removeReviewManagedCheckouts(environment.repository, environment.reviewId);
|
|
3442
3510
|
this.db.prepare("DELETE FROM pinned_environments WHERE id=?").run(environment.id);
|
|
3443
3511
|
this.db.prepare("DELETE FROM workspace_leases WHERE review_id=? AND owner=? AND NOT EXISTS(SELECT 1 FROM pinned_environments WHERE value->>'reviewId'=?)").run(environment.reviewId, this.ownerId, environment.reviewId);
|
|
3444
3512
|
} catch (error) {
|
|
@@ -4215,11 +4283,12 @@ var LocalReviewData = class {
|
|
|
4215
4283
|
/** The PR's current comparison, fetched into a registered checkout of its repository. */
|
|
4216
4284
|
async resolvePullRequest(url, repository) {
|
|
4217
4285
|
const deps = this.options.pullRequests ?? defaultPullRequestDeps;
|
|
4218
|
-
const {
|
|
4219
|
-
const checkout = await this.pullRequestCheckout(
|
|
4220
|
-
const pullRequest = await readPullRequest(
|
|
4286
|
+
const { provider, address } = resolvePullRequest(url);
|
|
4287
|
+
const checkout = await this.pullRequestCheckout(provider, address, repository, deps);
|
|
4288
|
+
const pullRequest = await provider.readPullRequest(address, deps);
|
|
4221
4289
|
const { head, base } = await fetchPullRequest({
|
|
4222
4290
|
...checkout,
|
|
4291
|
+
provider: provider.id,
|
|
4223
4292
|
pullRequest
|
|
4224
4293
|
}, deps);
|
|
4225
4294
|
const repositoryId = checkout.repositoryId;
|
|
@@ -4235,11 +4304,20 @@ var LocalReviewData = class {
|
|
|
4235
4304
|
base,
|
|
4236
4305
|
head
|
|
4237
4306
|
},
|
|
4238
|
-
title: pullRequest.title.trim()
|
|
4307
|
+
title: pullRequest.title.trim()
|
|
4239
4308
|
};
|
|
4240
4309
|
}
|
|
4310
|
+
async pullRequestTitle(url) {
|
|
4311
|
+
const { provider, address } = resolvePullRequest(url);
|
|
4312
|
+
try {
|
|
4313
|
+
const { title } = await provider.readPullRequest(address, this.options.pullRequests ?? defaultPullRequestDeps);
|
|
4314
|
+
return title.trim() || void 0;
|
|
4315
|
+
} catch {
|
|
4316
|
+
return;
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4241
4319
|
/** A registered checkout with a remote for host/owner/repo, and that remote. */
|
|
4242
|
-
async pullRequestCheckout(
|
|
4320
|
+
async pullRequestCheckout(provider, address, repository, deps) {
|
|
4243
4321
|
const registered = this.store.repositories();
|
|
4244
4322
|
const candidates = repository.id ? registered.filter((entry) => entry.id === repository.id) : [...registered.filter((entry) => entry.id === repository.preferred), ...registered.filter((entry) => entry.id !== repository.preferred)];
|
|
4245
4323
|
if (repository.id && candidates.length === 0) throw new ReviewInputError("Repository is not registered.", 404);
|
|
@@ -4248,7 +4326,7 @@ var LocalReviewData = class {
|
|
|
4248
4326
|
const vcs = await this.vcs(id);
|
|
4249
4327
|
const gitDir = vcs && await gitCommonDir(vcs.rootPath);
|
|
4250
4328
|
if (!vcs || !gitDir) continue;
|
|
4251
|
-
const remote = (await
|
|
4329
|
+
const remote = (await remoteUrls(gitDir, deps)).find((entry) => provider.matchesRemote(entry.url, address));
|
|
4252
4330
|
if (remote) return {
|
|
4253
4331
|
repositoryId: id,
|
|
4254
4332
|
rootPath: vcs.rootPath,
|
|
@@ -4257,6 +4335,7 @@ var LocalReviewData = class {
|
|
|
4257
4335
|
remote: remote.name
|
|
4258
4336
|
};
|
|
4259
4337
|
}
|
|
4338
|
+
const { host, slug } = address;
|
|
4260
4339
|
const name = host === "github.com" ? slug : `${host}/${slug}`;
|
|
4261
4340
|
throw new ReviewInputError(repository.id ? `That checkout has no GitHub remote for ${name}. Add one, or omit repositoryId.` : `No registered checkout has a GitHub remote for ${name}. Register a checkout of ${name} with review_register_repository first, or pass a target.`, 404);
|
|
4262
4341
|
}
|
|
@@ -4656,6 +4735,7 @@ function openLocalReviewStore(databasePath, options = {}) {
|
|
|
4656
4735
|
projectSource: (snapshot, pins) => data.projectSource(snapshot, pins),
|
|
4657
4736
|
resolveTarget: (target, pinned) => data.resolveTarget(target, pinned),
|
|
4658
4737
|
resolvePullRequest: (url, repository) => data.resolvePullRequest(url, repository),
|
|
4738
|
+
pullRequestTitle: (url) => data.pullRequestTitle(url),
|
|
4659
4739
|
headBranch: (pins, headRef) => data.headBranch(pins, headRef),
|
|
4660
4740
|
sourcePins: (snapshot) => data.sourcePins(snapshot),
|
|
4661
4741
|
unavailableAnchors: (snapshot) => data.unavailableAnchors(snapshot),
|
|
@@ -4700,4 +4780,4 @@ async function readWorkspace(file) {
|
|
|
4700
4780
|
}
|
|
4701
4781
|
}
|
|
4702
4782
|
//#endregion
|
|
4703
|
-
export {
|
|
4783
|
+
export { activityUpdateSchema as _, inspectSnapshot as a, diffrMissingError as b, askAgentIds as c, askPicksSchema as d, askQuestionSchema as f, activityEndSchema as g, activityBeginSchema as h, commandSchema as i, askChoiceKinds as l, selectionMarkdown as m, uploadSchema as n, initializeReviewStoreSchema as o, AgentSelectionSchema as p, SCRATCHPAD_ID as r, applyAskChange as s, openLocalReviewStore as t, askPermissionsSchema as u, invalidateStructuralComparisons as v, diffrExecutable as y };
|