chore(vendor): import pi 1.3.0

Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
2026-10-15 17:58:48 -04:00
parent 719370c8f7
commit 6081e3e325
1743 changed files with 205460 additions and 131705 deletions

View File

@@ -8,7 +8,8 @@
*
* Steps:
* 1. Check for uncommitted changes
* 2. Verify every public workspace package is registered on npm
* 2. Verify every public workspace package is registered on npm,
* pin the newest model catalog for Nix, and build with it
* 3. Bump version via npm run version:xxx or set an explicit version
* 4. Update CHANGELOG.md files: [Unreleased] -> [version] - date
* 5. Regenerate release artifacts
@@ -24,6 +25,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { findPackageDirectories } from "./package-workspaces.mjs";
import { getPublicWorkspacePackages } from "./release-packages.mjs";
import { hydrateModelCatalogBytes, updateModelCatalogPin } from "./update-model-catalog-pin.mjs";
const RELEASE_TARGET = process.argv[2];
const BUMP_TYPES = new Set(["major", "minor", "patch"]);
@@ -84,6 +86,48 @@ function assertPackagesAreRegisteredWithNpm() {
console.log(" All public workspace packages are registered on npm\n");
}
const MODEL_CATALOG_PIN = "nix/model-catalog.json";
// Release tags are immutable, so the tagged Nix pin must already build the
// release. Pin the newest catalog unconditionally (`--if-stale` only avoids pin
// churn on main), then run the Nix build's steps: hydrate the checkout's model
// data from it and build offline. This catches e.g. source that references a
// model the catalog lacks. On failure, restore the committed pin so the
// worktree is clean for a rerun.
async function pinAndBuildWithNewestModelCatalog() {
const root = process.cwd();
const committedPin = readFileSync(MODEL_CATALOG_PIN, "utf8");
const restored = `${MODEL_CATALOG_PIN} was restored. Run \`npm run generate:models\` to restore local model data, then rerun the release.`;
let revision;
let result;
try {
const pin = await updateModelCatalogPin(root);
revision = pin.revision;
console.log(` Pinned model catalog ${revision}`);
hydrateModelCatalogBytes(root, pin.bytes);
console.log("$ npm run build:offline");
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
result = spawnSync(npm, ["run", "build:offline"], { stdio: "inherit" });
} finally {
if (result?.status !== 0) writeFileSync(MODEL_CATALOG_PIN, committedPin);
}
// Only a build that ran and exited non-zero says anything about the catalog.
if (result.error || result.signal) {
const cause = result.error ? result.error.message : `it was stopped by ${result.signal}`;
console.error(`Error: npm run build:offline did not complete: ${cause}.\n${restored}`);
process.exit(1);
}
if (result.status !== 0) {
console.error(
`Error: the build with the newest published model catalog ${revision} failed; the Nix build of the release tag would fail too.\n` +
"If the errors concern model IDs, types, or APIs, the catalog predates main: publish one from main (Publish Model Catalog workflow).\n" +
"Otherwise fix the build (e.g. run `npm ci --ignore-scripts` if node_modules is out of date).\n" +
restored,
);
process.exit(1);
}
}
function compareVersions(a, b) {
const aParts = a.split(".").map(Number);
const bParts = b.split(".").map(Number);
@@ -224,6 +268,12 @@ console.log(" Working directory clean\n");
// 2. Verify npm package registration before modifying the worktree.
assertPackagesAreRegisteredWithNpm();
// Pin and verify the Nix model catalog before modifying versions, so the pin
// lands in the release commit and a failure leaves the worktree clean.
console.log("Pinning and building with the newest model catalog for Nix...");
await pinAndBuildWithNewestModelCatalog();
console.log();
// 3. Bump or set version
const version = bumpOrSetVersion(RELEASE_TARGET);
console.log(` New version: ${version}\n`);
@@ -237,7 +287,6 @@ console.log();
console.log("Regenerating release artifacts...");
run("npm run generate:models");
run("npm run check:model-data");
run("npm run shrinkwrap:coding-agent");
run("npm run install-lock:coding-agent");
console.log();
@@ -250,9 +299,15 @@ console.log("Building packages for tests...");
run("npm run build:offline");
console.log();
console.log("Running tests...");
run("./test.sh");
console.log();
// PI_RELEASE_SKIP_TESTS=1 skips the test suite, e.g. when it already passed in `npm run release:local`
// and an overloaded machine makes timing-sensitive tests fail. Checks and the install check still run.
if (process.env.PI_RELEASE_SKIP_TESTS === "1") {
console.log("Skipping tests (PI_RELEASE_SKIP_TESTS=1)\n");
} else {
console.log("Running tests...");
run("./test.sh");
console.log();
}
console.log("Checking the packed coding-agent consumer install...");
run("npm run check:package-install");