Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ClaudeHome.test.ts

52 lines1.9 KB

1import * as NodeOS from "node:os";
2​
3import * as NodeServices from "@effect/platform-node/NodeServices";
4import { describe, expect, it } from "@effect/vitest";
5import { Effect, Path } from "effect";
6​
7import {
8 makeClaudeCapabilitiesCacheKey,
9 makeClaudeContinuationGroupKey,
10 makeClaudeEnvironment,
11 resolveClaudeHomePath,
12} from "./ClaudeHome.ts";
13​
14it.layer(NodeServices.layer)("ClaudeHome", (it) => {
15 describe("Claude home resolution", () => {
16 it.effect("uses the process home when no Claude home override is configured", () =>
17 Effect.gen(function* () {
18 const path = yield* Path.Path;
19 const resolved = path.resolve(NodeOS.homedir());
20​
21 expect(yield* resolveClaudeHomePath({ homePath: "" })).toBe(resolved);
22 expect(yield* makeClaudeEnvironment({ homePath: "" })).toBe(process.env);
23 }),
24 );
25​
26 it.effect("resolves configured Claude HOME and stamps continuation/cache keys with it", () =>
27 Effect.gen(function* () {
28 const path = yield* Path.Path;
29 const homePath = "~/.claude-work";
30 const resolved = path.resolve(NodeOS.homedir(), ".claude-work");
31​
32 expect(yield* resolveClaudeHomePath({ homePath })).toBe(resolved);
33 expect((yield* makeClaudeEnvironment({ homePath })).HOME).toBe(resolved);
34 expect(yield* makeClaudeContinuationGroupKey({ homePath })).toBe(`claude:home:${resolved}`);
35 expect(yield* makeClaudeCapabilitiesCacheKey({ binaryPath: "claude", homePath })).toBe(
36 `claude\0${resolved}`,
37 );
38 }),
39 );
40​
41 it.effect("keeps continuation compatible across instances with the same Claude HOME", () =>
42 Effect.gen(function* () {
43 const path = yield* Path.Path;
44 const resolved = path.resolve(NodeOS.homedir());
45​
46 expect(yield* makeClaudeContinuationGroupKey({ homePath: "" })).toBe(
47 `claude:home:${resolved}`,
48 );
49 }),
50 );
51 });
52});