/** * XDG drift migration for the global CLEO config file (T9405). * * Pre-T9405 history: `globalConfigPath()` resolved to the CLEO **data** dir * (`getCleoHome()`), so existing installs have `config.json` at * `~/.local/share/cleo/config.json`. XDG says user config belongs in * `XDG_CONFIG_HOME` (`~/.config/cleo/config.json`). * * This migration runs on first credentials read after upgrade: * * 1. Skip if the data-dir source is absent. * 2. Skip if the data-dir migration marker exists (idempotent). * 3. Skip if the config-dir target already exists (manual migration / fresh install). * 4. Otherwise: * a. `mkdir -p` the config dir. * b. Read the data-dir config. * c. Validate the JSON parses. * d. Write to a temp file in the config dir, then atomically rename to the * final `config.json` (temp-then-rename — never any partial state). * e. Drop the marker file at `/.migrations/config-dir-v1.done`. * f. Rename the data-dir original to `config.json.pre-e1-bak` so users can * recover if something goes wrong. * * Migration is best-effort: every error is swallowed and logged to stderr. A * failed migration must never crash a CLI invocation — credentials resolution * just falls back to the data-dir location via the transition-window logic * baked into `globalConfigPath()`. * * @module llm/global-config-migration * @task T9405 * @epic T9398 */ /** * Filename used by `legacyGlobalConfigPath()` / `configDirGlobalConfigPath()`. * * Kept in one place so the migration helper and the credentials resolver agree * without anyone hard-coding the string in two places. * * @internal */ export declare const GLOBAL_CONFIG_FILENAME = "config.json"; /** * Resolve the canonical config-dir path for the global config file. * * Linux: `~/.config/cleo/config.json` * macOS: `~/Library/Preferences/cleo/config.json` * Windows: `%APPDATA%\cleo\Config\config.json` * * @public */ export declare function configDirGlobalConfigPath(): string; /** * Resolve the legacy data-dir path for the global config file. * * Pre-T9405 location. Read-only fallback during the transition window — the * migration moves the contents to {@link configDirGlobalConfigPath} and * renames the data-dir original to `config.json.pre-e1-bak`. * * @public */ export declare function legacyGlobalConfigPath(): string; /** * Run the data-dir → config-dir migration if applicable. * * Idempotent: safe to call on every CLEO invocation. Performs at most three * filesystem stat calls in the steady state (marker present OR source absent). * * Never throws. Errors are logged to stderr and swallowed — the credentials * resolver's transition-window logic will still find the legacy data-dir copy. * * @returns `true` when a migration was actually performed, `false` when it was * a no-op (already migrated, no source, or target already present). * * @task T9405 */ export declare function migrateGlobalConfigToConfigDir(): boolean; /** * Run the migration at most once per Node process. * * Called from the credentials resolver before reading `globalConfigPath()` so * a stale install is upgraded in-place on first credentials read. The latch * keeps the steady-state cost at one boolean check after the first call — * essential because `resolveCredentials()` is on the hot path of every LLM * call. * * Use {@link _resetGlobalConfigMigrationLatch} in tests to re-arm the latch. * * @public */ export declare function ensureGlobalConfigMigrated(): void; /** * Reset the in-process migration latch. Test-only — use in `beforeEach` so * each test re-runs the migration with its own fresh `XDG_*` / `CLEO_HOME` * overrides. * * @internal */ export declare function _resetGlobalConfigMigrationLatch(): void; //# sourceMappingURL=global-config-migration.d.ts.map