import path from "node:path";

import { detectProjectRoot } from "../project/detect-project-root.js";
import { assertInitialized } from "../project/assert-initialized.js";
import { invokePowerShellScript } from "../powershell/invoke-script.js";

export async function doctorCommand(options) {
  const projectRoot = detectProjectRoot(options.projectRoot);
  assertInitialized(projectRoot);
  const scriptPath = path.join(projectRoot, "tools", "harness", "doctor.ps1");
  await invokePowerShellScript(scriptPath, ["-ProjectRoot", projectRoot], { cwd: projectRoot });
}
