toolroll 0.9.117 → 0.9.119
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 +42 -0
- package/README.md +14 -14
- package/dist/agent-fence.js +54 -6
- package/dist/assignment.js +40 -29
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +32 -31
- package/dist/builder.js +295 -237
- package/dist/central-recovery-stage.js +3 -3
- package/dist/check-failure.js +2 -2
- package/dist/check-levels.js +3 -0
- package/dist/check-report.js +58 -7
- package/dist/coding-context.js +16 -2
- package/dist/coding-provider.js +7 -3
- package/dist/coding-workspace.js +5 -5
- package/dist/contracts/console-api.js +4 -1
- package/dist/contracts/engine-api.js +1 -0
- package/dist/contracts/release-check.js +7 -4
- package/dist/contracts/release-terms.js +11 -2
- package/dist/contracts/verification-receipt.js +1 -1
- package/dist/deploy-gate.js +7 -1
- package/dist/direct-chat.js +3 -3
- package/dist/easy-start.js +8 -6
- package/dist/engine-reads.js +72 -0
- package/dist/flexible-conversation-schema.js +24 -0
- package/dist/flexible-conversation.js +162 -0
- package/dist/flexible-custody.js +3 -0
- package/dist/flexible-import.js +51 -0
- package/dist/flexible-session.js +84 -11
- package/dist/install-mode.js +1 -1
- package/dist/invoke.js +18 -6
- package/dist/local-landing.js +500 -0
- package/dist/local-owner.js +1 -0
- package/dist/operate.js +143 -22
- package/dist/passwordless.js +1 -1
- package/dist/planner.js +6 -1
- package/dist/project-delete.js +1 -0
- package/dist/project-skills.js +28 -13
- package/dist/rehearsal.js +27 -0
- package/dist/release-adapters.js +170 -2
- package/dist/release-approval.js +11 -8
- package/dist/release-card.js +7 -2
- package/dist/release-carry.js +1 -1
- package/dist/release-cli.js +115 -14
- package/dist/release-main-proof.js +49 -0
- package/dist/release-main.js +110 -0
- package/dist/release-recheck.js +10 -3
- package/dist/release.js +221 -33
- package/dist/reply-shape.js +6 -1
- package/dist/result-actions.js +7 -1
- package/dist/result-follow-ups.js +8 -4
- package/dist/scout.js +6 -2
- package/dist/serve.js +31 -14
- package/dist/server/direct-chat.js +88 -3
- package/dist/server/engine-api.js +43 -5
- package/dist/server/render-results.js +3 -1
- package/dist/server/render-tasks.js +10 -1
- package/dist/server/route-table.js +9 -0
- package/dist/server/settings.js +31 -7
- package/dist/server/task-views.js +15 -0
- package/dist/server/tasks.js +63 -3
- package/dist/settings-groups-ui.js +2 -2
- package/dist/skills-manifest.js +57 -0
- package/dist/store.js +29 -4
- package/dist/surface.js +9 -1
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/verification-evidence.js +17 -6
- package/dist/workspace-ui.js +1 -1
- package/package.json +3 -2
- package/scripts/release-proof.mjs +240 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
export const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
3
|
+
export const releaseBranchFor = (version) => `release-${version}`;
|
|
4
|
+
export const mainJournalFile = (stateDir, version) => join(stateDir, "releases", "from-main", `${version}.json`);
|
|
5
|
+
export const mainRunKey = (version) => `from-main:${version}`;
|
|
6
|
+
export const mainResumeCommand = (version, checkout) => `toolroll release ${version} --repo ${checkout}`;
|
|
7
|
+
export function sameRelease(held, read) {
|
|
8
|
+
if (read.sha !== held.sha)
|
|
9
|
+
return `the release commit is now ${read.sha.slice(0, 7)}, not ${held.sha.slice(0, 7)}`;
|
|
10
|
+
if (read.tree !== held.tree)
|
|
11
|
+
return `${held.sha.slice(0, 7)}'s tree is now ${read.tree.slice(0, 12)}, not ${held.tree.slice(0, 12)}`;
|
|
12
|
+
if (read.pr !== held.pr)
|
|
13
|
+
return `${held.sha.slice(0, 7)} is now pull request #${read.pr}'s merge, not #${held.pr}'s`;
|
|
14
|
+
if (read.head !== held.head || read.branch !== held.branch)
|
|
15
|
+
return `pull request #${held.pr}'s tested head is now ${read.branch} at ${read.head.slice(0, 7)}, not ${held.branch} at ${held.head.slice(0, 7)}`;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export function firstParentAfter(head, sha, parents) {
|
|
19
|
+
const after = [];
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
for (let at = head; at !== undefined; at = parents.get(at)?.[0]) {
|
|
22
|
+
if (at === sha)
|
|
23
|
+
return after;
|
|
24
|
+
if (seen.has(at) || !parents.has(at))
|
|
25
|
+
return null;
|
|
26
|
+
seen.add(at);
|
|
27
|
+
after.push(at);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function versionSpan(text, from, value) {
|
|
32
|
+
const pattern = /"version"\s*:\s*"/g;
|
|
33
|
+
pattern.lastIndex = from;
|
|
34
|
+
const found = pattern.exec(text);
|
|
35
|
+
if (found === null)
|
|
36
|
+
return null;
|
|
37
|
+
const start = found.index + found[0].length;
|
|
38
|
+
if (text.slice(start, start + value.length + 1) !== `${value}"`)
|
|
39
|
+
return null;
|
|
40
|
+
return { start, end: start + value.length };
|
|
41
|
+
}
|
|
42
|
+
function strictJson(text) {
|
|
43
|
+
let value;
|
|
44
|
+
try {
|
|
45
|
+
value = JSON.parse(text);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
51
|
+
return null;
|
|
52
|
+
const tokens = (source) => JSON.stringify(source.match(/"(?:\\.|[^"\\])*"|[^\s"{}[\]:,]+|[{}[\]:,]/g));
|
|
53
|
+
return tokens(text) === tokens(JSON.stringify(value)) ? value : null;
|
|
54
|
+
}
|
|
55
|
+
export function bumpVersion(file, text, from, to) {
|
|
56
|
+
if (!VERSION_PATTERN.test(to) || !VERSION_PATTERN.test(from))
|
|
57
|
+
return null;
|
|
58
|
+
const before = strictJson(text);
|
|
59
|
+
if (before === null || before["version"] !== from)
|
|
60
|
+
return null;
|
|
61
|
+
const spans = [];
|
|
62
|
+
const first = versionSpan(text, 0, from);
|
|
63
|
+
if (first === null)
|
|
64
|
+
return null;
|
|
65
|
+
spans.push(first);
|
|
66
|
+
if (file === "package-lock.json") {
|
|
67
|
+
const packages = before["packages"];
|
|
68
|
+
if (packages?.[""]?.["version"] !== from)
|
|
69
|
+
return null;
|
|
70
|
+
const second = versionSpan(text, first.end, from);
|
|
71
|
+
if (second === null)
|
|
72
|
+
return null;
|
|
73
|
+
spans.push(second);
|
|
74
|
+
}
|
|
75
|
+
let out = text;
|
|
76
|
+
for (const span of [...spans].reverse())
|
|
77
|
+
out = `${out.slice(0, span.start)}${to}${out.slice(span.end)}`;
|
|
78
|
+
const after = strictJson(out);
|
|
79
|
+
if (after === null || after["version"] !== to)
|
|
80
|
+
return null;
|
|
81
|
+
const strip = (value) => {
|
|
82
|
+
const copy = structuredClone(value);
|
|
83
|
+
delete copy["version"];
|
|
84
|
+
const root = copy["packages"]?.[""];
|
|
85
|
+
if (file === "package-lock.json" && root !== undefined)
|
|
86
|
+
delete root["version"];
|
|
87
|
+
return JSON.stringify(copy);
|
|
88
|
+
};
|
|
89
|
+
if (strip(before) !== strip(after))
|
|
90
|
+
return null;
|
|
91
|
+
if (file === "package-lock.json" && after["packages"][""]?.["version"] !== to)
|
|
92
|
+
return null;
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
export function changelogWith(text, version, notes, date) {
|
|
96
|
+
const heading = `## ${version} — ${date}`;
|
|
97
|
+
const entry = `${heading}\n\n${notes.trim()}\n\n`;
|
|
98
|
+
const at = text.search(/^## /m);
|
|
99
|
+
return at === -1 ? `${text.replace(/\s*$/, "\n\n")}${entry}` : `${text.slice(0, at)}${entry}${text.slice(at)}`;
|
|
100
|
+
}
|
|
101
|
+
export function changelogHas(text, version) {
|
|
102
|
+
return new RegExp(`^## ${version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}( |$)`, "m").test(text);
|
|
103
|
+
}
|
|
104
|
+
export const HARNESS_PATTERNS = [
|
|
105
|
+
/^\.github\/workflows\//, /^scripts\/(?:ci-|release-proof|release-check|gate-|guard-|browser-build|suite-lifecycle|upgrade-rule)/, /^vitest\.config\.ts$/,
|
|
106
|
+
/^test\/(?:setup|setup-state|ensure-build)\b/, /^package(?:-lock)?\.json$/, /^tsconfig[^/]*\.json$/, /^scripts\/gate-files\.json$/,
|
|
107
|
+
];
|
|
108
|
+
export function harnessChanges(changed) {
|
|
109
|
+
return changed.filter(path => HARNESS_PATTERNS.some(pattern => pattern.test(path)));
|
|
110
|
+
}
|
package/dist/release-recheck.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { purposeCheckMode } from "./contracts/release-terms.js";
|
|
2
|
+
import { CHECK_CONTEXT_CAPTURE, CHECK_INVENTORY_CAPTURE, CHECK_REPORT_CAPTURE, OBLIGATION_SNAPSHOT_CAPTURE, TARGETED_PLAN_CAPTURE, checkContextOf, deployCheckProblem, fullCheckProblem, isUnitFile, payloadDigest, projectGitDir, readSealedJson, treeFactsOf } from "./check-report.js";
|
|
2
3
|
import { readVerifiedCommit, verifiedTreeDiff } from "./commit-extract.js";
|
|
3
|
-
import { checkContextSchema, fileIdentity, groupIdentity, journeyIdentity, obligationSnapshotSchema, readCheckReport, sealedInventorySchema, targetedPlanSchema, unitIdentity, versionIdentity, } from "./contracts/release-check.js";
|
|
4
|
+
import { checkContextSchema, fileIdentity, groupIdentity, journeyIdentity, obligationSnapshotSchema, readCheckReport, sealedInventorySchema, targetedPlanSchema, unitIdentity, versionIdentity, CHECK_PARTS, } from "./contracts/release-check.js";
|
|
4
5
|
import { parseContract } from "./contracts/contract.js";
|
|
5
6
|
import { releaseAuthority, releaseAuthorityOfTask, releaseCarries } from "./release-authority.js";
|
|
6
7
|
import { liveReleaseOf, releaseCheckScope } from "./scope.js";
|
|
@@ -244,7 +245,7 @@ export function planTargetedRecheck(store, root, input) {
|
|
|
244
245
|
return full("the check runs somewhere other than the last full check did", watch);
|
|
245
246
|
if (base.inventory.sealed.units.some(file => !facts.facts.units.includes(file)))
|
|
246
247
|
return full("a unit file the last full check had is gone", watch);
|
|
247
|
-
const journeysRan = base.report.parts.filter(one => one.ran).map(one => one.part);
|
|
248
|
+
const journeysRan = base.report.parts.filter(one => one.ran).map(one => one.part).filter((part) => CHECK_PARTS.includes(part));
|
|
248
249
|
const plan = planFrom(base.run, { ...obligations, required: [...new Set([...obligations.required, ...owed])].sort(),
|
|
249
250
|
units: [...new Set([...obligations.units, ...owed.flatMap(id => /^unit:(.+?)::/.exec(id)?.[1] ?? /^file:(.+)$/.exec(id)?.[1] ?? [])])].sort() }, snapshot, changed, facts.facts.units, journeysRan);
|
|
250
251
|
return { mode: "targeted", authority: a.id, plan, snapshot, watch: plan.required };
|
|
@@ -414,6 +415,12 @@ export function settleCoverage(store, root, input, gateOf) {
|
|
|
414
415
|
}
|
|
415
416
|
return { coverage: "identity-removed", composed: null };
|
|
416
417
|
};
|
|
418
|
+
if (b.attempt.mode === "full" && b.inventory?.sealed.deploy === true) {
|
|
419
|
+
const purpose = store.getScope(input.taskId)?.releaseCheck ?? null;
|
|
420
|
+
if (purposeCheckMode(purpose) !== "deploy" || deployCheckProblem({ report: b.report, inventory: b.inventory, exitCode: input.exitCode }) !== null)
|
|
421
|
+
return { coverage: "no-result", composed: null };
|
|
422
|
+
return { coverage: "deploy", composed: null };
|
|
423
|
+
}
|
|
417
424
|
if (b.attempt.mode === "full") {
|
|
418
425
|
if (b.attempt.authority !== null) {
|
|
419
426
|
const watch = owedIdentities(store, root, b.attempt.authority, input.runId);
|
package/dist/release.js
CHANGED
|
@@ -4,6 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { personProof } from "./person-proof.js";
|
|
5
5
|
import { RELEASE_CI_RUNNING_WORDS as CI_RUNNING_WORDS } from "./release-ci-hold.js";
|
|
6
6
|
import { transientFailure } from "./release-net.js";
|
|
7
|
+
import { changelogHas, harnessChanges, mainJournalFile, mainResumeCommand, releaseBranchFor, sameRelease, VERSION_PATTERN } from "./release-main.js";
|
|
7
8
|
export const REQUIRED_PR_CHECKS = [
|
|
8
9
|
"node 24 · ubuntu-latest",
|
|
9
10
|
"linux native containment · delegated cgroup v2",
|
|
@@ -159,8 +160,9 @@ export function tagChecksVerdict(runs) {
|
|
|
159
160
|
return checksVerdict(runs.filter(run => names.includes(run.name) && run.app === "github-actions" && workflowIs(run.workflowPath, RELEASE_TAG_WORKFLOW)), RELEASE_TAG_CHECKS);
|
|
160
161
|
}
|
|
161
162
|
export async function runRelease(options, adapters) {
|
|
162
|
-
const
|
|
163
|
-
const
|
|
163
|
+
const fromMain = options.version !== undefined;
|
|
164
|
+
const file = fromMain ? mainJournalFile(options.stateDir, options.version) : journalFile(options.stateDir, options.branch);
|
|
165
|
+
const resume = fromMain ? mainResumeCommand(options.version, options.checkout) : resumeCommand(options.branch, options.checkout);
|
|
164
166
|
const limits = { ...RELEASE_LIMITS, ...options.limits };
|
|
165
167
|
const pollMs = options.pollMs ?? POLL_MS;
|
|
166
168
|
const say = adapters.say;
|
|
@@ -231,6 +233,8 @@ export async function runRelease(options, adapters) {
|
|
|
231
233
|
try {
|
|
232
234
|
journal = readJournal(file);
|
|
233
235
|
if (journal !== null && options.fresh === true && journal.step !== "done") {
|
|
236
|
+
if (journal.mode === "main" && (journal.intents.tag !== undefined || journal.tagged !== null))
|
|
237
|
+
throw new Stop("tagging", `The release of ${journal.candidate.sha.slice(0, 7)} already began tagging ${journal.tag}; finish it with \`${resume}\` instead of starting over.`);
|
|
234
238
|
if (journal.intents.merge !== undefined)
|
|
235
239
|
throw new Stop("merging", `The release of ${journal.candidate.sha.slice(0, 7)} already began merging; finish it with \`${resume}\` instead of starting over.`);
|
|
236
240
|
await recoverDeploy();
|
|
@@ -250,8 +254,10 @@ export async function runRelease(options, adapters) {
|
|
|
250
254
|
const finishingHomebrew = journal !== null && journal.step === "homebrew" && journal.published !== null && options.fresh !== true;
|
|
251
255
|
if (!await adapters.github.authenticated())
|
|
252
256
|
throw new Stop("github-auth", "GitHub CLI is not signed in: run `gh auth login`, then rerun.");
|
|
257
|
+
let provenNow = false;
|
|
253
258
|
if (journal === null) {
|
|
254
|
-
journal = await begin(options, adapters, adapters.now());
|
|
259
|
+
journal = fromMain ? await beginMain(options, adapters, adapters.now()) : await begin(options, adapters, adapters.now());
|
|
260
|
+
provenNow = fromMain;
|
|
255
261
|
if (freshApproval || journal.candidate.sha === stoppedCheck) {
|
|
256
262
|
const base = journal.task.id;
|
|
257
263
|
const suffix = supersededTask === null ? null : supersededTask === base ? 1 : supersededTask.startsWith(`${base}-`) ? Number(supersededTask.slice(base.length + 1)) : null;
|
|
@@ -272,6 +278,11 @@ export async function runRelease(options, adapters) {
|
|
|
272
278
|
else
|
|
273
279
|
say(`Resuming the release of ${journal.tag} (${journal.candidate.sha.slice(0, 7)}) at ${journal.step}.`);
|
|
274
280
|
const j = journal;
|
|
281
|
+
if ((j.mode === "main") !== fromMain)
|
|
282
|
+
throw new Stop("usage", j.mode === "main" ? `This journal is the release of ${j.packageVersion} from main: run \`${mainResumeCommand(j.packageVersion, j.checkout)}\`.` : `This journal is a branch release; run \`${resumeCommand(j.branch, j.checkout)}\`.`);
|
|
283
|
+
const isMain = j.mode === "main";
|
|
284
|
+
if (isMain && j.full !== true && options.full === true)
|
|
285
|
+
throw new Stop("usage", `The release of ${j.packageVersion} was filed with the deploy check; to run the full check instead, start it again with \`toolroll release ${j.packageVersion} --full --new\`.`);
|
|
275
286
|
if (j.ciAhead === true && j.ciBeforeDeploy !== true)
|
|
276
287
|
j.ciBeforeDeploy = true;
|
|
277
288
|
if (j.checkout !== options.checkout)
|
|
@@ -487,8 +498,54 @@ export async function runRelease(options, adapters) {
|
|
|
487
498
|
if (!answer.ok)
|
|
488
499
|
throw new Stop("nightly-debt", `${answer.why} Nothing was ${phase === "deploy" ? "deployed" : phase === "merge" ? "merged" : "tagged or published"}; rerun the release once it passes.`);
|
|
489
500
|
};
|
|
490
|
-
const watch = async (action) => {
|
|
491
|
-
|
|
501
|
+
const watch = async (action) => {
|
|
502
|
+
if (isMain) {
|
|
503
|
+
if (await adapters.repo.github() !== j.github)
|
|
504
|
+
throw new Stop("drift", `The release's repository is no longer ${j.github}.`);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (rel !== undefined)
|
|
508
|
+
await identity(action, true);
|
|
509
|
+
};
|
|
510
|
+
const mainProof = async (nothing) => {
|
|
511
|
+
try {
|
|
512
|
+
return await proveMain(nothing);
|
|
513
|
+
}
|
|
514
|
+
catch (error) {
|
|
515
|
+
if (j.task.scopeDigest !== null && rel?.proofFailed !== undefined) {
|
|
516
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
517
|
+
await rel.proofFailed({ taskId: j.task.id, version: j.packageVersion, why: why.slice(0, 280) });
|
|
518
|
+
}
|
|
519
|
+
throw error;
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const proveMain = async (nothing) => {
|
|
523
|
+
const main = adapters.github.main;
|
|
524
|
+
if (main === undefined)
|
|
525
|
+
throw new Stop("usage", "This build of Toolroll can't release from main.");
|
|
526
|
+
const short = j.candidate.sha.slice(0, 7);
|
|
527
|
+
const proven = await main.prove(j.github, j.candidate.sha);
|
|
528
|
+
if (!proven.ok)
|
|
529
|
+
throw new Stop("proof", mainProofWords(j.packageVersion, short, proven.why, nothing));
|
|
530
|
+
const drift = sameRelease({ sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch }, proven);
|
|
531
|
+
if (drift !== null)
|
|
532
|
+
throw new Stop("drift", `${drift}. ${nothing}; this release stays bound to what it was approved for. Start it again with \`toolroll release ${j.packageVersion} --new\`.`);
|
|
533
|
+
const placed = await main.firstParent(j.github, j.candidate.sha);
|
|
534
|
+
if (!placed.ok)
|
|
535
|
+
throw new Stop("drift", `${short} is no longer on main's history (${placed.why}): main was rewritten or the commit removed. ${nothing}.`);
|
|
536
|
+
const verdict = prChecksVerdict(await adapters.github.checks(j.github, j.main.head), j.main.head, REQUIRED_PR_CHECKS, { workflow: REQUIRED_PR_CHECKS_WORKFLOW });
|
|
537
|
+
if (verdict.state !== "passed")
|
|
538
|
+
throw new Stop("ci-failed", mainProofWords(j.packageVersion, short, `the checks on pull request #${j.pr}'s head ${j.main.head.slice(0, 7)} aren't all passing: ${(verdict.state === "failed" ? verdict.failed : verdict.waiting).join(", ")}`, nothing));
|
|
539
|
+
if (j.task.scopeDigest !== null)
|
|
540
|
+
await rel?.proved?.({ taskId: j.task.id, version: j.packageVersion, proof: { sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch } });
|
|
541
|
+
if (placed.after.join() !== j.main.after.join()) {
|
|
542
|
+
j.main = { ...j.main, after: placed.after };
|
|
543
|
+
save();
|
|
544
|
+
}
|
|
545
|
+
if (placed.after.length > 0)
|
|
546
|
+
say(` ${placed.after.length} later commit${placed.after.length === 1 ? "" : "s"} on main go${placed.after.length === 1 ? "es" : ""} in the next release`);
|
|
547
|
+
return placed.after;
|
|
548
|
+
};
|
|
492
549
|
const updateFromMain = async () => {
|
|
493
550
|
const update = adapters.github.updateBranch;
|
|
494
551
|
if (update === undefined)
|
|
@@ -614,11 +671,22 @@ export async function runRelease(options, adapters) {
|
|
|
614
671
|
if (!owner.ok)
|
|
615
672
|
throw new Stop("approval", `Task ${j.task.id}: ${owner.why}. An active approver must approve the release scope.`);
|
|
616
673
|
};
|
|
674
|
+
const checkFailed = (input) => isMain
|
|
675
|
+
? `The ${j.full === true ? "full release check" : "deploy check"} of ${j.candidate.sha.slice(0, 7)} failed (run ${input.run}): ${input.why}. Nothing was deployed, tagged or published; Toolroll here is unchanged. Fix it on main, merge a release pull request for ${j.packageVersion} again, then run \`toolroll release ${j.packageVersion} --new\`.`
|
|
676
|
+
: checkFailedWords({ sha: j.candidate.sha, ...input, branch: j.branch, checkout: j.checkout, taskId: j.task.id });
|
|
617
677
|
const fullCheck = (gate) => {
|
|
618
678
|
if (gate.result?.level !== "full")
|
|
619
679
|
throw new Stop("check-level", `A Full check is required for this release (run ${gate.result?.run ?? "unknown"}: ${gate.result?.level ?? "unknown"}). Quick and Off checks cannot release a build.`);
|
|
620
680
|
if (gate.result.check !== "passed")
|
|
621
|
-
throw new Stop("check-failed",
|
|
681
|
+
throw new Stop("check-failed", checkFailed({ run: gate.result.run, class: null, why: `its check reads ${gate.result.check}` }));
|
|
682
|
+
if (isMain) {
|
|
683
|
+
const coverage = gate.result.coverage ?? null;
|
|
684
|
+
const wanted = j.full === true ? ["full"] : ["deploy", "full"];
|
|
685
|
+
if (coverage === null || !wanted.includes(coverage))
|
|
686
|
+
throw new Stop("check-level", `Run ${gate.result.run}'s check of ${j.candidate.sha.slice(0, 7)} covered ${coverage ?? "something this Toolroll doesn't name"}, not the ${j.full === true ? "full release check" : "deploy check"} this release was approved for. Update Toolroll here, then run \`toolroll release ${j.packageVersion} --new\`.`);
|
|
687
|
+
}
|
|
688
|
+
else if (gate.result.coverage === "deploy")
|
|
689
|
+
throw new Stop("check-level", `Run ${gate.result.run} ran only the deploy check, which releases from main alone may use.`);
|
|
622
690
|
};
|
|
623
691
|
const builtHead = () => j.check?.head ?? j.candidate.sha;
|
|
624
692
|
const checked = async (gate, action = "dispatch") => {
|
|
@@ -637,7 +705,12 @@ export async function runRelease(options, adapters) {
|
|
|
637
705
|
try {
|
|
638
706
|
switch (j.step) {
|
|
639
707
|
case "gate": {
|
|
640
|
-
|
|
708
|
+
if (isMain) {
|
|
709
|
+
if (!provenNow)
|
|
710
|
+
await mainProof("Nothing was checked, deployed, tagged or published");
|
|
711
|
+
}
|
|
712
|
+
else
|
|
713
|
+
await pinned();
|
|
641
714
|
if (rel !== undefined && j.freshTask !== true) {
|
|
642
715
|
const base = gateTaskId(j.packageVersion, j.candidate.sha);
|
|
643
716
|
for (let n = 1; n < 50; n++) {
|
|
@@ -652,19 +725,21 @@ export async function runRelease(options, adapters) {
|
|
|
652
725
|
}
|
|
653
726
|
}
|
|
654
727
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
728
|
+
if (!isMain) {
|
|
729
|
+
try {
|
|
730
|
+
await containsMain(adapters, j, "Nothing was filed or sent for approval");
|
|
731
|
+
}
|
|
732
|
+
catch (error) {
|
|
733
|
+
if (!(error instanceof Stop) || error.reason !== "base-moved")
|
|
734
|
+
throw error;
|
|
735
|
+
const head = await updateFromMain();
|
|
736
|
+
if (head === null)
|
|
737
|
+
throw error;
|
|
738
|
+
throw new Restart(head, true);
|
|
739
|
+
}
|
|
740
|
+
if (j.intents.gate === undefined)
|
|
741
|
+
await mainProtection(adapters, j, false, "Nothing was filed or sent for approval");
|
|
665
742
|
}
|
|
666
|
-
if (j.intents.gate === undefined)
|
|
667
|
-
await mainProtection(adapters, j, false, "Nothing was filed or sent for approval");
|
|
668
743
|
const existing = await adapters.toolroll.gate(j.task.id);
|
|
669
744
|
if (existing.exists && j.freshTask === true && j.intents.gate === undefined)
|
|
670
745
|
throw new Stop("approval", `Task ${j.task.id} appeared before this release filed it; rerun with --new.`);
|
|
@@ -674,7 +749,7 @@ export async function runRelease(options, adapters) {
|
|
|
674
749
|
j.task.scopeDigest = existing.scopeDigest;
|
|
675
750
|
}
|
|
676
751
|
else {
|
|
677
|
-
const settled = await earlyChecks(adapters, j, (what, probe) => waitFor("gate", what, probe), { pendingIsEnough: true, seen: (runs, verdict) => noteCi(runs, verdict) });
|
|
752
|
+
const settled = isMain ? true : await earlyChecks(adapters, j, (what, probe) => waitFor("gate", what, probe), { pendingIsEnough: true, seen: (runs, verdict) => noteCi(runs, verdict) });
|
|
678
753
|
if (!settled)
|
|
679
754
|
await rel?.auto?.ciRunning?.(j.task.id, j.candidate.sha);
|
|
680
755
|
j.ciAhead = !settled;
|
|
@@ -686,13 +761,21 @@ export async function runRelease(options, adapters) {
|
|
|
686
761
|
}
|
|
687
762
|
intend("gate");
|
|
688
763
|
await adapters.repo.sync(j.branch);
|
|
689
|
-
const filed = await adapters.toolroll.fileGate({
|
|
764
|
+
const filed = await adapters.toolroll.fileGate(isMain ? {
|
|
765
|
+
taskId: j.task.id, title: `Release ${j.packageVersion}`, checkout: j.checkout, candidate: j.candidate.sha,
|
|
766
|
+
goal: mainGoalWords(j),
|
|
767
|
+
acceptance: `The ${j.full === true ? "full release check" : "deploy check"} passes on the release commit|check`,
|
|
768
|
+
release: { version: j.packageVersion, pr: j.pr, branch: j.branch, noCarry: true, main: { full: j.full === true } },
|
|
769
|
+
} : {
|
|
690
770
|
taskId: j.task.id, title: `Release ${j.packageVersion}`, checkout: j.checkout, candidate: j.candidate.sha,
|
|
691
771
|
goal: `Verify ${j.packageName} ${j.packageVersion} (${j.branch} at ${j.candidate.sha}) passes the approved release check before it is deployed, merged, tagged and published.`,
|
|
692
772
|
acceptance: "The approved release check passes on the candidate commit|check",
|
|
693
773
|
...(rel === undefined ? {} : { release: { version: j.packageVersion, pr: j.pr, branch: j.branch, noCarry: options.noCarry === true } }),
|
|
694
774
|
});
|
|
695
775
|
j.task.scopeDigest = filed.scopeDigest;
|
|
776
|
+
save();
|
|
777
|
+
if (isMain)
|
|
778
|
+
await rel?.proved?.({ taskId: j.task.id, version: j.packageVersion, proof: { sha: j.candidate.sha, tree: j.candidate.tree, pr: j.pr, head: j.main.head, branch: j.main.branch } });
|
|
696
779
|
const seen = currentCi();
|
|
697
780
|
if (seen !== null)
|
|
698
781
|
await tell(ready => ready.ci({ taskId: j.task.id, ...seen }));
|
|
@@ -702,7 +785,7 @@ export async function runRelease(options, adapters) {
|
|
|
702
785
|
}
|
|
703
786
|
case "approval": {
|
|
704
787
|
const auto = rel?.auto;
|
|
705
|
-
if (auto !== undefined && j.freshTask !== true && j.auto?.state !== "refused" && j.task.scopeDigest !== null && await auto.setting(j.task.id)) {
|
|
788
|
+
if (!isMain && auto !== undefined && j.freshTask !== true && j.auto?.state !== "refused" && j.task.scopeDigest !== null && await auto.setting(j.task.id)) {
|
|
706
789
|
await watch("dispatch");
|
|
707
790
|
const gate = await adapters.toolroll.gate(j.task.id);
|
|
708
791
|
if (gate.scopeDigest !== j.task.scopeDigest)
|
|
@@ -725,7 +808,7 @@ export async function runRelease(options, adapters) {
|
|
|
725
808
|
await ciWhileRunning("Nothing was deployed or merged", true);
|
|
726
809
|
await tell(ready => ready.asked(j.task.id));
|
|
727
810
|
say(` The release scope needs your approval: \`toolroll task approve ${j.task.id} --digest ${j.task.scopeDigest}\`, or open the task in the console.`);
|
|
728
|
-
say(` Or approve it from here: \`toolroll release approve ${releaseBranchArg(j.branch)}\`.`);
|
|
811
|
+
say(` Or approve it from here: \`toolroll release approve ${isMain ? j.packageVersion : releaseBranchArg(j.branch)}\`.`);
|
|
729
812
|
if (j.ciAhead === true)
|
|
730
813
|
say(` ${CI_RUNNING_WORDS}`);
|
|
731
814
|
const approved = await waitFor("approval", `a person to approve task ${j.task.id}`, async () => {
|
|
@@ -770,10 +853,10 @@ export async function runRelease(options, adapters) {
|
|
|
770
853
|
say(` run ${gate.result.run} failed: ${answer.why}. Toolroll confirmed it as its own infrastructure, so the check runs again on ${j.candidate.sha.slice(0, 7)} under the same approval`);
|
|
771
854
|
return null;
|
|
772
855
|
}
|
|
773
|
-
throw new Stop("check-failed",
|
|
856
|
+
throw new Stop("check-failed", checkFailed({ run: gate.result.run, class: answer.class, why: answer.why }));
|
|
774
857
|
}
|
|
775
858
|
if (gate.failed !== null)
|
|
776
|
-
throw new Stop("check-failed", `The release build of ${j.task.id} failed: ${gate.failed}. Fix it and release the new commit with --new.`, true);
|
|
859
|
+
throw new Stop("check-failed", isMain ? checkFailed({ run: gate.result?.run ?? 0, class: null, why: `its build failed: ${gate.failed}` }) : `The release build of ${j.task.id} failed: ${gate.failed}. Fix it and release the new commit with --new.`, true);
|
|
777
860
|
if (gate.result === null || gate.result.check === "running" || gate.result.check === "pending")
|
|
778
861
|
return null;
|
|
779
862
|
const head = gate.result.head;
|
|
@@ -786,7 +869,7 @@ export async function runRelease(options, adapters) {
|
|
|
786
869
|
if (rel?.standing !== undefined) {
|
|
787
870
|
const standing = await rel.standing(j.task.id, gate.result.run);
|
|
788
871
|
if (!standing.ok)
|
|
789
|
-
throw new Stop("check-failed", `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}: approve this commit again with \`toolroll release ${j.branch} --repo ${j.checkout} --new\`, or fix the branch and release the new commit the same way.`);
|
|
872
|
+
throw new Stop("check-failed", isMain ? `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}. Nothing was deployed, tagged or published: run \`toolroll release ${j.packageVersion} --new\` to check it again.` : `Run ${gate.result.run} passed on ${j.candidate.sha.slice(0, 7)}, but ${standing.why}: approve this commit again with \`toolroll release ${j.branch} --repo ${j.checkout} --new\`, or fix the branch and release the new commit the same way.`);
|
|
790
873
|
if (standing.retried === null)
|
|
791
874
|
say(` run ${gate.result.run} passed, but its report can't be read, so whether anything passed only on a retry is unknown`);
|
|
792
875
|
else if (standing.retried.length > 0)
|
|
@@ -883,6 +966,8 @@ export async function runRelease(options, adapters) {
|
|
|
883
966
|
}
|
|
884
967
|
case "deploy": {
|
|
885
968
|
const check = j.check;
|
|
969
|
+
if (isMain && j.intents.deploy !== undefined)
|
|
970
|
+
await mainProof("The interrupted deploy wasn't finished; nothing was tagged or published");
|
|
886
971
|
await recoverDeploy();
|
|
887
972
|
await checked(await adapters.toolroll.gate(j.task.id), "deploy");
|
|
888
973
|
let runtime = await served(adapters, builtHead());
|
|
@@ -902,10 +987,16 @@ export async function runRelease(options, adapters) {
|
|
|
902
987
|
}
|
|
903
988
|
}
|
|
904
989
|
if (runtime === null) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
990
|
+
if (isMain) {
|
|
991
|
+
await watch("deploy");
|
|
992
|
+
await mainProof("Nothing was deployed, tagged or published");
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
await personCiBeforeDeploy();
|
|
996
|
+
await watch("deploy");
|
|
997
|
+
await pinned();
|
|
998
|
+
await autoCiHolds("the deploy");
|
|
999
|
+
}
|
|
909
1000
|
await nightlyHolds("deploy");
|
|
910
1001
|
let operation, secret = "";
|
|
911
1002
|
if (rel !== undefined && j.authority && epoch !== null) {
|
|
@@ -960,7 +1051,12 @@ export async function runRelease(options, adapters) {
|
|
|
960
1051
|
if (everywhere !== runtime)
|
|
961
1052
|
throw new Stop("mixed-runtime", `After relinking, the console, worker and both CLI names don't all run ${runtime} at ${j.candidate.sha.slice(0, 7)}.`);
|
|
962
1053
|
say(` toolroll and standing-orders run ${join(runtime, "bin.js")}`);
|
|
963
|
-
|
|
1054
|
+
if (isMain) {
|
|
1055
|
+
await tell(ready => ready.verified({ taskId: j.task.id, merge: j.candidate.sha }));
|
|
1056
|
+
advance("tag");
|
|
1057
|
+
}
|
|
1058
|
+
else
|
|
1059
|
+
advance("ci");
|
|
964
1060
|
break;
|
|
965
1061
|
}
|
|
966
1062
|
case "ci": {
|
|
@@ -1059,7 +1155,10 @@ export async function runRelease(options, adapters) {
|
|
|
1059
1155
|
if (at !== null && at !== merge.sha)
|
|
1060
1156
|
throw new Stop("conflict", `${j.tag} already points at ${at.slice(0, 7)}, not the merge ${merge.sha.slice(0, 7)}.`);
|
|
1061
1157
|
if (at === null) {
|
|
1062
|
-
|
|
1158
|
+
if (isMain)
|
|
1159
|
+
await mainProof("It runs here; nothing was tagged or published");
|
|
1160
|
+
else
|
|
1161
|
+
await autoCiHolds("the tag");
|
|
1063
1162
|
await nightlyHolds("tag");
|
|
1064
1163
|
intend("tag");
|
|
1065
1164
|
await adapters.github.createTag(j.github, j.tag, merge.sha);
|
|
@@ -1108,7 +1207,9 @@ export async function runRelease(options, adapters) {
|
|
|
1108
1207
|
}
|
|
1109
1208
|
}
|
|
1110
1209
|
const left = homebrewLeft;
|
|
1111
|
-
if (left === null)
|
|
1210
|
+
if (left === null && isMain)
|
|
1211
|
+
say(`Released ${j.tag} from main at ${j.candidate.sha.slice(0, 7)}: deployed here, tagged, published and ${j.homebrew?.state === "superseded" ? `left Homebrew as it is (${j.homebrew.why ?? "the tap names a newer version"})` : "on Homebrew"}.`);
|
|
1212
|
+
else if (left === null)
|
|
1112
1213
|
say(`Released ${j.tag}: deployed, merged as ${j.merge.sha.slice(0, 7)}, tagged, published and ${j.homebrew?.state === "superseded" ? `left Homebrew as it is (${j.homebrew.why ?? "the tap names a newer version"})` : "on Homebrew"}.`);
|
|
1113
1214
|
else
|
|
1114
1215
|
say(`Published ${j.tag} (deployed, merged as ${j.merge.sha.slice(0, 7)}, tagged, on npm and GitHub); Homebrew ${left.state}${left.why === null ? "" : `: ${left.why}`}. Finish it with \`${resume}\`.`);
|
|
@@ -1184,6 +1285,93 @@ async function begin(options, adapters, now) {
|
|
|
1184
1285
|
merge: null, tagged: null, published: null, homebrew: null, intents: {}, stopped: null, createdAt: at, updatedAt: at,
|
|
1185
1286
|
};
|
|
1186
1287
|
}
|
|
1288
|
+
export function mainProofWords(version, short, why, nothing) {
|
|
1289
|
+
return `${version} can't be released from ${short}: ${why.replace(/\.$/, "")}. ${nothing}. Merge a release pull request for ${version} (\`toolroll release prepare ${version}\`), then run \`toolroll release ${version}\`.`;
|
|
1290
|
+
}
|
|
1291
|
+
export function mainGoalWords(j) {
|
|
1292
|
+
const check = j.full === true
|
|
1293
|
+
? "runs the full release check on this Mac (about 40 minutes)"
|
|
1294
|
+
: "runs the deploy check on this Mac: it builds it, upgrades a copy of your database and starts it against that copy (about 4 minutes)";
|
|
1295
|
+
return `Release ${j.packageName} ${j.packageVersion} from main at ${j.candidate.sha} (pull request #${j.pr}). GitHub ran every required check on this tree on #${j.pr} (its head ${j.main?.head ?? "unknown"}). After your approval Toolroll ${check}, then deploys it here, tags ${j.tag} and publishes to npm and Homebrew. ${j.full === true ? "The check runs this commit's code with full access to this computer." : "The deploy check's own scripts run this commit's code with this project's check access (for Toolroll, full access to this computer); its build, the upgraded copy and the console run fenced: no network but their own loopback port, nothing written outside a throwaway folder."}`;
|
|
1296
|
+
}
|
|
1297
|
+
async function beginMain(options, adapters, now) {
|
|
1298
|
+
const version = options.version;
|
|
1299
|
+
const { checkout } = options;
|
|
1300
|
+
if (!VERSION_PATTERN.test(version))
|
|
1301
|
+
throw new Stop("usage", `${version} isn't a version: \`toolroll release <major.minor.patch>\`.`);
|
|
1302
|
+
const main = adapters.github.main;
|
|
1303
|
+
if (main === undefined)
|
|
1304
|
+
throw new Stop("usage", "This build of Toolroll can't release from main.");
|
|
1305
|
+
const installed = await adapters.toolroll.installed();
|
|
1306
|
+
const runtimes = new Set([...installed.services, ...installed.clis.map(one => one.runtime ?? "(not linked)")]);
|
|
1307
|
+
if (installed.services.length === 0 || runtimes.size !== 1) {
|
|
1308
|
+
throw new Stop("mixed-runtime", `The console, worker and CLI names don't run one build (${[...installed.services.map(one => `service ${one}`), ...installed.clis.map(one => `${one.name} ${one.runtime ?? "not linked"}`)].join("; ")}). Update them to one verified build first.`);
|
|
1309
|
+
}
|
|
1310
|
+
const github = await adapters.repo.github();
|
|
1311
|
+
const nothing = "Nothing was checked, deployed, tagged or published";
|
|
1312
|
+
const pull = await main.pull(github, version);
|
|
1313
|
+
if (pull.kind === "none")
|
|
1314
|
+
throw new Stop("no-release-commit", mainProofWords(version, "main", `no pull request from ${releaseBranchFor(version)} has merged into main`, nothing));
|
|
1315
|
+
if (pull.kind === "open")
|
|
1316
|
+
throw new Stop("not-merged", `Releases now go from main. Merge #${pull.pr} like any pull request once its checks pass, then run \`toolroll release ${version}\`.`);
|
|
1317
|
+
const short = pull.sha.slice(0, 7);
|
|
1318
|
+
const proven = await main.prove(github, pull.sha);
|
|
1319
|
+
if (!proven.ok)
|
|
1320
|
+
throw new Stop("proof", mainProofWords(version, short, proven.why, nothing));
|
|
1321
|
+
if (proven.sha !== pull.sha || proven.pr !== pull.pr)
|
|
1322
|
+
throw new Stop("proof", mainProofWords(version, short, `the proof names pull request #${proven.pr} at ${proven.sha.slice(0, 7)}`, nothing));
|
|
1323
|
+
if (proven.branch !== releaseBranchFor(version))
|
|
1324
|
+
throw new Stop("proof", mainProofWords(version, short, `pull request #${proven.pr} came from ${proven.branch}, not ${releaseBranchFor(version)} (where Node 22 runs)`, nothing));
|
|
1325
|
+
const placed = await main.firstParent(github, pull.sha);
|
|
1326
|
+
if (!placed.ok)
|
|
1327
|
+
throw new Stop("proof", mainProofWords(version, short, `it isn't on main's history (${placed.why})`, nothing));
|
|
1328
|
+
const verdict = prChecksVerdict(await adapters.github.checks(github, proven.head), proven.head, REQUIRED_PR_CHECKS, { workflow: REQUIRED_PR_CHECKS_WORKFLOW });
|
|
1329
|
+
if (verdict.state !== "passed")
|
|
1330
|
+
throw new Stop("ci-failed", mainProofWords(version, short, `the checks on pull request #${proven.pr}'s head ${proven.head.slice(0, 7)} aren't all passing: ${(verdict.state === "failed" ? verdict.failed : verdict.waiting).join(", ")}`, nothing));
|
|
1331
|
+
await adapters.repo.sync(releaseBranchFor(version));
|
|
1332
|
+
if (await adapters.repo.tree(pull.sha) !== proven.tree)
|
|
1333
|
+
throw new Stop("proof", mainProofWords(version, short, "this checkout's copy of it doesn't have the tree GitHub proved", nothing));
|
|
1334
|
+
const manifest = await adapters.repo.fileAt(pull.sha, "package.json");
|
|
1335
|
+
let pkg = null;
|
|
1336
|
+
try {
|
|
1337
|
+
pkg = manifest === null ? null : JSON.parse(manifest);
|
|
1338
|
+
}
|
|
1339
|
+
catch {
|
|
1340
|
+
pkg = null;
|
|
1341
|
+
}
|
|
1342
|
+
if (typeof pkg?.name !== "string" || pkg.version !== version)
|
|
1343
|
+
throw new Stop("version", mainProofWords(version, short, `its package.json names ${typeof pkg?.version === "string" ? pkg.version : "no version"}`, nothing));
|
|
1344
|
+
if (!changelogHas(await adapters.repo.fileAt(pull.sha, "CHANGELOG.md") ?? "", version))
|
|
1345
|
+
throw new Stop("changelog", mainProofWords(version, short, `its CHANGELOG.md has no "## ${version}" entry`, nothing));
|
|
1346
|
+
const tag = `v${version}`;
|
|
1347
|
+
if (await adapters.github.tag(github, tag) !== null)
|
|
1348
|
+
throw new Stop("version", `${tag} already exists. ${nothing}.`);
|
|
1349
|
+
if (await adapters.registry.published(pkg.name, version))
|
|
1350
|
+
throw new Stop("version", `${pkg.name}@${version} is already on npm. ${nothing}.`);
|
|
1351
|
+
const previous = previousVersion(version);
|
|
1352
|
+
const changed = previous === null || main.changedSince === undefined ? null : await main.changedSince(github, `v${previous}`, pull.sha);
|
|
1353
|
+
const harness = changed === null ? null : harnessChanges(changed.filter(path => path !== "package.json" && path !== "package-lock.json" && path !== "CHANGELOG.md"));
|
|
1354
|
+
const at = now.toISOString();
|
|
1355
|
+
adapters.say(`Releasing ${pkg.name} ${version} from main at ${short} (pull request #${proven.pr}).`);
|
|
1356
|
+
if (harness !== null && harness.length > 0 && options.full !== true) {
|
|
1357
|
+
adapters.say(` CI's own rules, the build or the test harness changed since ${previous} (${harness.slice(0, 5).join(", ")}${harness.length > 5 ? `, and ${harness.length - 5} more` : ""}). \`toolroll release ${version} --full --new\` runs the full check on this Mac first, about 40 minutes.`);
|
|
1358
|
+
}
|
|
1359
|
+
if (placed.after.length > 0)
|
|
1360
|
+
adapters.say(` ${placed.after.length} later commit${placed.after.length === 1 ? "" : "s"} on main go${placed.after.length === 1 ? "es" : ""} in the next release.`);
|
|
1361
|
+
return {
|
|
1362
|
+
version: 1, id: randomUUID(), github, checkout, branch: proven.branch, candidate: { sha: pull.sha, tree: proven.tree }, packageName: pkg.name, packageVersion: version, tag, pr: proven.pr,
|
|
1363
|
+
step: "gate", task: { id: gateTaskId(version, pull.sha), scopeDigest: null }, approval: null, check: null, completion: null, deploy: null, ci: null,
|
|
1364
|
+
merge: { sha: pull.sha, tree: proven.tree }, tagged: null, published: null, homebrew: null, intents: {}, stopped: null, createdAt: at, updatedAt: at,
|
|
1365
|
+
mode: "main", ...(options.full === true ? { full: true } : {}),
|
|
1366
|
+
main: { head: proven.head, branch: proven.branch, previousTag: previous === null ? null : `v${previous}`, harness, after: placed.after },
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
export function previousVersion(version) {
|
|
1370
|
+
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
|
|
1371
|
+
if (match === null || Number(match[3]) === 0)
|
|
1372
|
+
return null;
|
|
1373
|
+
return `${match[1]}.${match[2]}.${Number(match[3]) - 1}`;
|
|
1374
|
+
}
|
|
1187
1375
|
function deployStop(reason, message, stop) {
|
|
1188
1376
|
if (stop.gate === undefined)
|
|
1189
1377
|
return new Stop(reason, message);
|
package/dist/reply-shape.js
CHANGED
|
@@ -113,9 +113,14 @@ function limitBold(text, state) {
|
|
|
113
113
|
.replace(/\*\*([^*\n]+?)\*\*/g, (_, inner) => anchor(inner))
|
|
114
114
|
.replace(/(^|[^*\w])\*(?![\s*])([^*\n]*?[^\s*])\*(?![*\w])/g, "$1$2");
|
|
115
115
|
}
|
|
116
|
+
function ownPageLinks(text, appOrigin) {
|
|
117
|
+
const origins = appOrigin === null || appOrigin === undefined ? [] : typeof appOrigin === "string" ? [appOrigin] : appOrigin;
|
|
118
|
+
const origin = origins.find((one) => typeof one === "string" && /^https?:\/\/[^\s/]+$/.test(one.replace(/\/$/, ""))) ?? null;
|
|
119
|
+
return text.replace(/\[([^\]\n]{1,120})\]\((\/direct-chats\/[a-f0-9]{32})\)/g, (_all, label, path) => origin === null ? label : `[${label}](${origin.replace(/\/$/, "")}${path})`);
|
|
120
|
+
}
|
|
116
121
|
function holdAside(text, options) {
|
|
117
122
|
const held = [];
|
|
118
|
-
const body = text.replace(/\r\n?/g, "\n").replace(PROTECTED, (match) => {
|
|
123
|
+
const body = ownPageLinks(text, options.appOrigin).replace(/\r\n?/g, "\n").replace(PROTECTED, (match) => {
|
|
119
124
|
if (match.startsWith("`")) {
|
|
120
125
|
held.push(match);
|
|
121
126
|
return HOLD(held.length - 1);
|
package/dist/result-actions.js
CHANGED
|
@@ -143,6 +143,11 @@ export function createResultRevision(store, evidenceRoot, input, now) {
|
|
|
143
143
|
if (consumers.size > 0) {
|
|
144
144
|
return fail(409, `some of these notes were already sealed into revision ${[...consumers].join(", ")}; the others are still waiting — reload the result to see the current batch`);
|
|
145
145
|
}
|
|
146
|
+
if (input.approveNow !== undefined) {
|
|
147
|
+
const stale = input.currentResult === undefined ? "Reload the result before sending it back to build." : input.currentResult();
|
|
148
|
+
if (stale !== null)
|
|
149
|
+
return fail(409, stale);
|
|
150
|
+
}
|
|
146
151
|
if (postedSource !== revisionSourceOf(sourceScope?.digest ?? null)) {
|
|
147
152
|
return fail(409, "the task's terms changed since this page was shown — reload the result and read the current terms before creating a revision");
|
|
148
153
|
}
|
|
@@ -214,7 +219,8 @@ export function createResultRevision(store, evidenceRoot, input, now) {
|
|
|
214
219
|
store.raw().prepare("UPDATE task SET title = ? WHERE id = ?").run(title, result.id);
|
|
215
220
|
recordRevisionOrigin(store, result.id, input.origin);
|
|
216
221
|
}
|
|
217
|
-
|
|
222
|
+
const approvedNow = result.ok && coverage === null && input.approveNow !== undefined && input.approveNow(result.id);
|
|
223
|
+
if (result.ok && coverage === null && !approvedNow) {
|
|
218
224
|
const ref = store.lookupRef(result.id);
|
|
219
225
|
if (ref !== null)
|
|
220
226
|
store.requestPlan(ref.id, now);
|