The best way to control Claude Code, Codex and more from any computer or phone
fix(server): mise-installed providers update through mise instead of their own updater (#21524)
Mise-owned providers requested as latest now update with mise upgrade <tool>; pinned tools, version paths and mise x scripts stay manual. Co-authored-by: Ryan Hughes <ryan@heyoodle.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Ryan Hughes committed
Nov 8, 2026 at 08:22 UTC
ade473018d32003658b7d38693e083ee2e314bd8
11 files changed
+705
-36
apps/server/src/provider/Drivers/ClaudeMaintenance.ts
+1
@@ -27,6 +27,7 @@ const NativeVersion = Schema.String.check(Schema.isPattern(/^\d+\.\d+\.\d+$/));
27
const update = makePackageManagedProviderMaintenanceResolver({
28
provider: ProviderDriverKind.make("claudeAgent"),
29
npmPackageName: "@anthropic-ai/claude-code",
30
+ mise: { tool: "claude" },
31
nativeUpdate: {
32
args: ["update"],
33
isCommandPath: (commandPath) => {
apps/server/src/provider/Drivers/CodexDriver.ts
+1
@@ -81,6 +81,7 @@ function makeCodexMaintenanceResolver(sharedHomePath: string) {
81
return makePackageManagedProviderMaintenanceResolver({
82
provider: DRIVER_KIND,
83
npmPackageName: "@openai/codex",
84
+ mise: { tool: "codex" },
85
nativeUpdate: {
86
args: ["update"],
87
isCommandPath: (commandPath) => codexStandaloneHome(commandPath) !== null,
docs/internals/providers.md
+10
-2
@@ -88,8 +88,16 @@ either the resolved path or its real target, since those installers place real f
88
symlinks there. Volta is proven by its `volta-shim` link plus the package's image directory. When
89
nothing is proven, the provider's own updater (`claude update`, `codex update`, `opencode upgrade`,
90
`pi update --self`, `grok update`) runs instead, because each one detects its installer itself;
91
-the runner's version check catches an updater that exits 0 without updating. Mise installs stay
92
-manual-only because their version is pinned in mise's config. A Grok cask whose Homebrew prefix
91
+the runner's version check catches an updater that exits 0 without updating. Mise is checked
92
+first, since a `mise x` wrapper can sit at a native installer's path, and `MISE_DATA_DIR` can put
93
+installs anywhere, so `mise which` is asked whenever mise is on `PATH`. Each driver names its fixed
94
+mise tool; mise must resolve the binary and list it in an active install of that tool requested as
95
+`latest`, which gets `mise upgrade <tool>`. T3 Code keeps launching the configured path, so that
96
+path must be a shim or under the tool's `latest` link, which the upgrade repoints: a version
97
+directory (including one `mise activate` put on `PATH`) would keep running the old binary until mise
98
+prunes it. Everything else mise touches (fixed version paths, pinned tools, wrappers, OpenCode 1.x,
99
+whose mise tool crosses into 2.x) stays manual-only, so T3 Code never edits mise config. `mise latest` supplies the version, because settings such as
100
+`minimum_release_age` can hold mise behind npm. A Grok cask whose Homebrew prefix
101
cannot be verified also stays manual-only: `grok update` would install a second copy. npm updates pin `--prefix` because the
102
`npm` on `PATH` can belong to a different Node than the one that owns the provider. Homebrew
103
compares against `brew info` since casks trail npm by hours; native installs share npm's version
docs/user/install.md
+8
-6
@@ -204,12 +204,14 @@ on the environment's machine. An unlisted version is unverified.
204
205
When a provider CLI is behind its latest release, its provider card shows the
206
available version. **Update now** runs the installer that owns the CLI
207
-(Homebrew, or a global npm, pnpm, Yarn, Bun, Volta, or Vite+ install), or the
208
-CLI's own update command when T3 Code cannot tell. Update a CLI installed with
209
-mise through mise. Cursor and Antigravity update with T3 Code. Homebrew and
210
-Chocolatey installs compare against the version their package manager offers,
211
-which can trail the npm release; update Claude installed with Chocolatey
212
-through Chocolatey.
207
+(Homebrew, mise, or a global npm, pnpm, Yarn, Bun, Volta, or Vite+ install), or
208
+the CLI's own update command when T3 Code cannot tell. T3 Code runs `mise upgrade`
209
+only for a tool your mise config requests as `latest` when the provider's binary
210
+path is a mise shim or under the tool's `installs/<tool>/latest` link; update a
211
+pinned version, or a path into one version's directory, through mise yourself.
212
+Cursor and Antigravity update with T3 Code. Homebrew and Chocolatey installs
213
+compare against the version their package manager offers, which can trail the
214
+npm release; update Claude installed with Chocolatey through Chocolatey.
215
216
Add another provider instance for a separate account or configuration. Each
217
instance can have its own environment variables, such as API keys or a custom
packages/provider-core/src/server/maintenanceResolver.test.ts
+482
-1
@@ -14,10 +14,10 @@ import * as Fiber from "effect/Fiber";
14
import * as Layer from "effect/Layer";
15
import * as Sink from "effect/Sink";
16
import * as Stream from "effect/Stream";
17
+import * as TestClock from "effect/testing/TestClock";
18
import * as HttpClient from "effect/http/HttpClient";
19
import * as HttpClientResponse from "effect/http/HttpClientResponse";
20
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
20
-import * as TestClock from "effect/testing/TestClock";
21
import * as ProviderLatestVersions from "./ProviderLatestVersions.ts";
22
import {
23
createProviderVersionAdvisory,
@@ -66,6 +66,12 @@ const nativePackageToolUpdate = makePackageManagedProviderMaintenanceResolver({
66
isCommandPath: isNativeTestCommandPath("/.local/bin/native-package-tool"),
67
},
68
});
69
+const miseToolUpdate = makePackageManagedProviderMaintenanceResolver({
70
+ provider: driver("packageTool"),
71
+ npmPackageName: "@example/package-tool",
72
+ mise: { tool: "package-tool" },
73
+ nativeUpdate: null,
74
+});
75
const installedPackageToolProvider: ServerProvider = {
76
instanceId: ProviderInstanceId.make("packageTool"),
77
driver: driver("packageTool"),
@@ -131,6 +137,121 @@ function stdoutSpawner(
137
});
138
}
139
140
+type MiseLatestAnswer = string | { readonly stdout?: string; readonly exitCode?: number } | "hang";
141
+
142
+/** A `mise` answering `which`, `ls --json --installed [tool]`, and `latest`, recording each call. */
143
+function miseSpawner(
144
+ answers: {
145
+ readonly which: string;
146
+ readonly latest?: MiseLatestAnswer;
147
+ readonly installed: Record<string, ReadonlyArray<unknown>>;
148
+ },
149
+ spawned: Array<ReadonlyArray<string>>,
150
+) {
151
+ return ChildProcessSpawner.make((command) => {
152
+ const { command: executable, args } = command as unknown as {
153
+ readonly command: string;
154
+ readonly args: ReadonlyArray<string>;
155
+ };
156
+ spawned.push([executable, ...args]);
157
+ const latest = answers.latest ?? "";
158
+ const hang = args[0] === "latest" && latest === "hang";
159
+ let stdout = "";
160
+ let exitCode = 0;
161
+ if (args[0] === "which") {
162
+ stdout = `${answers.which}\n`;
163
+ } else if (args[0] === "latest" && typeof latest === "string") {
164
+ stdout = latest === "hang" ? "" : `${latest}\n`;
165
+ } else if (args[0] === "latest" && typeof latest !== "string") {
166
+ stdout = latest.stdout ?? "";
167
+ exitCode = latest.exitCode ?? 0;
168
+ } else if (args[0] === "ls") {
169
+ // `mise ls --json <tool>` lists one tool's installs; without a tool, every tool's.
170
+ const tool = args.slice(1).find((arg) => !arg.startsWith("-"));
171
+ stdout = JSON.stringify(tool ? (answers.installed[tool] ?? []) : answers.installed);
172
+ } else {
173
+ exitCode = 1;
174
+ }
175
+ return Effect.succeed(
176
+ ChildProcessSpawner.makeHandle({
177
+ pid: ChildProcessSpawner.ProcessId(1),
178
+ exitCode: hang ? Effect.never : Effect.succeed(ChildProcessSpawner.ExitCode(exitCode)),
179
+ isRunning: Effect.succeed(hang),
180
+ kill: () => Effect.void,
181
+ unref: Effect.succeed(Effect.void),
182
+ stdin: Sink.drain,
183
+ stdout: hang ? Stream.never : Stream.encodeText(Stream.make(stdout)),
184
+ stderr: Stream.empty,
185
+ all: Stream.empty,
186
+ getInputFd: () => Sink.drain,
187
+ getOutputFd: () => Stream.empty,
188
+ }),
189
+ );
190
+ });
191
+}
192
+
193
+/**
194
+ * A mise binary on its own PATH dir and an install of `package-tool` 1.0.0 in its data dir,
195
+ * with the `latest` link mise keeps pointing at the newest install.
196
+ */
197
+function miseFixture(
198
+ tempDir: string,
199
+ options: {
200
+ readonly misePresent?: boolean;
201
+ readonly tool?: string;
202
+ readonly dataDir?: string;
203
+ } = {},
204
+) {
205
+ const miseBinDir = NodePath.join(tempDir, "mise-bin");
206
+ const misePath = NodePath.join(miseBinDir, "mise");
207
+ if (options.misePresent !== false) writeExecutable(misePath);
208
+ const toolDir = NodePath.join(
209
+ options.dataDir ?? NodePath.join(tempDir, "mise"),
210
+ "installs",
211
+ "package-tool",
212
+ );
213
+ const latestDir = NodePath.join(toolDir, "latest");
214
+ let installPath = "";
215
+ let binaryPath = "";
216
+ /** Installs `version` and points `latest` at it, as `mise upgrade` does. */
217
+ const install = (version: string) => {
218
+ installPath = NodePath.join(toolDir, version);
219
+ binaryPath = NodePath.join(installPath, "bin", "package-tool");
220
+ writeExecutable(binaryPath);
221
+ if (symlinksSupported) {
222
+ NodeFS.rmSync(latestDir, { force: true });
223
+ NodeFS.symlinkSync(installPath, latestDir);
224
+ }
225
+ return binaryPath;
226
+ };
227
+ install("1.0.0");
228
+ const installed = (
229
+ install: { readonly requested_version?: string; readonly active?: boolean } = {},
230
+ ) => ({
231
+ [options.tool ?? "package-tool"]: [
232
+ { install_path: installPath, requested_version: "latest", active: true, ...install },
233
+ ],
234
+ });
235
+ return {
236
+ miseBinDir,
237
+ misePath,
238
+ get binaryPath() {
239
+ return binaryPath;
240
+ },
241
+ latestBinaryPath: NodePath.join(latestDir, "bin", "package-tool"),
242
+ install,
243
+ installed,
244
+ };
245
+}
246
+
247
+/** A mise shim: a link named for the tool that points at mise itself. */
248
+function linkShim(tempDir: string, misePath: string, name: string) {
249
+ const shimPath = NodePath.join(tempDir, "mise", "shims", name);
250
+ NodeFS.mkdirSync(NodePath.dirname(shimPath), { recursive: true });
251
+ NodeFS.symlinkSync(misePath, shimPath);
252
+ return shimPath;
253
+}
254
+
255
it.layer(
256
Layer.mergeAll(
257
NodeServices.layer,
@@ -1487,6 +1608,366 @@ it.layer(
1608
}),
1609
);
1610
1611
+ it.effect.each([
1612
+ { name: "its latest link", via: "latest" },
1613
+ { name: "a latest link in a custom data dir", via: "latest", dataDir: "data" },
1614
+ { name: "a shim", via: "shim" },
1615
+ ])(
1616
+ "upgrades the mapped mise tool through $name requested as latest",
1617
+ (fixture) =>
1618
+ Effect.gen(function* () {
1619
+ const tempDir = yield* makeTempDir("t3-mise-upgrade");
1620
+ const mise = miseFixture(
1621
+ tempDir,
1622
+ fixture.dataDir ? { dataDir: NodePath.join(tempDir, fixture.dataDir) } : {},
1623
+ );
1624
+ const binaryPath =
1625
+ fixture.via === "latest"
1626
+ ? mise.latestBinaryPath
1627
+ : linkShim(tempDir, mise.misePath, "package-tool");
1628
+ const spawned: Array<ReadonlyArray<string>> = [];
1629
+
1630
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(miseToolUpdate, {
1631
+ binaryPath,
1632
+ env: { PATH: mise.miseBinDir },
1633
+ }).pipe(
1634
+ Effect.provideService(
1635
+ ChildProcessSpawner.ChildProcessSpawner,
1636
+ miseSpawner({ which: mise.binaryPath, installed: mise.installed() }, spawned),
1637
+ ),
1638
+ );
1639
+
1640
+ expect(capabilities.update).toMatchObject({
1641
+ command: "mise upgrade package-tool",
1642
+ executable: mise.misePath,
1643
+ args: ["upgrade", "package-tool"],
1644
+ });
1645
+ expect(spawned).toContainEqual([mise.misePath, "which", "package-tool"]);
1646
+ // Resolution proves ownership but never asks mise for releases.
1647
+ expect(spawned.some((args) => args[1] === "latest")).toBe(false);
1648
+ }),
1649
+ { skip: !symlinksSupported || windowsHost },
1650
+ );
1651
+
1652
+ it.effect.each([
1653
+ { name: "a pinned version", installed: { requested_version: "1.0.0" } },
1654
+ { name: "an inactive install", installed: { active: false } },
1655
+ { name: "an install of another mise tool", tool: "other-tool" },
1656
+ { name: "an install mise which does not run", which: "elsewhere" },
1657
+ { name: "an install without mise on PATH", misePresent: false },
1658
+ { name: "a provider with no mise tool", definition: "unmapped" },
1659
+ { name: "a mise x wrapper", via: "wrapper" },
1660
+ { name: "a fixed version path", via: "versioned" },
1661
+ { name: "a version mise activate put on PATH", via: "activated" },
1662
+ ] as const)(
1663
+ "leaves $name manual-only",
1664
+ (fixture) =>
1665
+ Effect.gen(function* () {
1666
+ const tempDir = yield* makeTempDir("t3-mise-manual");
1667
+ const mise = miseFixture(tempDir, {
1668
+ misePresent: !("misePresent" in fixture),
1669
+ tool: "tool" in fixture ? fixture.tool : "package-tool",
1670
+ });
1671
+ let binaryPath = symlinksSupported ? mise.latestBinaryPath : mise.binaryPath;
1672
+ let path = mise.miseBinDir;
1673
+ if ("via" in fixture && fixture.via === "versioned") {
1674
+ binaryPath = mise.binaryPath;
1675
+ } else if ("via" in fixture && fixture.via === "activated") {
1676
+ binaryPath = "package-tool";
1677
+ path = [NodePath.dirname(mise.binaryPath), mise.miseBinDir].join(NodePath.delimiter);
1678
+ } else if ("via" in fixture) {
1679
+ binaryPath = NodePath.join(tempDir, "bin", "package-tool");
1680
+ NodeFS.mkdirSync(NodePath.dirname(binaryPath), { recursive: true });
1681
+ NodeFS.writeFileSync(
1682
+ binaryPath,
1683
+ '#!/bin/sh\nexec mise x package-tool -- package-tool "$@"\n',
1684
+ );
1685
+ NodeFS.chmodSync(binaryPath, 0o755);
1686
+ }
1687
+ const which =
1688
+ "which" in fixture
1689
+ ? NodePath.join(tempDir, "elsewhere", "package-tool")
1690
+ : mise.binaryPath;
1691
+
1692
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
1693
+ "definition" in fixture ? packageToolUpdate : miseToolUpdate,
1694
+ { binaryPath, env: { PATH: path } },
1695
+ ).pipe(
1696
+ Effect.provideService(
1697
+ ChildProcessSpawner.ChildProcessSpawner,
1698
+ miseSpawner(
1699
+ {
1700
+ which,
1701
+ installed: mise.installed("installed" in fixture ? fixture.installed : {}),
1702
+ },
1703
+ [],
1704
+ ),
1705
+ ),
1706
+ );
1707
+
1708
+ expect(capabilities.update).toBeNull();
1709
+ expect(capabilities.lookupLatestVersion).toBeUndefined();
1710
+ }),
1711
+ { skip: windowsHost },
1712
+ );
1713
+
1714
+ it.effect.skipIf(windowsHost)(
1715
+ "keeps the provider's own updater for an install mise does not own",
1716
+ () =>
1717
+ Effect.gen(function* () {
1718
+ const tempDir = yield* makeTempDir("t3-mise-native");
1719
+ const nativePath = NodePath.join(tempDir, ".local", "bin", "native-package-tool");
1720
+ writeExecutable(nativePath);
1721
+ const miseMappedNative = makePackageManagedProviderMaintenanceResolver({
1722
+ provider: driver("nativePackageTool"),
1723
+ npmPackageName: "@example/native-package-tool",
1724
+ mise: { tool: "native-package-tool" },
1725
+ nativeUpdate: {
1726
+ args: ["update"],
1727
+ isCommandPath: isNativeTestCommandPath("/.local/bin/native-package-tool"),
1728
+ },
1729
+ });
1730
+
1731
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(miseMappedNative, {
1732
+ binaryPath: nativePath,
1733
+ env: { PATH: "" },
1734
+ }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
1735
+
1736
+ expect(capabilities.update).toEqual({
1737
+ command: `${nativePath} update`,
1738
+ executable: nativePath,
1739
+ args: ["update"],
1740
+ lockKey: "nativePackageTool-native",
1741
+ });
1742
+ }),
1743
+ );
1744
+
1745
+ it.effect.each([
1746
+ {
1747
+ name: "a mise tool whose upgrades are disabled",
1748
+ mise: { tool: "package-tool", upgrade: false },
1749
+ },
1750
+ { name: "a pinned mise tool", mise: { tool: "package-tool" }, pinned: true },
1751
+ {
1752
+ name: "an inactive version of a mise tool",
1753
+ mise: { tool: "package-tool" },
1754
+ inactive: true,
1755
+ },
1756
+ {
1757
+ name: "an inactive version of a mise tool whose upgrades are disabled",
1758
+ mise: { tool: "package-tool", upgrade: false },
1759
+ inactive: true,
1760
+ },
1761
+ ] as const)(
1762
+ "keeps $name in a custom data dir manual-only instead of running its own updater",
1763
+ (fixture) =>
1764
+ Effect.gen(function* () {
1765
+ const tempDir = yield* makeTempDir("t3-mise-custom-manual");
1766
+ const mise = miseFixture(tempDir, { dataDir: NodePath.join(tempDir, "data") });
1767
+ let binaryPath = mise.latestBinaryPath;
1768
+ let installed = mise.installed("pinned" in fixture ? { requested_version: "1.0.0" } : {});
1769
+ if ("inactive" in fixture) {
1770
+ // Configured to 1.0.0 while mise resolves its active 2.0.0 instead.
1771
+ binaryPath = mise.binaryPath;
1772
+ const inactive = { ...installed["package-tool"]![0]!, active: false };
1773
+ mise.install("2.0.0");
1774
+ installed = { "package-tool": [inactive, ...mise.installed()["package-tool"]!] };
1775
+ }
1776
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
1777
+ makePackageManagedProviderMaintenanceResolver({
1778
+ provider: driver("packageTool"),
1779
+ npmPackageName: "@example/package-tool",
1780
+ mise: fixture.mise,
1781
+ nativeUpdate: { args: ["upgrade"] },
1782
+ }),
1783
+ { binaryPath, env: { PATH: mise.miseBinDir } },
1784
+ ).pipe(
1785
+ Effect.provideService(
1786
+ ChildProcessSpawner.ChildProcessSpawner,
1787
+ miseSpawner({ which: mise.binaryPath, installed }, []),
1788
+ ),
1789
+ );
1790
+
1791
+ expect(capabilities.update).toBeNull();
1792
+ }),
1793
+ { skip: !symlinksSupported || windowsHost },
1794
+ );
1795
+
1796
+ it.effect.skipIf(!symlinksSupported || windowsHost)(
1797
+ "updates an npm global under mise's Node with npm even when mise runs it",
1798
+ () =>
1799
+ Effect.gen(function* () {
1800
+ const tempDir = yield* makeTempDir("t3-mise-node-npm");
1801
+ const mise = miseFixture(tempDir);
1802
+ const nodePrefix = NodePath.join(tempDir, "mise", "installs", "node", "22.0.0");
1803
+ const binaryPath = NodePath.join(nodePrefix, "bin", "package-tool");
1804
+ const target = NodePath.join(
1805
+ nodePrefix,
1806
+ "lib",
1807
+ "node_modules",
1808
+ "@example",
1809
+ "package-tool",
1810
+ "bin",
1811
+ "package-tool.js",
1812
+ );
1813
+ writeExecutable(target);
1814
+ NodeFS.mkdirSync(NodePath.dirname(binaryPath), { recursive: true });
1815
+ NodeFS.symlinkSync(target, binaryPath);
1816
+
1817
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(miseToolUpdate, {
1818
+ binaryPath,
1819
+ env: { PATH: mise.miseBinDir },
1820
+ }).pipe(
1821
+ Effect.provideService(
1822
+ ChildProcessSpawner.ChildProcessSpawner,
1823
+ // mise resolves the npm global through its Node; no `package-tool` tool is installed.
1824
+ miseSpawner({ which: binaryPath, installed: {} }, []),
1825
+ ),
1826
+ );
1827
+
1828
+ expect(capabilities.update?.args).toEqual([
1829
+ "install",
1830
+ "-g",
1831
+ "--prefix",
1832
+ NodeFS.realpathSync(nodePrefix),
1833
+ "--allow-scripts=@example/package-tool",
1834
+ "@example/package-tool@latest",
1835
+ ]);
1836
+ }),
1837
+ );
1838
+
1839
+ it.effect.skipIf(!symlinksSupported || windowsHost)(
1840
+ "asks mise for its latest release only while update checks are enabled",
1841
+ () =>
1842
+ Effect.gen(function* () {
1843
+ const tempDir = yield* makeTempDir("t3-mise-latest");
1844
+ const mise = miseFixture(tempDir);
1845
+ const spawned: Array<ReadonlyArray<string>> = [];
1846
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(miseToolUpdate, {
1847
+ binaryPath: mise.latestBinaryPath,
1848
+ env: { PATH: mise.miseBinDir },
1849
+ }).pipe(
1850
+ Effect.provideService(
1851
+ ChildProcessSpawner.ChildProcessSpawner,
1852
+ miseSpawner(
1853
+ // mise's `minimum_release_age` can hold it behind npm's 1.2.0.
1854
+ { which: mise.binaryPath, latest: "1.1.0", installed: mise.installed() },
1855
+ spawned,
1856
+ ),
1857
+ ),
1858
+ );
1859
+ const advise = (enableProviderUpdateChecks: boolean) =>
1860
+ enrichProviderSnapshotWithVersionAdvisory(installedPackageToolProvider, capabilities, {
1861
+ enableProviderUpdateChecks,
1862
+ });
1863
+
1864
+ expect((yield* advise(false)).versionAdvisory).toMatchObject({
1865
+ status: "unknown",
1866
+ latestVersion: null,
1867
+ });
1868
+ expect(spawned.filter((args) => args[1] === "latest")).toEqual([]);
1869
+
1870
+ expect((yield* advise(true)).versionAdvisory).toMatchObject({
1871
+ status: "behind_latest",
1872
+ latestVersion: "1.1.0",
1873
+ });
1874
+ expect((yield* advise(true)).versionAdvisory?.latestVersion).toBe("1.1.0");
1875
+ expect(spawned.filter((args) => args[1] === "latest")).toEqual([
1876
+ [mise.misePath, "latest", "package-tool"],
1877
+ ]);
1878
+ }).pipe(
1879
+ Effect.provide(ProviderLatestVersions.layer),
1880
+ Effect.provideService(
1881
+ HttpClient.HttpClient,
1882
+ HttpClient.make(() => Effect.die("mise answers for its own installs")),
1883
+ ),
1884
+ ),
1885
+ );
1886
+
1887
+ it.effect.skipIf(!symlinksSupported || windowsHost)(
1888
+ "keeps each mise environment's latest release apart",
1889
+ () =>
1890
+ Effect.gen(function* () {
1891
+ const tempDir = yield* makeTempDir("t3-mise-latest-env");
1892
+ const mise = miseFixture(tempDir);
1893
+ const advise = (env: NodeJS.ProcessEnv, latest: string) =>
1894
+ resolveProviderMaintenanceCapabilitiesEffect(miseToolUpdate, {
1895
+ binaryPath: mise.latestBinaryPath,
1896
+ env: { PATH: mise.miseBinDir, ...env },
1897
+ }).pipe(
1898
+ Effect.provideService(
1899
+ ChildProcessSpawner.ChildProcessSpawner,
1900
+ miseSpawner({ which: mise.binaryPath, latest, installed: mise.installed() }, []),
1901
+ ),
1902
+ Effect.flatMap((capabilities) =>
1903
+ enrichProviderSnapshotWithVersionAdvisory(
1904
+ installedPackageToolProvider,
1905
+ capabilities,
1906
+ {
1907
+ enableProviderUpdateChecks: true,
1908
+ },
1909
+ ),
1910
+ ),
1911
+ Effect.map((snapshot) => snapshot.versionAdvisory?.latestVersion),
1912
+ );
1913
+
1914
+ expect(yield* advise({ MISE_MINIMUM_RELEASE_AGE: "7d" }, "1.1.0")).toBe("1.1.0");
1915
+ expect(yield* advise({}, "1.2.0")).toBe("1.2.0");
1916
+ expect(yield* advise({ MISE_MINIMUM_RELEASE_AGE: "7d" }, "1.2.0")).toBe("1.1.0");
1917
+ }).pipe(
1918
+ Effect.provide(ProviderLatestVersions.layer),
1919
+ Effect.provideService(
1920
+ HttpClient.HttpClient,
1921
+ HttpClient.make(() => Effect.die("mise answers for its own installs")),
1922
+ ),
1923
+ ),
1924
+ );
1925
+
1926
+ it.effect.each([
1927
+ { name: "fails", latest: { exitCode: 1 } },
1928
+ { name: "prints nothing", latest: { stdout: "" } },
1929
+ { name: "never answers", latest: "hang" },
1930
+ ] as const)(
1931
+ "reports an unknown latest version when mise latest $name",
1932
+ (fixture) =>
1933
+ Effect.gen(function* () {
1934
+ const tempDir = yield* makeTempDir("t3-mise-latest-unknown");
1935
+ const mise = miseFixture(tempDir);
1936
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(miseToolUpdate, {
1937
+ binaryPath: mise.latestBinaryPath,
1938
+ env: { PATH: mise.miseBinDir },
1939
+ }).pipe(
1940
+ Effect.provideService(
1941
+ ChildProcessSpawner.ChildProcessSpawner,
1942
+ miseSpawner(
1943
+ { which: mise.binaryPath, latest: fixture.latest, installed: mise.installed() },
1944
+ [],
1945
+ ),
1946
+ ),
1947
+ );
1948
+ expect(capabilities.update).toMatchObject({ args: ["upgrade", "package-tool"] });
1949
+
1950
+ const advisory = yield* enrichProviderSnapshotWithVersionAdvisory(
1951
+ installedPackageToolProvider,
1952
+ capabilities,
1953
+ { enableProviderUpdateChecks: true },
1954
+ ).pipe(Effect.forkChild);
1955
+ yield* TestClock.adjust("1 minute");
1956
+
1957
+ expect((yield* Fiber.join(advisory)).versionAdvisory).toMatchObject({
1958
+ status: "unknown",
1959
+ latestVersion: null,
1960
+ });
1961
+ }).pipe(
1962
+ Effect.provide(ProviderLatestVersions.layer),
1963
+ Effect.provideService(
1964
+ HttpClient.HttpClient,
1965
+ HttpClient.make(() => Effect.die("an offline mise must not fall back to npm")),
1966
+ ),
1967
+ ),
1968
+ { skip: !symlinksSupported || windowsHost },
1969
+ );
1970
+
1971
it.effect.skipIf(!symlinksSupported)("updates Yarn global installs with yarn", () =>
1972
Effect.gen(function* () {
1973
const tempDir = yield* makeTempDir("t3-yarn-capabilities");
packages/provider-core/src/server/maintenanceResolver.ts
+162
-16
@@ -1,3 +1,5 @@
1
+// @effect-diagnostics nodeBuiltinImport:off -- Synchronous hashing keeps env values out of cache keys.
2
+import * as NodeCrypto from "node:crypto";
3
export type {
4
ProviderMaintenanceCapabilities,
5
ProviderMaintenanceCommandAction,
@@ -92,6 +94,14 @@ export interface PackageManagedProviderMaintenanceDefinition {
94
| NodeJS.ProcessEnv
95
| ((context: ProviderMaintenanceResolutionContext) => NodeJS.ProcessEnv);
96
} | null;
97
+ /** The mise registry tool that installs this provider; unset keeps mise installs manual-only. */
98
+ readonly mise?: MiseProviderTool;
99
+}
100
+
101
+export interface MiseProviderTool {
102
+ readonly tool: string;
103
+ /** False still claims the tool's installs, but keeps them manual-only. */
104
+ readonly upgrade?: boolean;
105
}
106
107
const NpmLatestVersionResponse = Schema.Struct({
@@ -242,19 +252,23 @@ function isYarnGlobalCommandPath(commandPath: string): boolean {
252
}
253
254
/**
245
- * Version-manager installs are pinned in its config, so updating them means editing that.
255
+ * Paths mise owns. npm globals under mise's own Node belong to npm, which proves their prefix.
256
* A command wrapper is a symlink to the `mise` binary, which dispatches on argv[0].
257
*/
258
function isMiseCommandPath(commandPath: string): boolean {
259
const normalized = normalizeCommandPath(commandPath);
260
return (
251
- normalized.includes("/mise/installs/") ||
261
+ (normalized.includes("/mise/installs/") && !normalized.includes("/mise/installs/node/")) ||
262
normalized.includes("/mise/shims/") ||
253
- normalized.includes("/mise/command-wrappers/") ||
254
- /\/mise(?:\.exe)?$/.test(normalized)
263
+ normalized.includes("/mise/command-wrappers/")
264
);
265
}
266
267
+/** A mise shim or command wrapper is a link to mise itself, wherever mise keeps its data. */
268
+function isMiseExecutablePath(commandPath: string): boolean {
269
+ return /(?:^|\/)mise(?:\.exe)?$/.test(normalizeCommandPath(commandPath));
270
+}
271
+
272
const winGetClaudeCommandPath =
273
/^[a-z]:\/(?:users\/[^/]+\/appdata\/local\/microsoft|program files(?: \(x86\))?)\/winget\/(?:links|packages\/anthropic\.claudecode_[^/]+)\/claude\.exe$/;
274
@@ -463,6 +477,141 @@ const resolvePnpmGlobalLatestVersion = Effect.fn("resolvePnpmGlobalLatestVersion
477
return nonEmptyString(listedEntries?.[0]?.dependencies?.[packageName]?.version);
478
});
479
480
+const MiseInstall = Schema.Struct({
481
+ install_path: Schema.String,
482
+ requested_version: Schema.optional(Schema.NullOr(Schema.String)),
483
+ active: Schema.optional(Schema.Boolean),
484
+});
485
+const decodeMiseToolInstalls = Schema.decodeUnknownOption(
486
+ Schema.fromJsonString(Schema.Array(MiseInstall)),
487
+);
488
+const decodeMiseInstalls = Schema.decodeUnknownOption(
489
+ Schema.fromJsonString(Schema.Record(Schema.String, Schema.Array(MiseInstall))),
490
+);
491
+
492
+/** The installs `mise ls --json --installed <tool>` lists, refusing any other tool's. */
493
+function miseToolInstalls(
494
+ listing: string,
495
+ miseTool: string,
496
+): ReadonlyArray<typeof MiseInstall.Type> {
497
+ const installs = decodeMiseToolInstalls(listing);
498
+ if (Option.isSome(installs)) return installs.value;
499
+ const byTool = Option.getOrUndefined(decodeMiseInstalls(listing));
500
+ return byTool && Object.keys(byTool).every((tool) => tool === miseTool)
501
+ ? (byTool[miseTool] ?? [])
502
+ : [];
503
+}
504
+
505
+/**
506
+ * Null when mise does not own the executable. Upgrades need an active `latest` install of the
507
+ * driver's fixed mise tool, launched through a shim or the `latest` link `mise upgrade` moves;
508
+ * a fixed version's path would keep running the pruned binary, so it stays manual-only.
509
+ */
510
+export const resolveMiseProviderMaintenance = Effect.fn("resolveMiseProviderMaintenance")(
511
+ function* (
512
+ owner: { readonly provider: ProviderDriverKind; readonly packageName: string | null },
513
+ mise: MiseProviderTool | undefined,
514
+ context: ProviderMaintenanceResolutionContext,
515
+ ) {
516
+ const commandPaths = [context.resolvedCommandPath, context.realCommandPath];
517
+ const isShim = isMiseExecutablePath(context.realCommandPath);
518
+ const looksMise =
519
+ isShim || commandPaths.some(isMiseCommandPath) || (yield* isMiseWrapperScript(context));
520
+ const manual = (installPath: string) =>
521
+ makeManualOnlyProviderMaintenanceCapabilities({ ...owner, installPath });
522
+ const notOwned = (installPath: string) => (looksMise ? manual(installPath) : null);
523
+ const commandName = normalizeCommandPath(context.resolvedCommandPath)
524
+ .split("/")
525
+ .at(-1)
526
+ ?.replace(/\.(?:exe|cmd|bat|ps1)$/, "");
527
+ if (!mise) return notOwned(context.realCommandPath);
528
+ const miseTool = mise.tool;
529
+ // A shim runs whatever mise resolves for its own name, which must be the mapped tool's.
530
+ if (isShim && commandName !== miseTool) return manual(context.realCommandPath);
531
+
532
+ const fileSystem = yield* FileSystem.FileSystem;
533
+ const realPath = (target: string) =>
534
+ fileSystem.realPath(target).pipe(Effect.orElseSucceed(() => target));
535
+ const misePath =
536
+ (yield* resolveCommandPath("mise", { env: context.env })) ??
537
+ (isShim ? context.realCommandPath : null);
538
+ if (!misePath) return notOwned(context.realCommandPath);
539
+ // Asked even off mise's usual paths, since `MISE_DATA_DIR` can put installs anywhere.
540
+ const which = nonEmptyString(yield* runProbe(misePath, ["which", miseTool], context.env));
541
+ const resolvedPath = which ? yield* realPath(which) : null;
542
+ // Through a shim T3 Code runs whatever mise resolves; otherwise the configured binary.
543
+ const binaryPath = isShim ? resolvedPath : context.realCommandPath;
544
+ if (!binaryPath) return manual(context.realCommandPath);
545
+ const binary = normalizeCommandPath(binaryPath);
546
+ const runsBinary = resolvedPath !== null && normalizeCommandPath(resolvedPath) === binary;
547
+ const listing = yield* runProbe(
548
+ misePath,
549
+ ["ls", "--json", "--installed", miseTool],
550
+ context.env,
551
+ );
552
+ if (!listing) return runsBinary ? manual(binaryPath) : notOwned(binaryPath);
553
+ const isUnder = (path: string, dir: string) =>
554
+ path.startsWith(`${normalizeCommandPath(dir).replace(/\/+$/, "")}/`);
555
+ // An inactive or shadowed install is still mise's, even when `mise which` resolves another.
556
+ const owning = yield* Effect.filter(miseToolInstalls(listing, miseTool), (install) =>
557
+ realPath(install.install_path).pipe(
558
+ Effect.map((installPath) => isUnder(binary, installPath)),
559
+ ),
560
+ );
561
+ // `mise which` also resolves binaries from other tools, such as npm globals under mise's Node.
562
+ if (owning.length === 0) return notOwned(binaryPath);
563
+ if (!runsBinary) return manual(binaryPath);
564
+ const install = owning.find(
565
+ (candidate) => candidate.active === true && candidate.requested_version === "latest",
566
+ );
567
+ if (!install || mise.upgrade === false) return manual(binaryPath);
568
+ if (!isShim) {
569
+ // Keep the path's case: `realPath` needs it on case-sensitive filesystems.
570
+ const toolDir = install.install_path
571
+ .replaceAll("\\", "/")
572
+ .replace(/\/+$/, "")
573
+ .replace(/\/[^/]+$/, "");
574
+ const latestDirs = [toolDir, yield* realPath(toolDir)].map((dir) => `${dir}/latest`);
575
+ const resolved = normalizeCommandPath(context.resolvedCommandPath);
576
+ if (!latestDirs.some((dir) => isUnder(resolved, dir))) return manual(binaryPath);
577
+ }
578
+ const args = ["upgrade", miseTool];
579
+ const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
580
+ // Mise reads its settings from this environment, so each one gets its own cached answer.
581
+ const envHash = NodeCrypto.createHash("sha256");
582
+ for (const [name, value] of Object.entries(context.env).toSorted(([a], [b]) =>
583
+ a < b ? -1 : 1,
584
+ )) {
585
+ envHash.update(`${name}\0${value ?? ""}\0`);
586
+ }
587
+ const envKey = envHash.digest("hex");
588
+ const capabilities = makeProviderMaintenanceCapabilities({
589
+ ...owner,
590
+ updateExecutable: misePath,
591
+ updateArgs: args,
592
+ updateLockKey: "mise",
593
+ updateCommand: ["mise", ...args].join(" "),
594
+ platform: context.platform,
595
+ // Mise read its config from this environment, so the upgrade runs in it too.
596
+ env: context.env,
597
+ // Settings such as `minimum_release_age` can hold mise behind the registry,
598
+ // so only mise can say what it installs. It may go to the network, so ask lazily.
599
+ latestVersion: null,
600
+ lookupLatestVersion: runProbe(misePath, ["latest", miseTool], context.env).pipe(
601
+ Effect.map((latest) => {
602
+ const version = nonEmptyString(latest);
603
+ return version && /^\S+$/.test(version) ? version : null;
604
+ }),
605
+ Effect.provideContext(services),
606
+ ),
607
+ });
608
+ return {
609
+ ...capabilities,
610
+ latestVersionCacheKey: ["mise", misePath, miseTool, envKey].join("\0"),
611
+ };
612
+ },
613
+);
614
+
615
export const resolvePackageManagedProviderMaintenance = Effect.fn(
616
"resolvePackageManagedProviderMaintenance",
617
)(function* (
@@ -517,6 +666,13 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
666
});
667
}
668
669
+ const mise = yield* resolveMiseProviderMaintenance(
670
+ { provider: definition.provider, packageName },
671
+ definition.mise,
672
+ context,
673
+ );
674
+ if (mise) return mise;
675
+
676
const nativeUpdate = definition.nativeUpdate;
677
const nativeEnv = nativeUpdate?.env;
678
const native = nativeUpdate
@@ -532,13 +688,11 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
688
: {}),
689
})
690
: manual;
535
- // A native-looking launcher can still delegate to an npm- or mise-owned install.
691
+ // A native-looking launcher can still delegate to an npm-owned install.
692
if (
693
nativeUpdate?.isCommandPath &&
694
commandPaths.some(nativeUpdate.isCommandPath) &&
539
- !npmGlobalPrefixFromCommandPath(context.realCommandPath, packageName) &&
540
- !commandPaths.some(isMiseCommandPath) &&
541
- !(yield* isMiseWrapperScript(context))
695
+ !npmGlobalPrefixFromCommandPath(context.realCommandPath, packageName)
696
) {
697
return native;
698
}
@@ -633,14 +787,6 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
787
}
788
789
const homebrew = homebrewOwnershipFromCommandPath(context.realCommandPath);
636
- if (
637
- commandPaths.some(isMiseCommandPath) ||
638
- // Mise shims resolve to the version manager's keg, not the provider's.
639
- (homebrew?.kind === "formula" && homebrew.name.toLowerCase() === "mise") ||
640
- (yield* isMiseWrapperScript(context))
641
- ) {
642
- return manual;
643
- }
790
if (homebrew) {
791
return (
792
(yield* resolveHomebrewProviderMaintenance(
packages/provider-grok/src/server/driver.ts
+10
-3
@@ -37,6 +37,7 @@ import {
37
makeProviderMaintenanceCapabilities,
38
type ProviderMaintenanceCapabilitiesResolver,
39
resolveHomebrewProviderMaintenance,
40
+ resolveMiseProviderMaintenance,
41
resolveProviderMaintenanceCapabilitiesEffect,
42
} from "@t3tools/provider-core/server/maintenanceResolver";
43
import {
@@ -49,10 +50,10 @@ const decodeGrokSettings = Schema.decodeSync(GrokSettings);
50
const DRIVER_KIND = ProviderDriverKind.make("grok");
51
// npm latest matches the stable channel installed by grok update.
52
const GROK_NPM_PACKAGE = "@xai-official/grok";
52
-// `grok update` installs under `GROK_HOME`; use the resolved executable and instance environment.
53
+// `grok update` installs under `GROK_HOME` from the resolved executable and instance environment.
54
// npm 12 blocks the postinstall that moves the new binary in, yet exits 0, so allow it by env.
54
-// Homebrew casks need brew upgrades; `grok update` would install a second copy.
55
-// Keep casks manual when their brew cannot vouch for them.
55
+// Mise and Homebrew casks upgrade through their manager; `grok update` would install a second
56
+// copy, so a cask its brew cannot vouch for stays manual.
57
const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
58
resolve: Effect.fn("resolveGrokMaintenance")(function* (context) {
59
if (!context) {
@@ -61,6 +62,12 @@ const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
62
packageName: GROK_NPM_PACKAGE,
63
});
64
}
65
+ const mise = yield* resolveMiseProviderMaintenance(
66
+ { provider: DRIVER_KIND, packageName: GROK_NPM_PACKAGE },
67
+ { tool: "grok" },
68
+ context,
69
+ );
70
+ if (mise) return mise;
71
const homebrew = homebrewOwnershipFromCommandPath(context.realCommandPath);
72
// Only a cask is Grok's: a formula keg such as `node` holding an npm global is not.
73
if (homebrew?.kind === "cask") {
packages/provider-muse/src/server/driver.ts
+7
-6
@@ -121,12 +121,13 @@ export const MuseDriver: ProviderDriver<
121
const capabilities = yield* resolveInstallation(options);
122
// The maintenance runner requests fresh capabilities around an explicit update
123
// and needs the native target version to verify that the command actually upgraded.
124
- const latestVersion = options?.fresh
125
- ? yield* latestMuseVersion(processEnvironment, { fresh: true }).pipe(
126
- Effect.provideService(HttpClient.HttpClient, httpClient),
127
- Effect.provideService(ProviderLatestVersions.ProviderLatestVersions, latestVersions),
128
- )
129
- : undefined;
124
+ const latestVersion =
125
+ options?.fresh && !capabilities.lookupLatestVersion
126
+ ? yield* latestMuseVersion(processEnvironment, { fresh: true }).pipe(
127
+ Effect.provideService(HttpClient.HttpClient, httpClient),
128
+ Effect.provideService(ProviderLatestVersions.ProviderLatestVersions, latestVersions),
129
+ )
130
+ : undefined;
131
return latestVersion !== undefined ? { ...capabilities, latestVersion } : capabilities;
132
});
133
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<MuseSettings>>({
packages/provider-muse/src/server/maintenance.ts
+21
-2
@@ -12,6 +12,7 @@ import {
12
makeProviderMaintenanceCapabilities,
13
type ProviderMaintenanceCapabilities,
14
type ProviderMaintenanceCapabilitiesResolver,
15
+ resolveMiseProviderMaintenance,
16
} from "@t3tools/provider-core/server/maintenanceResolver";
17
import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions";
18
import { parseGenericCliVersion } from "@t3tools/provider-core/server/snapshotProbe";
@@ -37,7 +38,10 @@ export const compareMuseVersions = (current: string, latest: string) =>
38
? compareSemverVersions(comparableMuseVersion(current), comparableMuseVersion(latest))
39
: compareSemverVersions(current.replace(MUSE_REVISION, ""), latest.replace(MUSE_REVISION, ""));
40
40
-/** Only the official launcher owns an update channel; a standalone binary cannot update itself. */
41
+/**
42
+ * Mise upgrades a binary it installed. Otherwise only the official launcher owns
43
+ * an update channel; a standalone binary cannot update itself.
44
+ */
45
export const museMaintenance: ProviderMaintenanceCapabilitiesResolver = {
46
resolve: Effect.fn("MuseMaintenance.resolve")(function* (context) {
47
const manual = {
@@ -45,6 +49,12 @@ export const museMaintenance: ProviderMaintenanceCapabilitiesResolver = {
49
compareVersions: compareMuseVersions,
50
};
51
if (!context || context.platform === "win32") return manual;
52
+ const mise = yield* resolveMiseProviderMaintenance(
53
+ { provider: DRIVER, packageName: null },
54
+ { tool: "muse" },
55
+ context,
56
+ );
57
+ if (mise) return { ...mise, compareVersions: compareMuseVersions };
58
const fs = yield* FileSystem.FileSystem;
59
const isLauncher = yield* Effect.gen(function* () {
60
const stat = yield* fs.stat(context.realCommandPath);
@@ -119,6 +129,15 @@ export const enrichMuseSnapshot = Effect.fn("enrichMuseSnapshot")(function* (inp
129
readonly environment: NodeJS.ProcessEnv;
130
}) {
131
const { snapshot } = input;
132
+ const options = { enableProviderUpdateChecks: input.enableProviderUpdateChecks };
133
+ // Mise names the version it would install, so its answer alone counts.
134
+ if (input.maintenanceCapabilities.lookupLatestVersion) {
135
+ return yield* enrichProviderSnapshotWithVersionAdvisory(
136
+ snapshot,
137
+ input.maintenanceCapabilities,
138
+ options,
139
+ );
140
+ }
141
const latestVersion =
142
input.enableProviderUpdateChecks && snapshot.enabled && snapshot.installed && snapshot.version
143
? yield* latestMuseVersion(input.environment)
@@ -126,6 +145,6 @@ export const enrichMuseSnapshot = Effect.fn("enrichMuseSnapshot")(function* (inp
145
return yield* enrichProviderSnapshotWithVersionAdvisory(
146
snapshot,
147
{ ...input.maintenanceCapabilities, latestVersion },
129
- { enableProviderUpdateChecks: input.enableProviderUpdateChecks },
148
+ options,
149
);
150
});
packages/provider-opencode/src/server/driver.ts
+2
@@ -88,6 +88,8 @@ export const openCodeUpdateFor = (generation: ProbedOpenCode["generation"]) =>
88
isCommandPath: isOpenCodeNativeCommandPath,
89
requiresCommandPath: true,
90
},
91
+ // mise's `opencode` follows releases into 2.x, so it would upgrade 1.x across that line.
92
+ mise: { tool: "opencode", upgrade: generation === "v2" },
93
});
94
95
type OpenCodeRuntimeProbe = Effect.Success<
packages/provider-pi/src/server/driver.ts
+1
@@ -45,6 +45,7 @@ const DRIVER_KIND = ProviderDriverKind.make("pi");
45
const UPDATE = makePackageManagedProviderMaintenanceResolver({
46
provider: DRIVER_KIND,
47
npmPackageName: "@earendil-works/pi-coding-agent",
48
+ mise: { tool: "pi" },
49
nativeUpdate: { args: ["update", "--self"] },
50
});
51