import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { homedir } from 'node:os';
export class FileStore {
    baseDir;
    constructor(baseDir) {
        this.baseDir = baseDir ?? join(homedir(), '.claude', 'learn');
        mkdirSync(join(this.baseDir, 'exercises'), { recursive: true });
    }
    get exercisesDir() {
        return join(this.baseDir, 'exercises');
    }
    get dataDir() {
        return this.baseDir;
    }
    get dbPath() {
        return join(this.baseDir, 'data.db');
    }
    writeExerciseFiles(subjectSlug, exerciseSlug, files) {
        const dir = join(this.exercisesDir, subjectSlug, exerciseSlug);
        mkdirSync(dir, { recursive: true });
        for (const [name, content] of Object.entries(files)) {
            writeFileSync(join(dir, name), content, 'utf-8');
        }
        return dir;
    }
    exerciseExists(subjectSlug, exerciseSlug) {
        return existsSync(join(this.exercisesDir, subjectSlug, exerciseSlug));
    }
    readFile(path) {
        return readFileSync(path, 'utf-8');
    }
}
//# sourceMappingURL=files.js.map