import fs from "node:fs";
import path from "node:path";

export function assertInitialized(projectRoot) {
  const requiredPaths = [
    "tools/harness/doctor.ps1",
    "tools/harness/verify.ps1",
    "tools/harness/codex-loop.ps1",
    "task.json"
  ];

  for (const relativePath of requiredPaths) {
    const fullPath = path.join(projectRoot, relativePath);
    if (!fs.existsSync(fullPath)) {
      const error = new Error(`Project is not initialized. Missing: ${relativePath}. Run 'harness init'.`);
      error.exitCode = 2;
      throw error;
    }
  }
}
