toolroll 0.9.128 → 0.9.130
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 +41 -0
- package/dist/accent-colors.js +3 -1
- package/dist/agent-fence.js +0 -2
- package/dist/agents-board.js +0 -3
- package/dist/approval-authority.js +2 -1
- package/dist/assignment.js +56 -2
- package/dist/backup-ui.js +6 -3
- package/dist/backup.js +6 -0
- package/dist/bounded-spawn.js +0 -1
- package/dist/browser/manifest.json +57 -0
- package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.br +0 -0
- package/dist/browser/terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js.gz +0 -0
- package/dist/browser/{terminal.css → terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css} +1 -1
- package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.br +0 -0
- package/dist/browser/terminal.4d1cf20c32ad7c2099df657358d540d5fd92bb55195a88121e74b28467238b42.css.gz +0 -0
- package/dist/browser/{workspace.js → workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js} +25 -25
- package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.br +0 -0
- package/dist/browser/workspace.9bd1db81d3c897045a5d82d4804e374e41e78b1b2cfd05d37b982a4ea0d02626.js.gz +0 -0
- package/dist/browser/{workspace.css → workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css} +1 -1
- package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.br +0 -0
- package/dist/browser/workspace.a0752f935cfeaf16758d1085fe8f3e1719a7cd525b91a9c9943c789d65879a54.css.gz +0 -0
- package/dist/browser-shell.js +271 -25
- package/dist/canvas-freshness.js +122 -0
- package/dist/canvas-fs.js +273 -0
- package/dist/canvas-reads.js +747 -0
- package/dist/canvas-state-key.js +45 -0
- package/dist/canvas-state-worker.js +12 -0
- package/dist/central-recovery-stage.js +3 -3
- package/dist/chat-actions.js +26 -0
- package/dist/chat-channel.js +4 -3
- package/dist/chat-task-actions.js +1 -1
- package/dist/chat-warmth.js +0 -1
- package/dist/check-report.js +0 -6
- package/dist/commit-extract.js +79 -40
- package/dist/companion/access.js +162 -0
- package/dist/companion/actions.js +622 -0
- package/dist/companion/bonjour.js +45 -0
- package/dist/companion/canvas.js +141 -0
- package/dist/companion/chat-origin.js +92 -0
- package/dist/companion/chat.js +571 -0
- package/dist/companion/daemon.js +1387 -0
- package/dist/companion/direct-server.js +177 -0
- package/dist/companion/finish.js +51 -0
- package/dist/companion/framing.js +498 -0
- package/dist/companion/noise.js +461 -0
- package/dist/companion/passkey-gate.js +287 -0
- package/dist/companion/paths.js +90 -0
- package/dist/companion/reads.js +283 -0
- package/dist/companion/relay-auth.js +265 -0
- package/dist/companion/relay-server.js +870 -0
- package/dist/companion/schema.js +289 -0
- package/dist/companion/service.js +581 -0
- package/dist/companion/store.js +325 -0
- package/dist/companion/webauthn.js +407 -0
- package/dist/console-instance.js +0 -4
- package/dist/contracts/console-api.js +18 -0
- package/dist/converse.js +0 -1
- package/dist/coordinator.js +1 -1
- package/dist/design/kit.css +30 -0
- package/dist/desktop-config.js +156 -0
- package/dist/desktop-host.js +6 -152
- package/dist/desktop-update.js +1 -1
- package/dist/finished-task-sql.js +14 -0
- package/dist/flexible-answers.js +0 -1
- package/dist/github-read.js +41 -0
- package/dist/guides.js +4 -3
- package/dist/lead-doors.js +50 -3
- package/dist/lead-queue-runtime.js +11 -2
- package/dist/lead-queue.js +25 -0
- package/dist/live-backup-change.js +93 -0
- package/dist/live-backup.js +75 -31
- package/dist/live-bus.js +3 -2
- package/dist/live-records.js +0 -1
- package/dist/local-landing.js +47 -0
- package/dist/local-owner.js +0 -1
- package/dist/model-choices.js +0 -11
- package/dist/nightly-check.js +0 -3
- package/dist/nightly-github.js +1 -2
- package/dist/notification-retention.js +119 -0
- package/dist/observations.js +0 -1
- package/dist/operate.js +17 -4
- package/dist/person-proof.js +5 -1
- package/dist/pull-request-flow.js +116 -2
- package/dist/qr.js +360 -0
- package/dist/release-adapters.js +14 -43
- package/dist/release-auto.js +17 -13
- package/dist/release-card.js +0 -4
- package/dist/release-cli.js +37 -2
- package/dist/release.js +13 -2
- package/dist/restore-retirement.js +6 -1
- package/dist/result-review.js +0 -3
- package/dist/retention-ui.js +1 -1
- package/dist/retention.js +14 -21
- package/dist/review-context.js +0 -5
- package/dist/route-rules.js +1 -5
- package/dist/sandbox-runtime.js +0 -1
- package/dist/scope.js +68 -17
- package/dist/scout.js +0 -6
- package/dist/serve.js +60 -9
- package/dist/server/kit.js +1 -0
- package/dist/server/live.js +9 -2
- package/dist/server/pages.js +12 -4
- package/dist/server/phone-engine-api.js +79 -0
- package/dist/server/render-pages.js +1 -11
- package/dist/server/render-results.js +0 -1
- package/dist/server/render-tasks.js +0 -68
- package/dist/server/route-table.js +12 -1
- package/dist/server/settings-phone.js +515 -0
- package/dist/server/settings-scripts.js +2 -0
- package/dist/server/settings-section-table.js +0 -3
- package/dist/server/settings-sections.js +10 -4
- package/dist/server/settings.js +20 -5
- package/dist/server/terminals.js +2 -1
- package/dist/settings-groups-ui.js +2 -1
- package/dist/settings-proofs.js +6 -0
- package/dist/store.js +52 -4
- package/dist/structured-output.js +0 -1
- package/dist/style-asset.js +20 -7
- package/dist/tailnet.js +39 -0
- package/dist/task-control.js +5 -0
- package/dist/task-sizing.js +0 -1
- package/dist/toolroll-update-cli.js +19 -3
- package/dist/toolroll-update-ui.js +2 -2
- package/dist/toolroll-update.js +98 -16
- package/dist/youiyoux-intake.js +8 -0
- package/package.json +7 -2
- package/dist/contracts/contract-test.js +0 -55
- package/dist/unfenced-test-support.js +0 -6
- /package/dist/browser/{terminal.js → terminal.2a682d0b91a35288271c73b7ee253e524cca0917d17fbaf6733e80b7a767a37c.js} +0 -0
|
@@ -14,6 +14,9 @@ import { NIGHTLY_CHECK_ONLY, RELEASE_MERGES_ONLY, nightlyTaskRef, refArchived, r
|
|
|
14
14
|
import { belongsToRelease } from "./release-authority.js";
|
|
15
15
|
import { autoReleaseSealed } from "./release-auto.js";
|
|
16
16
|
import { fullCheckGate, requestFollowUpChecks } from "./result-follow-ups.js";
|
|
17
|
+
import { checkPasskeyAction, consumePasskeyAction } from "./companion/passkey-gate.js";
|
|
18
|
+
import { getPasskeyChallenge } from "./companion/store.js";
|
|
19
|
+
import { canonicalJson, passkeyProofDetail, publishDestinationForRun } from "./companion/webauthn.js";
|
|
17
20
|
export const MERGE_METHODS = ["squash", "merge", "rebase"];
|
|
18
21
|
export const MAX_CI_REVISIONS = 2;
|
|
19
22
|
export const MERGED_ACTION = "pull request merged";
|
|
@@ -153,6 +156,9 @@ export function completeAndOpenPullRequest(store, input, now) {
|
|
|
153
156
|
const run = store.getRun(input.runId);
|
|
154
157
|
if (receipt.head !== null && receipt.head !== run.headRevision)
|
|
155
158
|
return refuse("stale", "This result's commit changed. Open the current result first.");
|
|
159
|
+
if (input.destination !== undefined && canonicalJson(publishDestinationForRun(store, input.runId)) !== canonicalJson(input.destination)) {
|
|
160
|
+
return refuse("changed", "Where this pull request would open changed since you reviewed it. Nothing was published.");
|
|
161
|
+
}
|
|
156
162
|
const completed = checkAssignmentAsOperator(store, input.taskId, input.digest, input.who, now, input.root);
|
|
157
163
|
if (!completed.ok)
|
|
158
164
|
return refuse(completed.reason, completed.message);
|
|
@@ -341,10 +347,77 @@ function askPerson(store, publication, head, body, clock) {
|
|
|
341
347
|
}, clock());
|
|
342
348
|
});
|
|
343
349
|
}
|
|
350
|
+
export const MERGE_PROVED_ACTION = "merge proved";
|
|
351
|
+
export const MERGED_ELSEWHERE_ACTION = "merged elsewhere";
|
|
344
352
|
export async function mergeAsPerson(store, input) {
|
|
345
353
|
const run = store.getRun(input.runId);
|
|
346
|
-
const
|
|
347
|
-
|
|
354
|
+
const taskRef = run === null ? null : store.refById(run.taskRef);
|
|
355
|
+
const repo = taskRef?.repo ?? null;
|
|
356
|
+
const clock = input.clock ?? (() => new Date());
|
|
357
|
+
if (input.passkey !== undefined) {
|
|
358
|
+
const publication = store.publicationForRun(input.runId);
|
|
359
|
+
const grant = repo === null ? null : store.publicationGrantFor(repo);
|
|
360
|
+
if (publication === null || publication.prNumber === null || taskRef === null) {
|
|
361
|
+
return refuse("no-pr", "This result has no open pull request to merge.");
|
|
362
|
+
}
|
|
363
|
+
const method = grant?.mergeMethod ?? "squash";
|
|
364
|
+
const passkey = input.passkey;
|
|
365
|
+
const bindingOf = (base) => ({ verb: "ship", runId: input.runId, taskId: taskRef.externalId, prNumber: publication.prNumber,
|
|
366
|
+
headSha: publication.headSha, method, anyway: input.anyway === true, githubRepo: publication.githubRepo, base });
|
|
367
|
+
const row = getPasskeyChallenge(store.handle, passkey.challenge);
|
|
368
|
+
const bound = row === null ? null : JSON.parse(row.bindingJson).base;
|
|
369
|
+
const early = checkPasskeyAction(store, { accountName: input.name, repo, verb: "ship", expectedBinding: bindingOf(typeof bound === "string" ? bound : ""), proof: passkey, now: clock() });
|
|
370
|
+
if (!early.ok)
|
|
371
|
+
return refuse(early.code === "binding_mismatch" ? "changed" : "password", early.message);
|
|
372
|
+
const signed = { base: typeof bound === "string" ? bound : "", head: publication.headSha };
|
|
373
|
+
const merged = await mergePullRequest(store, {
|
|
374
|
+
runId: input.runId,
|
|
375
|
+
by: input.name,
|
|
376
|
+
...(input.anyway === true ? { anyway: true } : {}),
|
|
377
|
+
...(input.exec === undefined ? {} : { exec: input.exec }),
|
|
378
|
+
...(input.clock === undefined ? {} : { clock: input.clock }),
|
|
379
|
+
destination: seen => seen.base !== signed.base
|
|
380
|
+
? `It merged into ${seen.base ?? "another branch"}, not ${signed.base}: the pull request's base changed on GitHub.`
|
|
381
|
+
: seen.head !== signed.head ? `It merged at ${(seen.head ?? "another commit").slice(0, 7)}, not the approved ${signed.head.slice(0, 7)}.` : null,
|
|
382
|
+
beforeReserve: seen => {
|
|
383
|
+
if (seen.head !== publication.headSha)
|
|
384
|
+
return { ok: false, message: "The pull request head moved before merging." };
|
|
385
|
+
const expectedBinding = bindingOf(seen.base ?? "");
|
|
386
|
+
const checked = checkPasskeyAction(store, { accountName: input.name, repo, verb: "ship", expectedBinding, proof: passkey, now: clock() });
|
|
387
|
+
if (!checked.ok)
|
|
388
|
+
return { ok: false, message: checked.message, ...(checked.code === "binding_mismatch" ? { reason: "changed" } : {}) };
|
|
389
|
+
const now = clock();
|
|
390
|
+
const consumed = consumePasskeyAction(store, checked, { repo, now });
|
|
391
|
+
if (!consumed.ok)
|
|
392
|
+
return { ok: false, message: consumed.message };
|
|
393
|
+
store.recordAction({
|
|
394
|
+
at: now.toISOString(),
|
|
395
|
+
actor: input.name,
|
|
396
|
+
repo,
|
|
397
|
+
taskId: taskRef.externalId,
|
|
398
|
+
runId: input.runId,
|
|
399
|
+
action: MERGE_PROVED_ACTION,
|
|
400
|
+
outcome: "passkey",
|
|
401
|
+
source: "request",
|
|
402
|
+
detail: passkeyProofDetail({
|
|
403
|
+
at: now,
|
|
404
|
+
generation: consumed.accountGeneration,
|
|
405
|
+
digest: publication.headSha,
|
|
406
|
+
verb: "ship",
|
|
407
|
+
credentialId: consumed.credentialId,
|
|
408
|
+
pairedDeviceId: consumed.deviceId,
|
|
409
|
+
be: consumed.be,
|
|
410
|
+
bs: consumed.bs,
|
|
411
|
+
}),
|
|
412
|
+
});
|
|
413
|
+
return { ok: true };
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
if (!merged.ok && merged.reason === "elsewhere")
|
|
417
|
+
recordMergedElsewhere(store, { publication, taskId: taskRef.externalId, repo, by: input.name, words: merged.message }, clock());
|
|
418
|
+
return merged;
|
|
419
|
+
}
|
|
420
|
+
if (input.password === undefined || input.password === "")
|
|
348
421
|
return refuse("password", "Enter your password to merge.");
|
|
349
422
|
const proved = authenticateApprover(store, input.name, input.password, repo);
|
|
350
423
|
if (!proved.ok)
|
|
@@ -447,6 +520,8 @@ export async function mergePullRequest(store, input) {
|
|
|
447
520
|
return fail("checks", before.checks === "failing" ? "Checks are failing, so it can't merge." : before.checks === "running" ? "Checks are still running. Merge once they pass." : "No checks have reported yet. Merge once they pass.");
|
|
448
521
|
const token = randomUUID();
|
|
449
522
|
let reserved;
|
|
523
|
+
let passkeyRefusedMsg = "Passkey verification failed.";
|
|
524
|
+
let passkeyRefusedReason = "password";
|
|
450
525
|
try {
|
|
451
526
|
reserved = store.transact(() => {
|
|
452
527
|
if (fullCheckGate(store, publication.run, clock()).state === "recovery-held")
|
|
@@ -464,6 +539,14 @@ export async function mergePullRequest(store, input) {
|
|
|
464
539
|
const reservedAt = clock();
|
|
465
540
|
if (fullCheckGate(store, publication.run, reservedAt).state === "recovery-held")
|
|
466
541
|
throw new RecoveryHeldReservation();
|
|
542
|
+
if (input.beforeReserve !== undefined) {
|
|
543
|
+
const check = input.beforeReserve({ base: before.base, url: before.url, head: before.head });
|
|
544
|
+
if (!check.ok) {
|
|
545
|
+
passkeyRefusedMsg = check.message;
|
|
546
|
+
passkeyRefusedReason = check.reason ?? "password";
|
|
547
|
+
return "passkey-refused";
|
|
548
|
+
}
|
|
549
|
+
}
|
|
467
550
|
store.handle.prepare("INSERT OR REPLACE INTO merge_in_flight (publication, task_ref, token, by, at) VALUES (?, ?, ?, ?, ?)").run(publication.id, publication.taskRef, token, input.by, reservedAt.toISOString());
|
|
468
551
|
return "ok";
|
|
469
552
|
});
|
|
@@ -473,6 +556,8 @@ export async function mergePullRequest(store, input) {
|
|
|
473
556
|
return refuse("recovery-held", "Checks are on hold after recovery. Earlier execution is unverified.");
|
|
474
557
|
throw error;
|
|
475
558
|
}
|
|
559
|
+
if (reserved === "passkey-refused")
|
|
560
|
+
return refuse(passkeyRefusedReason, passkeyRefusedMsg);
|
|
476
561
|
if (reserved === "recovery-held")
|
|
477
562
|
return refuse("recovery-held", "Checks are on hold after recovery. Earlier execution is unverified.");
|
|
478
563
|
if (reserved === "halted")
|
|
@@ -500,6 +585,8 @@ export async function mergePullRequest(store, input) {
|
|
|
500
585
|
}
|
|
501
586
|
if (merged.code === 4)
|
|
502
587
|
return fail("gh-signed-out", "The GitHub CLI isn't signed in on this computer. Run gh auth login, then merge again.");
|
|
588
|
+
if (after === null)
|
|
589
|
+
return fail("unconfirmed", "GitHub couldn't be read after the merge ran, so whether it merged isn't known yet. Refresh before trying again.");
|
|
503
590
|
return fail("refused", `GitHub didn't merge it: ${plain(firstLine(merged.stderr) || "no reason given", 200)}`);
|
|
504
591
|
}
|
|
505
592
|
export function pullRequestViewOf(store, runId) {
|
|
@@ -507,11 +594,16 @@ export function pullRequestViewOf(store, runId) {
|
|
|
507
594
|
const follow = publication === null ? null : followOf(store, publication.id);
|
|
508
595
|
if (publication === null || follow === null)
|
|
509
596
|
return null;
|
|
597
|
+
const elsewhere = follow.mergeCommit !== null ? undefined
|
|
598
|
+
: store.handle.prepare("SELECT detail FROM action_ledger WHERE run_id = ? AND action = ? ORDER BY id DESC LIMIT 1").get(runId, MERGED_ELSEWHERE_ACTION);
|
|
510
599
|
const grant = store.publicationGrantFor(store.refById(publication.taskRef)?.repo ?? "");
|
|
511
600
|
const method = follow.mergeMethod ?? grant?.mergeMethod ?? "squash";
|
|
512
601
|
const gate = fullCheckGate(store, runId, new Date());
|
|
513
602
|
const fullCheck = gate.state === "clear" ? null : gate;
|
|
514
603
|
const base = { runId, prNumber: publication.prNumber, prUrl: publication.prUrl, mergeCommit: follow.mergeCommit || null, mergeMethod: method, canMerge: false, revisionTask: follow.revisionTask, fullCheck };
|
|
604
|
+
if (elsewhere !== undefined) {
|
|
605
|
+
return { ...base, state: "failed", label: "Merged into another branch", detail: `${String(elsewhere["detail"] ?? "It merged somewhere it wasn't approved for.")} Check it on GitHub.` };
|
|
606
|
+
}
|
|
515
607
|
const error = follow.mergeError === null ? "" : ` Last merge attempt: ${follow.mergeError}`;
|
|
516
608
|
if (follow.mergeCommit !== null) {
|
|
517
609
|
return { ...base, state: "merged", label: "Merged", detail: follow.mergedBy === null || follow.mergedBy === "GitHub" ? "Merged on GitHub." : `Merged by ${follow.mergedBy}${follow.mergeMethod === null ? "" : ` (${follow.mergeMethod})`}. Branch deleted.` };
|
|
@@ -554,3 +646,25 @@ export function newestPullRequestOf(store, versions) {
|
|
|
554
646
|
export const MERGE_NEEDS_PERSON = "Only a person can merge. Merge it on the task page or from your paired chat.";
|
|
555
647
|
class RecoveryHeldReservation extends Error {
|
|
556
648
|
}
|
|
649
|
+
export async function pullRequestOnGitHub(publication, exec = execRun) {
|
|
650
|
+
if (publication.prNumber === null)
|
|
651
|
+
return null;
|
|
652
|
+
const viewed = await exec("gh", ["pr", "view", String(publication.prNumber), "--repo", publication.githubRepo, "--json", "state,headRefOid,baseRefName,url"], { timeoutMs: EXEC_TIMEOUT_MS });
|
|
653
|
+
if (viewed.code !== 0)
|
|
654
|
+
return null;
|
|
655
|
+
try {
|
|
656
|
+
const payload = JSON.parse(viewed.stdout);
|
|
657
|
+
return { state: String(payload.state ?? "").toUpperCase(), head: typeof payload.headRefOid === "string" ? payload.headRefOid : null,
|
|
658
|
+
base: typeof payload.baseRefName === "string" ? payload.baseRefName : null, url: typeof payload.url === "string" ? payload.url : null };
|
|
659
|
+
}
|
|
660
|
+
catch {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function recordMergedElsewhere(store, input, now) {
|
|
665
|
+
store.transact(() => {
|
|
666
|
+
updateFollow(store, input.publication.id, { merge_error: input.words.slice(0, 300) }, now);
|
|
667
|
+
store.recordAction({ at: now.toISOString(), actor: input.by, repo: input.repo, taskId: input.taskId, runId: input.publication.run, action: MERGED_ELSEWHERE_ACTION,
|
|
668
|
+
outcome: "needs-person", source: "work", detail: input.words });
|
|
669
|
+
});
|
|
670
|
+
}
|
package/dist/qr.js
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
const ECC_ORDINAL = { L: 0, M: 1, Q: 2, H: 3 };
|
|
2
|
+
const ECC_FORMAT_BITS = { L: 1, M: 0, Q: 3, H: 2 };
|
|
3
|
+
const ECC_CODEWORDS_PER_BLOCK = [
|
|
4
|
+
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
5
|
+
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
6
|
+
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
7
|
+
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
8
|
+
];
|
|
9
|
+
const NUM_ERROR_CORRECTION_BLOCKS = [
|
|
10
|
+
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
11
|
+
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
12
|
+
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
13
|
+
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81],
|
|
14
|
+
];
|
|
15
|
+
const PENALTY_N1 = 3, PENALTY_N2 = 3, PENALTY_N3 = 40, PENALTY_N4 = 10;
|
|
16
|
+
export function encodeQr(data, ecc = "M") {
|
|
17
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
18
|
+
let version = 1;
|
|
19
|
+
let dataUsedBits = 0;
|
|
20
|
+
for (;; version++) {
|
|
21
|
+
const capacityBits = numDataCodewords(version, ecc) * 8;
|
|
22
|
+
dataUsedBits = 4 + (version <= 9 ? 8 : 16) + bytes.length * 8;
|
|
23
|
+
if (dataUsedBits <= capacityBits)
|
|
24
|
+
break;
|
|
25
|
+
if (version >= 40)
|
|
26
|
+
throw new RangeError("Data too long for a QR code");
|
|
27
|
+
}
|
|
28
|
+
let level = ecc;
|
|
29
|
+
for (const better of ["M", "Q", "H"]) {
|
|
30
|
+
if (ECC_ORDINAL[better] > ECC_ORDINAL[level] && dataUsedBits <= numDataCodewords(version, better) * 8)
|
|
31
|
+
level = better;
|
|
32
|
+
}
|
|
33
|
+
const bits = [];
|
|
34
|
+
appendBits(bits, 0x4, 4);
|
|
35
|
+
appendBits(bits, bytes.length, version <= 9 ? 8 : 16);
|
|
36
|
+
for (const b of bytes)
|
|
37
|
+
appendBits(bits, b, 8);
|
|
38
|
+
const capacityBits = numDataCodewords(version, level) * 8;
|
|
39
|
+
appendBits(bits, 0, Math.min(4, capacityBits - bits.length));
|
|
40
|
+
appendBits(bits, 0, (8 - (bits.length % 8)) % 8);
|
|
41
|
+
for (let pad = 0xec; bits.length < capacityBits; pad ^= 0xec ^ 0x11)
|
|
42
|
+
appendBits(bits, pad, 8);
|
|
43
|
+
const dataCodewords = new Array(bits.length / 8).fill(0);
|
|
44
|
+
bits.forEach((bit, i) => { dataCodewords[i >>> 3] = (dataCodewords[i >>> 3] ?? 0) | (bit << (7 - (i & 7))); });
|
|
45
|
+
const symbol = new QrSymbol(version, level);
|
|
46
|
+
symbol.drawFunctionPatterns();
|
|
47
|
+
symbol.drawCodewords(symbol.addEccAndInterleave(dataCodewords));
|
|
48
|
+
let bestMask = 0, minPenalty = Infinity;
|
|
49
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
50
|
+
symbol.applyMask(mask);
|
|
51
|
+
symbol.drawFormatBits(mask);
|
|
52
|
+
const penalty = symbol.penaltyScore();
|
|
53
|
+
if (penalty < minPenalty) {
|
|
54
|
+
bestMask = mask;
|
|
55
|
+
minPenalty = penalty;
|
|
56
|
+
}
|
|
57
|
+
symbol.applyMask(mask);
|
|
58
|
+
}
|
|
59
|
+
symbol.applyMask(bestMask);
|
|
60
|
+
symbol.drawFormatBits(bestMask);
|
|
61
|
+
const modules = symbol.modules, size = symbol.size;
|
|
62
|
+
return { version, size, ecc: level, mask: bestMask, dark: (x, y) => x >= 0 && y >= 0 && x < size && y < size && modules[y][x] };
|
|
63
|
+
}
|
|
64
|
+
function appendBits(out, value, length) {
|
|
65
|
+
for (let i = length - 1; i >= 0; i--)
|
|
66
|
+
out.push((value >>> i) & 1);
|
|
67
|
+
}
|
|
68
|
+
function numRawDataModules(version) {
|
|
69
|
+
let result = (16 * version + 128) * version + 64;
|
|
70
|
+
if (version >= 2) {
|
|
71
|
+
const numAlign = Math.floor(version / 7) + 2;
|
|
72
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
73
|
+
if (version >= 7)
|
|
74
|
+
result -= 36;
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
function numDataCodewords(version, ecc) {
|
|
79
|
+
const o = ECC_ORDINAL[ecc];
|
|
80
|
+
return Math.floor(numRawDataModules(version) / 8) - ECC_CODEWORDS_PER_BLOCK[o][version] * NUM_ERROR_CORRECTION_BLOCKS[o][version];
|
|
81
|
+
}
|
|
82
|
+
function rsMultiply(x, y) {
|
|
83
|
+
let z = 0;
|
|
84
|
+
for (let i = 7; i >= 0; i--) {
|
|
85
|
+
z = (z << 1) ^ ((z >>> 7) * 0x11d);
|
|
86
|
+
z ^= ((y >>> i) & 1) * x;
|
|
87
|
+
}
|
|
88
|
+
return z & 0xff;
|
|
89
|
+
}
|
|
90
|
+
function rsDivisor(degree) {
|
|
91
|
+
const result = new Array(degree).fill(0);
|
|
92
|
+
result[degree - 1] = 1;
|
|
93
|
+
let root = 1;
|
|
94
|
+
for (let i = 0; i < degree; i++) {
|
|
95
|
+
for (let j = 0; j < result.length; j++) {
|
|
96
|
+
result[j] = rsMultiply(result[j], root);
|
|
97
|
+
if (j + 1 < result.length)
|
|
98
|
+
result[j] = result[j] ^ result[j + 1];
|
|
99
|
+
}
|
|
100
|
+
root = rsMultiply(root, 0x02);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
function rsRemainder(data, divisor) {
|
|
105
|
+
const result = divisor.map(() => 0);
|
|
106
|
+
for (const b of data) {
|
|
107
|
+
const factor = b ^ result.shift();
|
|
108
|
+
result.push(0);
|
|
109
|
+
divisor.forEach((coef, i) => { result[i] = result[i] ^ rsMultiply(coef, factor); });
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
class QrSymbol {
|
|
114
|
+
version;
|
|
115
|
+
ecc;
|
|
116
|
+
size;
|
|
117
|
+
modules;
|
|
118
|
+
isFunction;
|
|
119
|
+
constructor(version, ecc) {
|
|
120
|
+
this.version = version;
|
|
121
|
+
this.ecc = ecc;
|
|
122
|
+
this.size = version * 4 + 17;
|
|
123
|
+
this.modules = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
124
|
+
this.isFunction = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
125
|
+
}
|
|
126
|
+
set(x, y, dark) {
|
|
127
|
+
this.modules[y][x] = dark;
|
|
128
|
+
this.isFunction[y][x] = true;
|
|
129
|
+
}
|
|
130
|
+
drawFunctionPatterns() {
|
|
131
|
+
for (let i = 0; i < this.size; i++) {
|
|
132
|
+
this.set(6, i, i % 2 === 0);
|
|
133
|
+
this.set(i, 6, i % 2 === 0);
|
|
134
|
+
}
|
|
135
|
+
this.drawFinder(3, 3);
|
|
136
|
+
this.drawFinder(this.size - 4, 3);
|
|
137
|
+
this.drawFinder(3, this.size - 4);
|
|
138
|
+
const align = this.alignmentPositions(), n = align.length;
|
|
139
|
+
for (let i = 0; i < n; i++)
|
|
140
|
+
for (let j = 0; j < n; j++) {
|
|
141
|
+
if (!((i === 0 && j === 0) || (i === 0 && j === n - 1) || (i === n - 1 && j === 0)))
|
|
142
|
+
this.drawAlignment(align[i], align[j]);
|
|
143
|
+
}
|
|
144
|
+
this.drawFormatBits(0);
|
|
145
|
+
this.drawVersion();
|
|
146
|
+
}
|
|
147
|
+
drawFormatBits(mask) {
|
|
148
|
+
const data = (ECC_FORMAT_BITS[this.ecc] << 3) | mask;
|
|
149
|
+
let rem = data;
|
|
150
|
+
for (let i = 0; i < 10; i++)
|
|
151
|
+
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
152
|
+
const bits = ((data << 10) | rem) ^ 0x5412;
|
|
153
|
+
const bit = (i) => ((bits >>> i) & 1) !== 0;
|
|
154
|
+
for (let i = 0; i <= 5; i++)
|
|
155
|
+
this.set(8, i, bit(i));
|
|
156
|
+
this.set(8, 7, bit(6));
|
|
157
|
+
this.set(8, 8, bit(7));
|
|
158
|
+
this.set(7, 8, bit(8));
|
|
159
|
+
for (let i = 9; i < 15; i++)
|
|
160
|
+
this.set(14 - i, 8, bit(i));
|
|
161
|
+
for (let i = 0; i < 8; i++)
|
|
162
|
+
this.set(this.size - 1 - i, 8, bit(i));
|
|
163
|
+
for (let i = 8; i < 15; i++)
|
|
164
|
+
this.set(8, this.size - 15 + i, bit(i));
|
|
165
|
+
this.set(8, this.size - 8, true);
|
|
166
|
+
}
|
|
167
|
+
drawVersion() {
|
|
168
|
+
if (this.version < 7)
|
|
169
|
+
return;
|
|
170
|
+
let rem = this.version;
|
|
171
|
+
for (let i = 0; i < 12; i++)
|
|
172
|
+
rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
|
|
173
|
+
const bits = (this.version << 12) | rem;
|
|
174
|
+
for (let i = 0; i < 18; i++) {
|
|
175
|
+
const dark = ((bits >>> i) & 1) !== 0, a = this.size - 11 + (i % 3), b = Math.floor(i / 3);
|
|
176
|
+
this.set(a, b, dark);
|
|
177
|
+
this.set(b, a, dark);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
drawFinder(x, y) {
|
|
181
|
+
for (let dy = -4; dy <= 4; dy++)
|
|
182
|
+
for (let dx = -4; dx <= 4; dx++) {
|
|
183
|
+
const dist = Math.max(Math.abs(dx), Math.abs(dy)), xx = x + dx, yy = y + dy;
|
|
184
|
+
if (xx >= 0 && xx < this.size && yy >= 0 && yy < this.size)
|
|
185
|
+
this.set(xx, yy, dist !== 2 && dist !== 4);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
drawAlignment(x, y) {
|
|
189
|
+
for (let dy = -2; dy <= 2; dy++)
|
|
190
|
+
for (let dx = -2; dx <= 2; dx++)
|
|
191
|
+
this.set(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
192
|
+
}
|
|
193
|
+
alignmentPositions() {
|
|
194
|
+
if (this.version === 1)
|
|
195
|
+
return [];
|
|
196
|
+
const numAlign = Math.floor(this.version / 7) + 2;
|
|
197
|
+
const step = this.version === 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
|
|
198
|
+
const result = [6];
|
|
199
|
+
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
|
|
200
|
+
result.splice(1, 0, pos);
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
addEccAndInterleave(data) {
|
|
204
|
+
const o = ECC_ORDINAL[this.ecc];
|
|
205
|
+
const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[o][this.version];
|
|
206
|
+
const blockEccLen = ECC_CODEWORDS_PER_BLOCK[o][this.version];
|
|
207
|
+
const rawCodewords = Math.floor(numRawDataModules(this.version) / 8);
|
|
208
|
+
const numShortBlocks = numBlocks - (rawCodewords % numBlocks);
|
|
209
|
+
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
210
|
+
const blocks = [];
|
|
211
|
+
const divisor = rsDivisor(blockEccLen);
|
|
212
|
+
for (let i = 0, k = 0; i < numBlocks; i++) {
|
|
213
|
+
const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
|
|
214
|
+
k += dat.length;
|
|
215
|
+
const ecc = rsRemainder(dat, divisor);
|
|
216
|
+
if (i < numShortBlocks)
|
|
217
|
+
dat.push(0);
|
|
218
|
+
blocks.push(dat.concat(ecc));
|
|
219
|
+
}
|
|
220
|
+
const result = [];
|
|
221
|
+
for (let i = 0; i < blocks[0].length; i++) {
|
|
222
|
+
blocks.forEach((block, j) => {
|
|
223
|
+
if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks)
|
|
224
|
+
result.push(block[i]);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
drawCodewords(data) {
|
|
230
|
+
let i = 0;
|
|
231
|
+
for (let right = this.size - 1; right >= 1; right -= 2) {
|
|
232
|
+
if (right === 6)
|
|
233
|
+
right = 5;
|
|
234
|
+
for (let vert = 0; vert < this.size; vert++) {
|
|
235
|
+
for (let j = 0; j < 2; j++) {
|
|
236
|
+
const x = right - j, upward = ((right + 1) & 2) === 0, y = upward ? this.size - 1 - vert : vert;
|
|
237
|
+
if (!this.isFunction[y][x] && i < data.length * 8) {
|
|
238
|
+
this.modules[y][x] = ((data[i >>> 3] >>> (7 - (i & 7))) & 1) !== 0;
|
|
239
|
+
i++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
applyMask(mask) {
|
|
246
|
+
for (let y = 0; y < this.size; y++)
|
|
247
|
+
for (let x = 0; x < this.size; x++) {
|
|
248
|
+
let invert;
|
|
249
|
+
switch (mask) {
|
|
250
|
+
case 0:
|
|
251
|
+
invert = (x + y) % 2 === 0;
|
|
252
|
+
break;
|
|
253
|
+
case 1:
|
|
254
|
+
invert = y % 2 === 0;
|
|
255
|
+
break;
|
|
256
|
+
case 2:
|
|
257
|
+
invert = x % 3 === 0;
|
|
258
|
+
break;
|
|
259
|
+
case 3:
|
|
260
|
+
invert = (x + y) % 3 === 0;
|
|
261
|
+
break;
|
|
262
|
+
case 4:
|
|
263
|
+
invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
|
|
264
|
+
break;
|
|
265
|
+
case 5:
|
|
266
|
+
invert = ((x * y) % 2) + ((x * y) % 3) === 0;
|
|
267
|
+
break;
|
|
268
|
+
case 6:
|
|
269
|
+
invert = (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
270
|
+
break;
|
|
271
|
+
default:
|
|
272
|
+
invert = (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
if (!this.isFunction[y][x] && invert)
|
|
276
|
+
this.modules[y][x] = !this.modules[y][x];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
penaltyScore() {
|
|
280
|
+
let result = 0;
|
|
281
|
+
const size = this.size, m = this.modules;
|
|
282
|
+
for (let y = 0; y < size; y++) {
|
|
283
|
+
let runColor = false, runX = 0;
|
|
284
|
+
const history = [0, 0, 0, 0, 0, 0, 0];
|
|
285
|
+
for (let x = 0; x < size; x++) {
|
|
286
|
+
if (m[y][x] === runColor) {
|
|
287
|
+
runX++;
|
|
288
|
+
if (runX === 5)
|
|
289
|
+
result += PENALTY_N1;
|
|
290
|
+
else if (runX > 5)
|
|
291
|
+
result++;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
this.finderHistoryAdd(runX, history);
|
|
295
|
+
if (!runColor)
|
|
296
|
+
result += this.finderPenaltyCount(history) * PENALTY_N3;
|
|
297
|
+
runColor = m[y][x];
|
|
298
|
+
runX = 1;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
result += this.finderTerminate(runColor, runX, history) * PENALTY_N3;
|
|
302
|
+
}
|
|
303
|
+
for (let x = 0; x < size; x++) {
|
|
304
|
+
let runColor = false, runY = 0;
|
|
305
|
+
const history = [0, 0, 0, 0, 0, 0, 0];
|
|
306
|
+
for (let y = 0; y < size; y++) {
|
|
307
|
+
if (m[y][x] === runColor) {
|
|
308
|
+
runY++;
|
|
309
|
+
if (runY === 5)
|
|
310
|
+
result += PENALTY_N1;
|
|
311
|
+
else if (runY > 5)
|
|
312
|
+
result++;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
this.finderHistoryAdd(runY, history);
|
|
316
|
+
if (!runColor)
|
|
317
|
+
result += this.finderPenaltyCount(history) * PENALTY_N3;
|
|
318
|
+
runColor = m[y][x];
|
|
319
|
+
runY = 1;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
result += this.finderTerminate(runColor, runY, history) * PENALTY_N3;
|
|
323
|
+
}
|
|
324
|
+
for (let y = 0; y < size - 1; y++)
|
|
325
|
+
for (let x = 0; x < size - 1; x++) {
|
|
326
|
+
const c = m[y][x];
|
|
327
|
+
if (c === m[y][x + 1] && c === m[y + 1][x] && c === m[y + 1][x + 1])
|
|
328
|
+
result += PENALTY_N2;
|
|
329
|
+
}
|
|
330
|
+
let dark = 0;
|
|
331
|
+
for (const row of m)
|
|
332
|
+
for (const v of row)
|
|
333
|
+
if (v)
|
|
334
|
+
dark++;
|
|
335
|
+
const total = size * size;
|
|
336
|
+
const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
|
|
337
|
+
result += k * PENALTY_N4;
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
finderPenaltyCount(h) {
|
|
341
|
+
const n = h[1];
|
|
342
|
+
const core = n > 0 && h[2] === n && h[3] === n * 3 && h[4] === n && h[5] === n;
|
|
343
|
+
return (core && h[0] >= n * 4 && h[6] >= n ? 1 : 0) + (core && h[6] >= n * 4 && h[0] >= n ? 1 : 0);
|
|
344
|
+
}
|
|
345
|
+
finderTerminate(runColor, run, history) {
|
|
346
|
+
if (runColor) {
|
|
347
|
+
this.finderHistoryAdd(run, history);
|
|
348
|
+
run = 0;
|
|
349
|
+
}
|
|
350
|
+
run += this.size;
|
|
351
|
+
this.finderHistoryAdd(run, history);
|
|
352
|
+
return this.finderPenaltyCount(history);
|
|
353
|
+
}
|
|
354
|
+
finderHistoryAdd(run, history) {
|
|
355
|
+
if (history[0] === 0)
|
|
356
|
+
run += this.size;
|
|
357
|
+
history.pop();
|
|
358
|
+
history.unshift(run);
|
|
359
|
+
}
|
|
360
|
+
}
|
package/dist/release-adapters.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { existsSync, lstatSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync } from "node:fs";
|
|
4
4
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -24,6 +24,7 @@ import { CHECK_REPORT_CAPTURE, readSealedJson } from "./check-report.js";
|
|
|
24
24
|
import { readCheckReport } from "./contracts/release-check.js";
|
|
25
25
|
import { macosCases, skipCoverage, skippedCases, uncoveredWords } from "./fenced-check-coverage.js";
|
|
26
26
|
import { runCheckStamp } from "./store.js";
|
|
27
|
+
import { runtimeVersionAt } from "./toolroll-update.js";
|
|
27
28
|
import { noteCiRunning, releaseCiHoldOf, releaseCiRunningOf } from "./release-ci-hold.js";
|
|
28
29
|
import { autoPublishHeld, holdAutoPublish, liftCiHold, authorizeAutoCheck, giveUpAutoApproval, noteAutoCheckFailed, noteAutoRelease, releaseAutoApproves, sealAutoGreen } from "./release-auto.js";
|
|
29
30
|
import { proveCarry } from "./release-carry.js";
|
|
@@ -37,19 +38,9 @@ export { failedBeforeTests } from "./github-jobs.js";
|
|
|
37
38
|
import { extractCommit } from "./commit-extract.js";
|
|
38
39
|
import { teardownGit, refusal as gitRefusal } from "./teardown-git.js";
|
|
39
40
|
import { RELEASE_REMOTE, releaseConfigProblem, releaseGitArgs, releaseGitEnv, releaseRemote, releaseTools } from "./release-git.js";
|
|
41
|
+
import { ciEnv, exec, githubReads } from "./github-read.js";
|
|
42
|
+
export { exec, githubReads } from "./github-read.js";
|
|
40
43
|
export { RELEASE_PATH, RELEASE_REMOTE, releaseConfigProblem, releaseGitArgs, releaseGitEnv, releaseRemote, releaseTools } from "./release-git.js";
|
|
41
|
-
export const exec = (command, args, options = {}) => new Promise(done => {
|
|
42
|
-
const child = execFile(command, [...args], { cwd: options.cwd, env: options.env ?? process.env, timeout: options.timeoutMs ?? 120_000, maxBuffer: 64 * 1024 * 1024, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
43
|
-
const failure = error;
|
|
44
|
-
const code = failure === null ? 0 : failure.code === "ENOENT" ? 127 : failure.killed === true ? 124 : typeof failure.code === "number" ? failure.code : 1;
|
|
45
|
-
done({ code, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
|
|
46
|
-
});
|
|
47
|
-
child.stdin?.on("error", () => { });
|
|
48
|
-
if (options.input !== undefined)
|
|
49
|
-
child.stdin?.end(options.input);
|
|
50
|
-
else
|
|
51
|
-
child.stdin?.end();
|
|
52
|
-
});
|
|
53
44
|
const ownCli = () => {
|
|
54
45
|
const bin = join(dirname(fileURLToPath(import.meta.url)), "bin.js");
|
|
55
46
|
return existsSync(bin) ? [process.execPath, bin] : ["toolroll"];
|
|
@@ -438,7 +429,11 @@ export function releaseAdapters(options) {
|
|
|
438
429
|
},
|
|
439
430
|
},
|
|
440
431
|
toolroll: {
|
|
441
|
-
async installed() {
|
|
432
|
+
async installed() {
|
|
433
|
+
const services = serviceRuntimes(), clis = cliRuntimes();
|
|
434
|
+
const versions = Object.fromEntries([...services, ...clis.flatMap(one => one.runtime === null ? [] : [one.runtime])].map(dist => [dist, runtimeVersionAt(dist)]));
|
|
435
|
+
return { services, clis, versions };
|
|
436
|
+
},
|
|
442
437
|
async runtimeCommit(runtime) {
|
|
443
438
|
try {
|
|
444
439
|
const candidate = object(JSON.parse(readFileSync(join(runtime, "..", "..", "..", "package.json"), "utf8")))["candidate"];
|
|
@@ -1056,10 +1051,6 @@ function autoReleaseAdapter(withStore, now, auto) {
|
|
|
1056
1051
|
async publishHeld(taskId) { return withStore(store => autoPublishHeld(store, taskId)); },
|
|
1057
1052
|
};
|
|
1058
1053
|
}
|
|
1059
|
-
function ciEnv() {
|
|
1060
|
-
const kept = Object.fromEntries(["HOME", "LANG", "LC_ALL", "TMPDIR", "USER", "LOGNAME", "GH_TOKEN", "GITHUB_TOKEN"].flatMap(name => process.env[name] === undefined ? [] : [[name, process.env[name]]]));
|
|
1061
|
-
return { ...kept, PATH: "/usr/bin:/bin", GH_HOST: "github.com", GH_PROMPT_DISABLED: "1", GH_NO_UPDATE_NOTIFIER: "1" };
|
|
1062
|
-
}
|
|
1063
1054
|
export async function readCheckRuns(run, gh, repo, sha, options = {}) {
|
|
1064
1055
|
if (options.tag !== undefined && !/^v\d+\.\d+\.\d+$/.test(options.tag))
|
|
1065
1056
|
throw new Error("not a release tag");
|
|
@@ -1070,14 +1061,15 @@ export async function readCheckRuns(run, gh, repo, sha, options = {}) {
|
|
|
1070
1061
|
const flows = await must(run(gh, ["api", "--hostname", "github.com", "--paginate", `repos/${repo}/actions/runs?head_sha=${sha}&per_page=100`,
|
|
1071
1062
|
"--jq", ".workflow_runs[] | {suite: .check_suite_id, workflow: .workflow_id, path: .path, head: .head_sha, event: .event, branch: .head_branch, bases: [(.pull_requests // [])[] | .base.ref], prs: [(.pull_requests // [])[] | {number, repo: .base.repo.url}]}"], { cwd: "/", env: ciEnv() }), "gh api actions/runs");
|
|
1072
1063
|
const retargeted = new Map();
|
|
1064
|
+
const RETARGET_EVENTS = new Set(["base_ref_changed", "automatic_base_change_succeeded", "automatic_base_change_failed"]);
|
|
1073
1065
|
const everRetargeted = async (pr) => {
|
|
1074
1066
|
const known = retargeted.get(pr);
|
|
1075
1067
|
if (known !== undefined)
|
|
1076
1068
|
return known;
|
|
1077
1069
|
let changed = true;
|
|
1078
1070
|
try {
|
|
1079
|
-
const
|
|
1080
|
-
changed = events.code !== 0 || events.stdout.split("\n").some(line => line.trim()
|
|
1071
|
+
const reads = await Promise.all(["timeline", "events"].map(kind => run(gh, ["api", "--hostname", "github.com", "--paginate", `repos/${repo}/issues/${pr}/${kind}?per_page=100`, "--jq", ".[] | .event"], { cwd: "/", env: ciEnv() })));
|
|
1072
|
+
changed = reads.some(events => events.code !== 0 || events.stdout.split("\n").some(line => RETARGET_EVENTS.has(line.trim())));
|
|
1081
1073
|
}
|
|
1082
1074
|
catch {
|
|
1083
1075
|
changed = true;
|
|
@@ -1145,28 +1137,6 @@ export async function readJobBeforeTests(run, gh, repo, id) {
|
|
|
1145
1137
|
return failedBeforeTests({ id, status: String(job["status"]), conclusion: textOr(job["conclusion"]),
|
|
1146
1138
|
steps: steps.map(one => ({ number: Number(one["number"]), name: String(one["name"]), status: String(one["status"]), conclusion: textOr(one["conclusion"]) })) });
|
|
1147
1139
|
}
|
|
1148
|
-
export function githubReads(run, gh, options = {}) {
|
|
1149
|
-
return async (path, timeoutMs) => {
|
|
1150
|
-
if (!/^repos\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_./?&=%-]+$/.test(path) || timeoutMs <= 0)
|
|
1151
|
-
return { ok: false, why: "not a read this makes" };
|
|
1152
|
-
const exec = options.retry === true ? retryingExec(run, { say: () => { }, sleep, budgetMs: timeoutMs }) : run;
|
|
1153
|
-
let result;
|
|
1154
|
-
try {
|
|
1155
|
-
result = await exec(gh, ["api", "--hostname", "github.com", "--method", "GET", path], { cwd: "/", env: ciEnv(), timeoutMs });
|
|
1156
|
-
}
|
|
1157
|
-
catch (error) {
|
|
1158
|
-
return { ok: false, why: String(error?.message ?? error).slice(0, 200) };
|
|
1159
|
-
}
|
|
1160
|
-
if (result.code !== 0)
|
|
1161
|
-
return { ok: false, why: result.code === 124 ? "GitHub didn't answer in time" : result.code === 127 ? "gh isn't installed" : (result.stderr || result.stdout).trim().split("\n").slice(-1)[0].slice(0, 200) || `gh exited ${result.code}` };
|
|
1162
|
-
try {
|
|
1163
|
-
return { ok: true, body: JSON.parse(result.stdout) };
|
|
1164
|
-
}
|
|
1165
|
-
catch {
|
|
1166
|
-
return { ok: false, why: "GitHub's answer couldn't be read" };
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
}
|
|
1170
1140
|
export const CHECK_SUITE_CEILING = 1000;
|
|
1171
1141
|
export async function readSuitesComplete(run, gh, repo, sha) {
|
|
1172
1142
|
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) || !/^[0-9a-f]{40}$/.test(sha))
|
|
@@ -1423,7 +1393,8 @@ async function macosCasesOf(run, gh, slug, sha) {
|
|
|
1423
1393
|
}
|
|
1424
1394
|
export function githubJson(run, gh) {
|
|
1425
1395
|
return async (path) => {
|
|
1426
|
-
|
|
1396
|
+
const compare = /^repos\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/compare\/(?:[0-9a-f]{40}|v\d+\.\d+\.\d+)\.\.\.[0-9a-f]{40}(?:\?per_page=\d+)?$/.test(path);
|
|
1397
|
+
if (!/^repos\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_./?&=%:+-]+$/.test(path) || (path.includes("..") && !compare))
|
|
1427
1398
|
throw new Error(`not a GitHub read this makes: ${path.slice(0, 120)}`);
|
|
1428
1399
|
const out = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", path], { cwd: "/", env: ciEnv() });
|
|
1429
1400
|
if (out.code !== 0)
|