import { randomUUID } from 'node:crypto';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
const TASKS_DIR = '.nanocoder';
const TASKS_FILE = 'tasks.json';
export function getTasksPath() {
    return join(process.cwd(), TASKS_DIR, TASKS_FILE);
}
export async function loadTasks() {
    try {
        const path = getTasksPath();
        const content = await readFile(path, 'utf-8');
        return JSON.parse(content);
    }
    catch {
        return [];
    }
}
export async function saveTasks(tasks) {
    const dirPath = join(process.cwd(), TASKS_DIR);
    await mkdir(dirPath, { recursive: true });
    const path = getTasksPath();
    await writeFile(path, JSON.stringify(tasks, null, 2), 'utf-8');
}
export function generateTaskId() {
    return randomUUID().slice(0, 8);
}
export async function clearAllTasks() {
    await saveTasks([]);
}
//# sourceMappingURL=storage.js.map