The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 12:00 UTC
fix(provider-muse): Muse turns no longer fail when the project path's case differs from the disk (#22346)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Nishchay Chandra committed
Oct 31, 2026 at 02:09 UTC
5033239dec868def062f4ea3c513f964087d36b3
4 files changed
+94
-8
packages/provider-muse/src/server/adapter.test.ts
+35
@@ -1,3 +1,6 @@
1
+// @effect-diagnostics-next-line nodeBuiltinImport:off -- Mock native realpath to exercise macOS case correction on every platform.
2
+import * as NodeFSP from "node:fs/promises";
3
+import { vi } from "vite-plus/test";
4
import { assert, describe, it } from "@effect/vitest";
5
import * as NodeServices from "@effect/platform-node/NodeServices";
6
import { MspError } from "@muse-code/sdk";
@@ -379,6 +382,8 @@ const approval = (turnId: string) => ({
382
subject: { kind: "shell", command: "touch result.txt" },
383
});
384
385
+vi.mock("node:fs/promises", { spy: true });
386
+
387
describe("MuseAdapterV2", () => {
388
it.effect("connects the thread's MCP credential on native start and resume", () =>
389
Effect.gen(function* () {
@@ -569,6 +574,36 @@ describe("MuseAdapterV2", () => {
574
),
575
);
576
577
+ it.effect("pins sessions and turns to native canonical case", () =>
578
+ Effect.gen(function* () {
579
+ using _realpath = vi.spyOn(NodeFSP, "realpath").mockResolvedValue("/workspace/eevee");
580
+ const fake = yield* makeFakeMuse();
581
+ const policy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
582
+ ...runtimePolicy,
583
+ cwd: "/workspace/EEVEE",
584
+ });
585
+ const harness = yield* makeHarness(
586
+ fake,
587
+ INSTANCE_ID,
588
+ undefined,
589
+ undefined,
590
+ undefined,
591
+ policy,
592
+ );
593
+ yield* startConversation(harness, fake);
594
+ const sessionStart = fake.calls.find((call) => call.method === "session/start");
595
+ const turnStart = fake.calls.find((call) => call.method === "turn/start");
596
+ assert.strictEqual(sessionStart?.params.workspaceRoot, "/workspace/eevee");
597
+ assert.deepStrictEqual(turnStart?.params.workspaceRoots, [
598
+ sessionStart?.params.workspaceRoot,
599
+ ]);
600
+ }).pipe(
601
+ Effect.scoped,
602
+ Effect.provide(testLayer),
603
+ Effect.provideService(HostProcess.Platform, "darwin"),
604
+ ),
605
+ );
606
+
607
it.effect("stops at a Meta usage limit until every exhausted window resets", () =>
608
Effect.gen(function* () {
609
const fake = yield* makeFakeMuse();
packages/provider-muse/src/server/adapter.ts
+3
-4
@@ -65,6 +65,7 @@ import { isMuseUsageLimitFailure, museUsageLimitResetAt } from "./usageLimits.ts
65
import {
66
createMuseSdkHostEffect,
67
museApprovalMode,
68
+ museCanonicalPath,
69
musePermissionProfile,
70
museWorkspaceRoot,
71
type createMuseSdkHost,
@@ -289,11 +290,9 @@ export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
290
if (input.runtimePolicy.interactionMode === "plan")
291
return yield* protocolError("Muse Code does not support dedicated Plan mode");
292
const scope = yield* Effect.scope;
292
- // Muse requires canonical workspace roots and approval paths; resolve symlinks once.
293
+ // Native realpath also corrects filesystem case, which Muse validates.
294
const requestedCwd = input.runtimePolicy.cwd ?? providerHost.paths.cwd;
294
- const cwd = yield* fileSystem
295
- .realPath(requestedCwd)
296
- .pipe(Effect.orElseSucceed(() => requestedCwd));
295
+ const cwd = yield* museCanonicalPath(requestedCwd);
296
const workspaceRoot = yield* museWorkspaceRoot(cwd);
297
const now = yield* DateTime.now;
298
let session: OrchestrationV2ProviderSession = {
packages/provider-muse/src/server/sdk.test.ts
+46
-1
@@ -1,3 +1,5 @@
1
+// @effect-diagnostics-next-line nodeBuiltinImport:off -- Mock native realpath to exercise macOS case correction on every platform.
2
+import * as NodeFSP from "node:fs/promises";
3
// @effect-diagnostics-next-line nodeBuiltinImport:off -- The Muse SDK spawns with Node's child_process, so the launch test quotes arguments the same way.
4
import * as NodeChildProcess from "node:child_process";
5
import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -21,6 +23,8 @@ import {
23
type MuseSdkHost,
24
} from "./sdk.ts";
25
26
+vi.mock("node:fs/promises", { spy: true });
27
+
28
vi.mock("@muse-code/sdk", () => ({ spawnMspConnection: vi.fn() }));
29
30
function pending<A>() {
@@ -311,13 +315,54 @@ describe("Muse launch", () => {
315
});
316
317
describe("Muse workspace root", () => {
318
+ it.effect("uses native canonical case off Windows", () =>
319
+ Effect.gen(function* () {
320
+ using _realpath = vi.spyOn(NodeFSP, "realpath").mockResolvedValue("/workspace/eevee");
321
+ expect(yield* museWorkspaceRoot("/workspace/EEVEE")).toBe("/workspace/eevee");
322
+ }).pipe(Effect.provideService(HostProcess.Platform, "darwin")),
323
+ );
324
+
325
it("writes Windows paths in their verbatim form", () => {
326
expect(museVerbatimPath("C:\\Users\\Person\\repo")).toBe("\\\\?\\C:\\Users\\Person\\repo");
327
expect(museVerbatimPath("\\\\server\\share\\repo")).toBe("\\\\?\\UNC\\server\\share\\repo");
328
expect(museVerbatimPath("\\\\?\\C:\\repo")).toBe("\\\\?\\C:\\repo");
329
});
330
320
- // FileSystem.realPath keeps the case it is given; Muse rejects a root whose case differs from the disk's.
331
+ it.effect("keeps a root it cannot resolve off Windows", () =>
332
+ Effect.gen(function* () {
333
+ expect(yield* museWorkspaceRoot("/workspace/repo")).toBe("/workspace/repo");
334
+ }).pipe(Effect.provideService(HostProcess.Platform, "linux")),
335
+ );
336
+
337
+ it.effect("keeps a Windows root it cannot resolve, in verbatim form", () =>
338
+ Effect.gen(function* () {
339
+ expect(yield* museWorkspaceRoot("C:\\definitely-missing\\repo")).toBe(
340
+ "\\\\?\\C:\\definitely-missing\\repo",
341
+ );
342
+ expect(yield* museWorkspaceRoot("C:/definitely-missing/repo")).toBe(
343
+ "\\\\?\\C:\\definitely-missing\\repo",
344
+ );
345
+ expect(yield* museWorkspaceRoot("//server/share/missing")).toBe(
346
+ "\\\\?\\UNC\\server\\share\\missing",
347
+ );
348
+ }).pipe(Effect.provideService(HostProcess.Platform, "win32")),
349
+ );
350
+
351
+ // FileSystem.realPath keeps the case it is given; Muse rejects a root whose case
352
+ // differs from the disk's, and APFS is case-insensitive just like NTFS.
353
+ it.effect("fixes the case of a macOS root natively", () =>
354
+ Effect.gen(function* () {
355
+ if ((yield* HostProcess.Platform) !== "darwin") return;
356
+ const fs = yield* FileSystem.FileSystem;
357
+ const path = yield* Path.Path;
358
+ const created = yield* fs.makeTempDirectoryScoped({ prefix: "MuseRoot-" });
359
+ // Only a case-insensitive volume resolves the miscased path; skip on a case-sensitive one.
360
+ if (!(yield* fs.exists(created.toUpperCase()))) return;
361
+ const root = yield* museWorkspaceRoot(created.toUpperCase());
362
+ expect(path.basename(root)).toBe(path.basename(created));
363
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
364
+ );
365
+
366
it.effect("fixes the case of a Windows root natively", () =>
367
Effect.gen(function* () {
368
if ((yield* HostProcess.Platform) !== "win32") return;
packages/provider-muse/src/server/sdk.ts
+10
-3
@@ -1,6 +1,6 @@
1
// @effect-diagnostics globalTimers:off
2
// The SDK owns process shutdown; native deadlines cover initialize before an Effect resource exists.
3
-// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.realPath is Node's JS realpath; museWorkspaceRoot needs the native one.
3
+// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.realPath is Node's JS realpath; museCanonicalPath needs the native one.
4
import * as NodeFSP from "node:fs/promises";
5
6
import {
@@ -70,9 +70,16 @@ export function museVerbatimPath(path: string): string {
70
return path.startsWith("\\\\") ? `\\\\?\\UNC\\${path.slice(2)}` : `\\\\?\\${path}`;
71
}
72
73
-/** Windows roots need native realpath for true case/long names, then verbatim form; launch cmd.exe in plain form. */
73
+// Native realpath corrects filesystem case as well as resolving symlinks.
74
+export const museCanonicalPath = Effect.fn("museCanonicalPath")(function* (path: string) {
75
+ return yield* Effect.tryPromise(() => NodeFSP.realpath(path)).pipe(
76
+ Effect.orElseSucceed(() => path),
77
+ );
78
+});
79
+
80
+// Windows turn roots need verbatim form; launch cmd.exe with the plain canonical path.
81
export const museWorkspaceRoot = Effect.fn("museWorkspaceRoot")(function* (path: string) {
75
- if ((yield* HostProcess.Platform) !== "win32") return path;
82
+ if ((yield* HostProcess.Platform) !== "win32") return yield* museCanonicalPath(path);
83
const canonical = yield* Effect.tryPromise(() => NodeFSP.realpath(path)).pipe(
84
// A verbatim path takes `/` literally, so an unresolved root needs Windows separators.
85
Effect.orElseSucceed(() => path.replaceAll("/", "\\")),