| 607 | |
| 608 | const dateStr = new Date().toISOString().slice(0, 10); |
| 609 | const archiveDir = path.join(PROJECT_ROOT, '.planning', 'archive', dateStr, path.basename(entry.path.replace(/\/$/, ''))); |
| 610 | fs.mkdirSync(archiveDir, { recursive: true }); |
| 611 | |
| 612 | for (const item of items) { |
| 613 | const src = path.join(dirPath, item); |
| 614 | const dest = path.join(archiveDir, item); |
| 615 | fs.renameSync(src, dest); |
| 616 | } |
| 617 | } catch { /* best effort */ } |
| 618 | } else if (strategy === 'delete') { |
| 619 | // Remove directory entirely, then recreate if it's a standard planning dir |
| 620 | try { |
| 621 | fs.rmSync(dirPath, { recursive: true, force: true }); |
| 622 | // Recreate if it's a known planning directory |
| 623 | const relativePath = path.relative(PROJECT_ROOT, dirPath).replace(/\\/g, '/'); |
| 624 | if (relativePath.startsWith('.planning/')) { |
| 625 | fs.mkdirSync(dirPath, { recursive: true }); |
| 626 | } |
| 627 | } catch { /* best effort */ } |