diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 46831be05..66ec97fc4 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed release-built `omp--` binaries missing the compiled tiny-model Transformers.js version pin, which made Homebrew Darwin arm64 fall back to resolving `@huggingface/transformers/package.json` from bunfs at runtime. ([#3904](https://github.com/can1357/oh-my-pi/issues/3904)) + ## [16.2.8] - 2026-06-30 ### Added diff --git a/scripts/ci-release-build-binaries.test.ts b/scripts/ci-release-build-binaries.test.ts new file mode 100644 index 000000000..021274273 --- /dev/null +++ b/scripts/ci-release-build-binaries.test.ts @@ -0,0 +1,26 @@ +import { $ } from "bun"; +import { describe, expect, it } from "bun:test"; +import { createRequire } from "node:module"; +import * as path from "node:path"; + +interface PackageManifest { + version: string; +} + +const repoRoot = path.join(import.meta.dir, ".."); +const transformersManifest: PackageManifest = createRequire(import.meta.url)("@huggingface/transformers/package.json"); +const transformersVersion = transformersManifest.version; + +describe("ci-release-build-binaries dry run", () => { + it("pins the Transformers.js runtime version in compiled release binaries", async () => { + const result = await $`bun scripts/ci-release-build-binaries.ts --dry-run --targets linux-x64` + .cwd(repoRoot) + .quiet(); + const output = result.text(); + + expect(output).toContain('--define process.env.PI_COMPILED="true"'); + expect(output).toContain( + `--define process.env.PI_TINY_TRANSFORMERS_VERSION=${JSON.stringify(transformersVersion)}`, + ); + }); +}); diff --git a/scripts/ci-release-build-binaries.ts b/scripts/ci-release-build-binaries.ts index 4645d4259..5a3a6c3e0 100644 --- a/scripts/ci-release-build-binaries.ts +++ b/scripts/ci-release-build-binaries.ts @@ -1,4 +1,5 @@ #!/usr/bin/env bun +import { createRequire } from "node:module"; import * as fs from "node:fs/promises"; import * as path from "node:path"; @@ -11,9 +12,15 @@ interface BinaryTarget { outfile: string; } +interface PackageManifest { + version: string; +} + const repoRoot = path.join(import.meta.dir, ".."); const binariesDir = path.join(repoRoot, "packages", "coding-agent", "binaries"); const entrypoint = "./packages/coding-agent/src/cli.ts"; +const transformersManifest: PackageManifest = createRequire(import.meta.url)("@huggingface/transformers/package.json"); +const transformersVersion = transformersManifest.version; // Worker threads spawn `new Worker(Bun.main, { argv })` — they re-enter the // binary's own entry module — so no separate worker modules are compiled. // Legacy pi-* extension compat surfaces are served through an in-process @@ -107,41 +114,43 @@ async function embedNative(target: BinaryTarget): Promise { }); } +function buildCompileCommand(target: BinaryTarget): string[] { + return [ + "bun", + "build", + "--compile", + "--no-compile-autoload-bunfig", + "--no-compile-autoload-dotenv", + "--no-compile-autoload-tsconfig", + "--no-compile-autoload-package-json", + "--minify-identifiers", + "--keep-names", + "--define", + 'process.env.PI_COMPILED="true"', + "--define", + `process.env.PI_TINY_TRANSFORMERS_VERSION=${JSON.stringify(transformersVersion)}`, + "--root", + ".", + "--target", + target.target, + entrypoint, + "--outfile", + target.outfile, + ]; +} + async function buildBinary(target: BinaryTarget): Promise { console.log(`Building ${target.outfile}...`); await embedNative(target); if (isDryRun) { - console.log(`DRY RUN bun build --compile --no-compile-autoload-bunfig --no-compile-autoload-dotenv --no-compile-autoload-tsconfig --no-compile-autoload-package-json --minify-identifiers --keep-names --define process.env.PI_COMPILED="true" --root . --target=${target.target} ${entrypoint} --outfile ${target.outfile}`); + console.log(`DRY RUN ${buildCompileCommand(target).join(" ")}`); return; } const buildEnv = shouldAdhocSignDarwinBinary(target) ? { ...Bun.env, BUN_NO_CODESIGN_MACHO_BINARY: "1" } : Bun.env; - await runCommand( - [ - "bun", - "build", - "--compile", - "--no-compile-autoload-bunfig", - "--no-compile-autoload-dotenv", - "--no-compile-autoload-tsconfig", - "--no-compile-autoload-package-json", - "--minify-identifiers", - "--keep-names", - "--define", - 'process.env.PI_COMPILED="true"', - "--root", - ".", - "--target", - target.target, - entrypoint, - "--outfile", - target.outfile, - ], - repoRoot, - buildEnv, - ); + await runCommand(buildCompileCommand(target), repoRoot, buildEnv); // Bun 1.3.12 emits a truncated Mach-O signature on darwin builds. if (shouldAdhocSignDarwinBinary(target)) {