import { mkdir, writeFile } from "node:fs/promises";
import { dirname, join } from "node:path";
export async function writeThreadSuiteProjectIndex(cwd, inventory, options, semanticDiscovery, synthesis) {
    const path = ".threadwell/project-index.json";
    const absolutePath = join(cwd, path);
    await mkdir(dirname(absolutePath), { recursive: true });
    await writeFile(absolutePath, `${JSON.stringify(createThreadSuiteProjectIndex(inventory, options, semanticDiscovery, synthesis), null, 2)}\n`, "utf-8");
    return { path, action: "written", profile: options.profile };
}
export function createThreadSuiteProjectIndex(inventory, options, semanticDiscovery, synthesis) {
    return {
        schemaVersion: 1,
        generatedAt: new Date().toISOString(),
        profile: options.profile,
        projectType: inventory.projectType,
        confidence: inventory.confidence,
        manifests: inventory.manifests,
        documents: inventory.documents,
        sourceRoots: inventory.sourceRoots,
        testRoots: inventory.testRoots,
        continuityFiles: inventory.continuityFiles,
        adrFiles: inventory.adrFiles,
        skipped: inventory.skipped,
        semanticDiscovery,
        synthesis,
    };
}
//# sourceMappingURL=project-index.js.map