/**
 * Copy provenance helpers for Lisa-owned doctor artifacts.
 * @module cli/doctor-lisa-owned-artifact-copies
 */
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import * as path from "node:path";
/**
 * Short content identity for a resolved artifact copy.
 * @param bytes - File contents
 * @returns Human-sized content version
 */
function artifactVersion(bytes) {
    return `sha256:${createHash("sha256").update(bytes).digest("hex").slice(0, 12)}`;
}
/**
 * Report all resolvable copies for one installed Lisa-owned artifact.
 * @param lisaRoot - Installed Lisa package root
 * @param destination - Project-relative artifact destination
 * @param installed - Bytes currently installed in the project
 * @param sources - Absolute paths of shipped package variants
 * @returns Multi-copy provenance
 */
export async function describeResolvableCopies(lisaRoot, destination, installed, sources) {
    const shipped = await Promise.all(sources.map(async (source) => [source, await readFile(source)]));
    const copies = [
        {
            location: `project:${destination}`,
            version: artifactVersion(installed),
            governs: true,
        },
        ...shipped.map(([source, bytes]) => ({
            location: `package:${path.relative(lisaRoot, source).split(path.sep).join("/")}`,
            version: artifactVersion(bytes),
            governs: false,
        })),
    ];
    const versions = new Set(copies.map(copy => copy.version));
    return { destination, copies, disagrees: versions.size > 1 };
}
//# sourceMappingURL=doctor-lisa-owned-artifact-copies.js.map