import { readFile } from "node:fs/promises";
import { join } from "node:path";
const SAFE_SCRIPT_NAMES = new Set(["check", "lint", "typecheck", "test:unit", "test:ci"]);
export async function createThreadSuiteValidationPlan(cwd, inventory) {
    const commands = [];
    const notes = [];
    if (inventory.manifests.some((manifest) => manifest.path === "package.json")) {
        const scripts = await readPackageScripts(cwd);
        for (const name of SAFE_SCRIPT_NAMES) {
            if (scripts.has(name))
                commands.push(`npm run ${name}`);
        }
        if (commands.length === 0)
            notes.push("No known lightweight npm validation scripts detected.");
    }
    if (inventory.manifests.some((manifest) => manifest.path === "Cargo.toml")) {
        commands.push("cargo check");
    }
    if (commands.length === 0)
        notes.push("Validation discovery found no safe default commands.");
    return { commands, notes };
}
async function readPackageScripts(cwd) {
    try {
        const packageJson = JSON.parse(await readFile(join(cwd, "package.json"), "utf-8"));
        return new Set(Object.entries(packageJson.scripts ?? {}).flatMap(([name, value]) => typeof value === "string" ? [name] : []));
    }
    catch {
        return new Set();
    }
}
//# sourceMappingURL=validation.js.map