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

usageClaudeTranscriptDir.ts

29 lines1.1 KB

1/**
2 * Pure choice of Claude Code's on-disk transcript directory.
3 *
4 * Used by `UsageService` so a missing default `~/.claude/projects` is reported
5 * as missing instead of walking the user's `~/projects` tree.
6 *
7 * @module usageClaudeTranscriptDir
8 */
9​
10export function isClaudeHomeExplicitOverride(configuredHomePath: string): boolean {
11 return configuredHomePath.trim().length > 0;
13​
14/**
15 * Default installs nest transcripts under `<home>/.claude/projects`. A custom
16 * CLAUDE_CONFIG_DIR uses `<home>/projects` only when that nested path is
17 * absent. The OS home never falls back to `<home>/projects`.
18 */
19export function resolveClaudeTranscriptDirPath(input: {
20 readonly homePath: string;
21 readonly join: (a: string, b: string, ...rest: string[]) => string;
22 readonly nestedProjectsExists: boolean;
23 readonly homeIsExplicitOverride: boolean;
24}): string {
25 const nested = input.join(input.homePath, ".claude", "projects");
26 if (input.nestedProjectsExists) return nested;
27 if (input.homeIsExplicitOverride) return input.join(input.homePath, "projects");
28 return nested;