import { existsSync, mkdirSync } from "fs";
import { join } from "path";
import { getAgentDir as getDefaultAgentDir } from "../config.js";
import { resolvePath } from "../utils/paths.js";
/**
 * Compute the default session directory for a cwd.
 * Encodes cwd into a safe directory name under ~/.atomic/agent/sessions/.
 */
export function getDefaultSessionDirPath(cwd, agentDir = getDefaultAgentDir()) {
    const resolvedCwd = resolvePath(cwd);
    const resolvedAgentDir = resolvePath(agentDir);
    const safePath = `--${resolvedCwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
    return join(resolvedAgentDir, "sessions", safePath);
}
export function getDefaultSessionDir(cwd, agentDir = getDefaultAgentDir()) {
    const sessionDir = getDefaultSessionDirPath(cwd, agentDir);
    if (!existsSync(sessionDir)) {
        mkdirSync(sessionDir, { recursive: true });
    }
    return sessionDir;
}
//# sourceMappingURL=session-manager-paths.js.map