import os from "node:os";
import path from "node:path";
import { mkdirSync } from "node:fs";
function expandHomeDir(input) {
    if (input.startsWith("~/")) {
        return path.join(os.homedir(), input.slice(2));
    }
    if (input === "~") {
        return os.homedir();
    }
    return input;
}
export function resolveSeaworkHome(env = process.env) {
    const raw = env.SEAWORK_HOME ?? env.SEAWORK_HOME ?? "~/.seawork";
    const resolved = path.resolve(expandHomeDir(raw));
    mkdirSync(resolved, { recursive: true });
    return resolved;
}
//# sourceMappingURL=seawork-home.js.map