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

ClaudeHome.test.ts

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