@devries-cameron20 / t3code-1 / commits / beaf28459b
Fork 0

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

fix(provider-core): Vite+ system_first shims update the install they actually run (#35086)

Julius Marminge committed Nov 12, 2026 at 02:39 UTC beaf28459b3d9283791e09b077ae9a0973837198
2 files changed +119 -2
packages/provider-core/src/server/maintenanceResolver.test.ts
+64
@@ -1011,6 +1011,70 @@ it.layer(
1011 }),
1012 );
1013
1014 + // `vp env off` makes each shim run the next matching executable on PATH instead.
1015 + it.effect.each([
1016 + {
1017 + name: "a system_first shim (VP_HOME layout) to a later install",
1018 + vpHome: ".vite-plus",
1019 + setVpHome: true,
1020 + configs: { ".vite-plus": "system_first" },
1021 + vitePlus: false,
1022 + },
1023 + {
1024 + name: "a system_first shim (XDG layout) to a later install",
1025 + vpHome: ".local/share/vite-plus",
1026 + setVpHome: false,
1027 + configs: { ".config/vite-plus": "system_first" },
1028 + vitePlus: false,
1029 + },
1030 + {
1031 + name: "a managed VP_HOME shim despite a system_first XDG config",
1032 + vpHome: ".local/share/vite-plus",
1033 + setVpHome: true,
1034 + configs: { ".local/share/vite-plus": "managed", ".config/vite-plus": "system_first" },
1035 + vitePlus: true,
1036 + },
1037 + ] as const)("updates through vp only for the install the shim runs: $name", (fixture) =>
1038 + Effect.gen(function* () {
1039 + const tempDir = yield* makeTempDir("vite-plus-system-first");
1040 + const vpHome = NodePath.join(tempDir, fixture.vpHome);
1041 + for (const [dir, shimMode] of Object.entries(fixture.configs)) {
1042 + NodeFS.mkdirSync(NodePath.join(tempDir, dir), { recursive: true });
1043 + NodeFS.writeFileSync(
1044 + NodePath.join(tempDir, dir, "config.json"),
1045 + JSON.stringify({ shimMode }),
1046 + );
1047 + }
1048 + const shim = NodePath.join(vpHome, "bin", "package-tool");
1049 + writeExecutable(shim);
1050 + const otherInstall = linkIntoPackage(NodePath.join(tempDir, "npm"), "package-tool", [
1051 + "lib",
1052 + "node_modules",
1053 + "@example",
1054 + "package-tool",
1055 + ]);
1056 +
1057 + const capabilities = yield* packageToolUpdate
1058 + .resolve({
1059 + binaryPath: "package-tool",
1060 + resolvedCommandPath: shim,
1061 + realCommandPath: NodePath.join(vpHome, "current", "bin", "vp"),
1062 + env: {
1063 + ...(fixture.setVpHome ? { VP_HOME: vpHome } : {}),
1064 + PATH: [NodePath.dirname(shim), NodePath.dirname(otherInstall)].join(":"),
1065 + },
1066 + platform: "linux",
1067 + })
1068 + .pipe(
1069 + Effect.provideService(HostProcess.Platform, "linux"),
1070 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
1071 + Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
1072 + );
1073 +
1074 + expect(capabilities.update?.lockKey === "vite-plus-global").toBe(fixture.vitePlus);
1075 + }),
1076 + );
1077 +
1078 it.effect("keeps a project folder named vite-plus manual-only", () =>
1079 Effect.gen(function* () {
1080 const capabilities = yield* resolveInstall({
packages/provider-core/src/server/maintenanceResolver.ts
+55 -2
@@ -648,18 +648,71 @@ export const resolveMiseProviderMaintenance = Effect.fn("resolveMiseProviderMain
648 },
649 );
650
651 +const decodeVitePlusConfig = Schema.decodeUnknownOption(
652 + Schema.fromJsonString(Schema.Struct({ shimMode: Schema.optional(Schema.Unknown) })),
653 +);
654 +
655 +/** With `shimMode: "system_first"` (`vp env off`), a Vite+ shim runs the next same-named command on PATH. */
656 +const followVitePlusSystemFirstShim = Effect.fn("followVitePlusSystemFirstShim")(function* (
657 + context: ProviderMaintenanceResolutionContext,
658 +) {
659 + if (!isVitePlusGlobalCommandPath(context.resolvedCommandPath)) return context;
660 + const fileSystem = yield* FileSystem.FileSystem;
661 + const path = yield* Path.Path;
662 + const shimDir = path.dirname(context.resolvedCommandPath);
663 + const dataDir = path.dirname(shimDir);
664 + // Without VP_HOME, the XDG layout keeps shims in `~/.local/share/vite-plus` and config in `$XDG_CONFIG_HOME/vite-plus`.
665 + const home = context.env.VP_HOME
666 + ? undefined
667 + : /^(.*)\/\.local\/share\/vite-plus$/.exec(dataDir.replaceAll("\\", "/"))?.[1];
668 + const configPaths = [
669 + ...(home !== undefined
670 + ? [path.join(context.env.XDG_CONFIG_HOME || path.join(home, ".config"), "vite-plus")]
671 + : []),
672 + dataDir,
673 + ].map((dir) => path.join(dir, "config.json"));
674 + const config = yield* Effect.firstSuccessOf(
675 + configPaths.map((configPath) => fileSystem.readFileString(configPath)),
676 + ).pipe(Effect.orElseSucceed(() => ""));
677 + if (Option.getOrUndefined(decodeVitePlusConfig(config))?.shimMode !== "system_first") {
678 + return context;
679 + }
680 + const delimiter = context.platform === "win32" ? ";" : ":";
681 + const dirKey = (dir: string) => normalizeCommandPath(dir).replace(/\/+$/, "");
682 + const shimDirKey = dirKey(shimDir);
683 + const env = Object.fromEntries(
684 + Object.entries(context.env).map(([name, value]) => [
685 + name,
686 + name.toLowerCase() === "path" && value
687 + ? value
688 + .split(delimiter)
689 + .filter((entry) => dirKey(entry) !== shimDirKey)
690 + .join(delimiter)
691 + : value,
692 + ]),
693 + );
694 + const command = path.basename(context.resolvedCommandPath).replace(/\.(?:exe|cmd|bat|ps1)$/i, "");
695 + const resolvedCommandPath = yield* resolveCommandPath(command, { env });
696 + if (!resolvedCommandPath) return context;
697 + const realCommandPath = yield* fileSystem
698 + .realPath(resolvedCommandPath)
699 + .pipe(Effect.orElseSucceed(() => resolvedCommandPath));
700 + return { ...context, resolvedCommandPath, realCommandPath };
701 +});
702 +
703 export const resolvePackageManagedProviderMaintenance = Effect.fn(
704 "resolvePackageManagedProviderMaintenance",
705 )(function* (
706 definition: PackageManagedProviderMaintenanceDefinition,
655 - context: ProviderMaintenanceResolutionContext | null,
707 + configuredContext: ProviderMaintenanceResolutionContext | null,
708 ) {
657 - if (!context) {
709 + if (!configuredContext) {
710 return makeManualOnlyProviderMaintenanceCapabilities({
711 provider: definition.provider,
712 packageName: definition.npmPackageName,
713 });
714 }
715 + const context = yield* followVitePlusSystemFirstShim(configuredContext);
716 const manual = makeManualOnlyProviderMaintenanceCapabilities({
717 provider: definition.provider,
718 packageName: definition.npmPackageName,