import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs'; import { join } from 'node:path'; import { SEED_PATH, DATA_PATH } from './data-path'; const SEED_TASKS_DIR = join(SEED_PATH, 'tasks'); const GLOBAL_TASKS_DIR = join(DATA_PATH, 'tasks'); export function syncSeedTasks(): void { if (!existsSync(SEED_TASKS_DIR)) return; mkdirSync(GLOBAL_TASKS_DIR, { recursive: true }); const seedEntries = readdirSync(SEED_TASKS_DIR, { withFileTypes: true }); for (const entry of seedEntries) { if (!entry.isDirectory()) continue; const seedTaskDir = join(SEED_TASKS_DIR, entry.name); const taskFile = join(seedTaskDir, 'TASK.md'); if (!existsSync(taskFile)) continue; const targetDir = join(GLOBAL_TASKS_DIR, entry.name); if (existsSync(targetDir)) { // Task already exists in DATA_PATH — skip to preserve user edits continue; } cpSync(seedTaskDir, targetDir, { recursive: true }); console.log(`[tasks] Synced seed task: ${entry.name}`); } }