import path from "node:path";
import { RELEASE_MANIFEST_FILE } from "./release-manifest.js";

export function getPackageCacheRoot(userProfile) {
  return path.win32.join(userProfile, ".codex", "packages", "codex-harness");
}

export function getPackageInstallRoot(userProfile, version) {
  return path.win32.join(getPackageCacheRoot(userProfile), version);
}

export function getUserPackageLockPath(userProfile) {
  return path.win32.join(getPackageCacheRoot(userProfile), "package.lock.json");
}

export function getReleaseAssetNames(version) {
  return {
    zip: `codex-harness-${version}-win.zip`,
    sha256: `codex-harness-${version}-win.sha256`,
    manifest: RELEASE_MANIFEST_FILE
  };
}

export function getDownloadedZipPath(userProfile, version) {
  return path.win32.join(getPackageCacheRoot(userProfile), getReleaseAssetNames(version).zip);
}

export function getDownloadedShaPath(userProfile, version) {
  return path.win32.join(getPackageCacheRoot(userProfile), getReleaseAssetNames(version).sha256);
}

export function getDownloadedManifestPath(userProfile, version) {
  return path.win32.join(getPackageCacheRoot(userProfile), `release-manifest-${version}.json`);
}
