Something went wrong. Try again.
source dump of claude code forked from oppi.li/claude-code
Something went wrong. Try again.
1.4 kB · 38 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839import envPaths from 'env-paths'import { join } from 'path'import { getFsImplementation } from './fsOperations.js'import { djb2Hash } from './hash.js'
const paths = envPaths('claude-cli')
// Local sanitizePath using djb2Hash — NOT the shared version from// sessionStoragePortable.ts which uses Bun.hash (wyhash) when available.// Cache directory names must remain stable across upgrades so existing cache// data (error logs, MCP logs) is not orphaned.const MAX_SANITIZED_LENGTH = 200function sanitizePath(name: string): string { const sanitized = name.replace(/[^a-zA-Z0-9]/g, '-') if (sanitized.length <= MAX_SANITIZED_LENGTH) { return sanitized } return `${sanitized.slice(0, MAX_SANITIZED_LENGTH)}-${Math.abs(djb2Hash(name)).toString(36)}`}
function getProjectDir(cwd: string): string { return sanitizePath(cwd)}
export const CACHE_PATHS = { baseLogs: () => join(paths.cache, getProjectDir(getFsImplementation().cwd())), errors: () => join(paths.cache, getProjectDir(getFsImplementation().cwd()), 'errors'), messages: () => join(paths.cache, getProjectDir(getFsImplementation().cwd()), 'messages'), mcpLogs: (serverName: string) => join( paths.cache, getProjectDir(getFsImplementation().cwd()), // Sanitize server name for Windows compatibility (colons are reserved for drive letters) `mcp-logs-${sanitizePath(serverName)}`, ),}