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 21, 04:45 UTC
| 1 | import os from "node:os"; |
| 2 | import path from "pathe"; |
| 3 | |
| 4 | /** |
| 5 | * Root of alchemy's user-level auth state (`~/.alchemy`). Overridable with |
| 6 | * `ALCHEMY_HOME`, which relocates profiles, credential files, |
| 7 | * and cross-process locks together — used by tests to isolate a temp home |
| 8 | * and available to users who keep dotfiles elsewhere. Resolved lazily so an |
| 9 | * override set after module load (e.g. in a test) still takes effect. An |
| 10 | * empty `ALCHEMY_HOME` counts as unset, never as the current directory. |
| 11 | */ |
| 12 | export const rootDir = () => process.env.ALCHEMY_HOME || path.join(os.homedir(), ".alchemy"); |
| 13 | |
| 14 | export const configFilePath = () => path.join(rootDir(), "profiles.json"); |
| 15 | |
| 16 | /** Directory containing one directory per named profile. */ |
| 17 | export const profilesDirPath = () => path.join(rootDir(), "profiles"); |
| 18 | |
| 19 | /** Directory containing all provider documents for a named profile. */ |
| 20 | export const profileDirPath = (profile: string) => path.join(profilesDirPath(), profile); |
| 21 | |
| 22 | /** Cached state-store credentials for a profile, beside its provider documents. */ |
| 23 | export const profileStateStoresDirPath = (profile: string) => |
| 24 | path.join(profileDirPath(profile), "state-stores"); |
| 25 | |
| 26 | /** The single persisted document for one provider in one profile. */ |
| 27 | export const profileProviderFilePath = (profile: string, provider: string) => |
| 28 | path.join(profileDirPath(profile), `${provider.toLowerCase()}.json`); |
| 29 | |
| 30 | export const credentialsDirPath = () => path.join(rootDir(), "credentials"); |
| 31 | |
| 32 | export const profileCredentialsDirPath = (profile: string) => |
| 33 | path.join(credentialsDirPath(), profile); |