/**
 * SF home directory resolution.
 *
 * Exports sfHome() which returns the SF configuration directory,
 * defaulting to ~/.sf with a SF_HOME env var override.
 *
 * For the user's home directory, use os.homedir() directly — it handles
 * platform-specific env lookup (USERPROFILE on Windows, HOME on POSIX)
 * with appropriate fallbacks.
 */
import { homedir } from "node:os";
import { join, resolve } from "node:path";
/**
 * Resolve the SF home directory (typically ~/.sf).
 *
 * `SF_HOME` env var overrides the default location.
 * Falls back to `homedir()/.sf`.
 *
 * Always returns an absolute, normalized path — `resolve()` canonicalizes
 * any relative or non-canonical `SF_HOME` value so downstream comparison
 * and redaction sites don't have to.
 */
export function sfHome() {
	return process.env.SF_HOME
		? resolve(process.env.SF_HOME)
		: join(homedir(), ".sf");
}
