fix(coding-agent): sync pi-natives on omp update
bun install -g <pkg>@<v> did not reliably re-resolve transitive optionalDependencies, so @oh-my-pi/pi-natives and the platform leaf @oh-my-pi/pi-natives-<tag> stayed at the previous version while @oh-my-pi/pi-coding-agent moved. The loader’s validateLoadedBindings then aborted because the .node file exposed the old __piNativesV<old> sentinel instead of __piNativesV<new>. buildBunInstallArgs now pins @oh-my-pi/pi-natives and (when the running tag is one the release pipeline publishes) the platform leaf to the same version it installs for @oh-my-pi/pi-coding-agent, so bun replaces all three in lock-step. The leaf is gated by the same SUPPORTED_PLATFORMS set the loader uses, so unsupported tags still surface the original 'no matching version' diagnostic instead of EBADPLATFORM. Fixes #1824
This commit is contained in:
@@ -45,7 +45,8 @@ describe("update-cli bun install command", () => {
|
||||
// is already pointed at the official registry but its cache predates
|
||||
// the release.
|
||||
// See https://github.com/can1357/oh-my-pi/issues/1686.
|
||||
expect(buildBunInstallArgs("15.7.6")).toEqual([
|
||||
const args = buildBunInstallArgs("15.7.6", "linux-x64");
|
||||
expect(args.slice(0, 5)).toEqual([
|
||||
"install",
|
||||
"-g",
|
||||
"--no-cache",
|
||||
@@ -53,6 +54,31 @@ describe("update-cli bun install command", () => {
|
||||
"@oh-my-pi/pi-coding-agent@15.7.6",
|
||||
]);
|
||||
});
|
||||
|
||||
it("pins the native addon core and the platform-specific leaf to the same version so the loader sentinel cannot drift on supported tags", () => {
|
||||
// Regression: bun install -g <pkg>@<v> would update only the top-level
|
||||
// package, leaving @oh-my-pi/pi-natives and @oh-my-pi/pi-natives-<tag>
|
||||
// at their previous version. The next launch then loaded a stale .node
|
||||
// file and aborted at validateLoadedBindings with `The .node file on
|
||||
// disk is from a different release than this loader`. See
|
||||
// https://github.com/can1357/oh-my-pi/issues/1824.
|
||||
for (const tag of ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64", "win32-x64"]) {
|
||||
const args = buildBunInstallArgs("15.9.0", tag);
|
||||
expect(args).toContain("@oh-my-pi/pi-natives@15.9.0");
|
||||
expect(args).toContain(`@oh-my-pi/pi-natives-${tag}@15.9.0`);
|
||||
}
|
||||
});
|
||||
|
||||
it("omits the leaf on unsupported platform tags so an EBADPLATFORM swap does not mask the underlying `no matching version` error", () => {
|
||||
// Defensive: an unsupported tag (e.g. linux-arm32) still installs the
|
||||
// core natives package — which will fail at module load if the platform
|
||||
// truly is unsupported — but we never request a leaf the release
|
||||
// pipeline doesn't publish, otherwise bun aborts with EBADPLATFORM
|
||||
// and hides the real diagnostic from `loadNative`'s aggregated error.
|
||||
const args = buildBunInstallArgs("15.9.0", "linux-arm");
|
||||
expect(args).toContain("@oh-my-pi/pi-natives@15.9.0");
|
||||
expect(args.some(arg => arg.startsWith("@oh-my-pi/pi-natives-"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("update-cli binary replacement", () => {
|
||||
|
||||
Reference in New Issue
Block a user