from pathlib import Path def project_root() -> Path: """Returns the project root (parent of the gimme_job package directory).""" return Path(__file__).parent.parent.parent def workspace_dir() -> Path: return project_root() / "workspace" def sites_dir() -> Path: return project_root() / "sites" def db_path() -> Path: import os db = os.environ.get("GIMME_JOB_DB_PATH", "gimme_job.db") p = Path(db) if not p.is_absolute(): p = project_root() / p return p def chrome_profile_dir(name: str = "JobAgent") -> Path: return workspace_dir() / "chrome-profiles" / name def captures_dir() -> Path: return workspace_dir() / "captures" def traces_dir() -> Path: return workspace_dir() / "traces" def screenshots_dir() -> Path: return workspace_dir() / "screenshots" def dom_dir() -> Path: return workspace_dir() / "dom" def manifests_dir() -> Path: return workspace_dir() / "manifests" def generated_dir() -> Path: return workspace_dir() / "generated" def logs_dir() -> Path: return workspace_dir() / "logs" def reports_dir() -> Path: return workspace_dir() / "reports" def trace_path(site_id: str, run_id: str) -> Path: return traces_dir() / f"{site_id}_{run_id}.zip" def screenshot_path(site_id: str, run_id: str) -> Path: return screenshots_dir() / f"{site_id}_{run_id}.png" def dom_snapshot_path(site_id: str, run_id: str) -> Path: return dom_dir() / f"{site_id}_{run_id}.html" def html_dump_path(site_id: str, suffix: str = "learn") -> Path: return dom_dir() / f"{site_id}_{suffix}.html" def a11y_snapshot_path(site_id: str, suffix: str = "learn") -> Path: return dom_dir() / f"{site_id}_{suffix}_a11y.json" def learn_screenshot_path(site_id: str) -> Path: return screenshots_dir() / f"{site_id}_learn.png" def ensure_workspace_dirs() -> None: """Create all workspace subdirectories.""" for d in [ workspace_dir(), chrome_profile_dir(), captures_dir(), traces_dir(), screenshots_dir(), dom_dir(), manifests_dir(), generated_dir(), logs_dir(), reports_dir(), ]: d.mkdir(parents=True, exist_ok=True)