scripts-migrate-logs
#!/usr/bin/env python3 """Migrate CODITECT runtime logs to centralized .coditect-data/logs."""
from future import annotations
import argparse import shutil from pathlib import Path
def discover_projects_dir() -> Path: home = Path.home() env = Path.home().joinpath("PROJECTS") if env.exists(): return env return home / "PROJECTS"
def migrate_logs(dry_run: bool) -> int: projects = discover_projects_dir() target = projects / ".coditect-data" / "logs" target.mkdir(parents=True, exist_ok=True)
sources = [
Path.home() / ".coditect" / "logs",
Path("logs"),
Path("coditect-core") / "logs",
]
moved = 0
for src in sources:
if not src.exists() or not src.is_dir():
continue
for item in src.iterdir():
if item.is_file():
dest = target / item.name
if dry_run:
print(f"[dry-run] {item} -> {dest}")
else:
shutil.move(str(item), str(dest))
moved += 1
return moved
def main() -> None: parser = argparse.ArgumentParser(description="Migrate runtime logs to .coditect-data/logs") parser.add_argument("--dry-run", action="store_true") args = parser.parse_args()
moved = migrate_logs(args.dry_run)
print(f"moved {moved} log file(s)")
if name == "main": main()