@devries-cameron20 / t3code-1 / commits / 67d7de8aa2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-core): bun-global updates only offer versions bun will install (#30641)

Julius Marminge committed Nov 11, 2026 at 16:08 UTC 67d7de8aa232135bfedd6adee789598bdd76cf59
2 files changed +112
packages/provider-core/src/server/maintenanceResolver.test.ts
+77
@@ -66,6 +66,14 @@ const nativePackageToolUpdate = makePackageManagedProviderMaintenanceResolver({
66 isCommandPath: isNativeTestCommandPath("/.local/bin/native-package-tool"),
67 },
68 });
69 +const bunOutdatedTable = (row: string) => [
70 + "|-------------------------------------------------------|",
71 + "| Package | Current | Update | Latest |",
72 + "|-----------------------|---------|--------|----------|",
73 + row,
74 + "|-------------------------------------------------------|",
75 + "Note: The * indicates that version isn't true latest due to minimum release age",
76 +];
77 const miseToolUpdate = makePackageManagedProviderMaintenanceResolver({
78 provider: driver("packageTool"),
79 npmPackageName: "@example/package-tool",
@@ -1267,6 +1275,75 @@ it.layer(
1275 { skip: !symlinksSupported || windowsHost },
1276 );
1277
1278 + it.effect.each([
1279 + {
1280 + case: "the eligible release under minimumReleaseAge",
1281 + row: "| @example/package-tool | 1.0.0 | 1.0.0 | 1.1.0 * |",
1282 + expected: "1.1.0",
1283 + },
1284 + {
1285 + case: "no update when the installed version is the eligible release",
1286 + row: "| @example/package-tool | 1.0.0 | 1.0.0 * | 1.0.0 * |",
1287 + expected: "1.0.0",
1288 + },
1289 + {
1290 + // bun prints only its banner both when nothing is outdated and when the registry fails.
1291 + case: "the npm fallback when bun reports no row",
1292 + row: null,
1293 + expected: "1.2.0",
1294 + },
1295 + ])(
1296 + "advertises $case for bun-global installs",
1297 + (fixture) =>
1298 + Effect.gen(function* () {
1299 + const tempDir = yield* makeTempDir("t3-bun-latest");
1300 + const bunBinDir = NodePath.join(tempDir, ".bun", "bin");
1301 + writeExecutable(NodePath.join(bunBinDir, "bun"));
1302 + writeExecutable(NodePath.join(bunBinDir, "package-tool"));
1303 + const outdated = [
1304 + "bun outdated v1.3.3 (274e01c7)",
1305 + ...(fixture.row === null ? [] : bunOutdatedTable(fixture.row)),
1306 + "",
1307 + ].join("\n");
1308 +
1309 + const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
1310 + packageToolUpdate,
1311 + { binaryPath: "package-tool", env: { PATH: bunBinDir } },
1312 + ).pipe(
1313 + Effect.provideService(HostProcess.Platform, "darwin"),
1314 + Effect.provideService(HostProcess.Environment, { PATH: "" }),
1315 + Effect.provideService(
1316 + ChildProcessSpawner.ChildProcessSpawner,
1317 + stdoutSpawner((_command, args) =>
1318 + args[0] === "outdated"
1319 + ? outdated
1320 + : `${tempDir} node_modules (1)\n└── @example/package-tool@1.0.0\n`,
1321 + ),
1322 + ),
1323 + );
1324 +
1325 + const provider = yield* enrichProviderSnapshotWithVersionAdvisory(
1326 + installedPackageToolProvider,
1327 + capabilities,
1328 + ).pipe(
1329 + Effect.provideServiceEffect(
1330 + ProviderLatestVersions.ProviderLatestVersions,
1331 + ProviderLatestVersions.make([["@example/package-tool", "1.2.0"]]),
1332 + ),
1333 + Effect.provideService(
1334 + HttpClient.HttpClient,
1335 + HttpClient.make(() => Effect.die("the npm version is already cached")),
1336 + ),
1337 + );
1338 + expect(provider.versionAdvisory).toMatchObject({
1339 + status: fixture.expected === "1.0.0" ? "current" : "behind_latest",
1340 + currentVersion: "1.0.0",
1341 + latestVersion: fixture.expected,
1342 + });
1343 + }),
1344 + { skip: windowsHost },
1345 + );
1346 +
1347 it.effect.skipIf(windowsHost)(
1348 "switches to bun updates when the resolved binary lives in bun's global bin",
1349 () =>
packages/provider-core/src/server/maintenanceResolver.ts
+35
@@ -482,6 +482,37 @@ const resolvePnpmGlobalLatestVersion = Effect.fn("resolvePnpmGlobalLatestVersion
482 return nonEmptyString(listedEntries?.[0]?.dependencies?.[packageName]?.version);
483 });
484
485 +// `bun outdated` has no JSON output; its `Latest` column is what `@latest` installs
486 +// under minimumReleaseAge (marked `*`). `Update` is only the global package.json range.
487 +function parseBunOutdatedLatestVersion(output: string, packageName: string): string | null {
488 + for (const line of output.split("\n")) {
489 + const cells = line.split("|").map((cell) => cell.trim());
490 + if (cells.length === 6 && cells[1] === packageName) {
491 + return nonEmptyString(cells[4]?.replace(/ \*$/, ""));
492 + }
493 + }
494 + return null;
495 +}
496 +
497 +// bun rejects an exact pin to a release inside minimumReleaseAge, so the update stays `@latest`.
498 +const resolveBunGlobalLatestVersion = Effect.fn("resolveBunGlobalLatestVersion")(function* (
499 + packageName: string,
500 + env: NodeJS.ProcessEnv,
501 +) {
502 + // Match the updater's bun and environment.
503 + const bunPath = yield* resolveCommandPath("bun", {
504 + env: { ...(yield* HostProcess.Environment), ...env },
505 + });
506 + if (!bunPath) return null;
507 + // FORCE_COLOR=1 draws the table with box characters and splits versions with ANSI codes.
508 + const outdated = yield* runProbe(bunPath, ["outdated", "-g", packageName], {
509 + ...env,
510 + FORCE_COLOR: "0",
511 + });
512 + // A missing row reads the same whether bun is current or its registry failed, so npm decides.
513 + return outdated ? parseBunOutdatedLatestVersion(outdated, packageName) : null;
514 +});
515 +
516 const MiseInstall = Schema.Struct({
517 install_path: Schema.String,
518 requested_version: Schema.optional(Schema.NullOr(Schema.String)),
@@ -723,6 +754,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
754 });
755 }
756 if (commandPaths.some(isBunGlobalCommandPath)) {
757 + const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
758 return makeProviderMaintenanceCapabilities({
759 provider: definition.provider,
760 packageName,
@@ -730,6 +762,9 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
762 updateArgs: ["i", "-g", `${packageName}@latest`],
763 updateLockKey: "bun-global",
764 env: context.env,
765 + lookupLatestVersion: resolveBunGlobalLatestVersion(packageName, context.env).pipe(
766 + Effect.provideContext(services),
767 + ),
768 });
769 }
770 if (commandPaths.some(isPnpmGlobalCommandPath)) {