export function createBaseSemanticDiscovery(inventory) {
    return {
        projectPurpose: {
            value: "Unknown from available evidence.",
            confidence: "low",
            sources: [],
        },
        languages: inferLanguages(inventory),
        frameworks: [],
        commands: [],
        dependencies: [],
        entrypoints: [],
        modules: inventory.sourceRoots.map((path) => ({
            path,
            value: `Source root detected at ${path}.`,
            confidence: "low",
            sources: [path],
        })),
        architectureHints: [],
        validationStrategy: [],
        risks: [],
        unknowns: [
            {
                value: "Project purpose requires manifest, docs, or entrypoint evidence.",
                confidence: "high",
                sources: [],
            },
        ],
    };
}
export function mergeSemanticDiscovery(base, updates) {
    return {
        projectPurpose: updates.projectPurpose ?? base.projectPurpose,
        languages: mergeClaims(base.languages, updates.languages),
        frameworks: mergeClaims(base.frameworks, updates.frameworks),
        commands: mergeClaims(base.commands, updates.commands),
        dependencies: mergeClaims(base.dependencies, updates.dependencies),
        entrypoints: mergeClaims(base.entrypoints, updates.entrypoints),
        modules: mergeClaims(base.modules, updates.modules),
        architectureHints: mergeClaims(base.architectureHints, updates.architectureHints),
        validationStrategy: mergeClaims(base.validationStrategy, updates.validationStrategy),
        risks: mergeClaims(base.risks, updates.risks),
        unknowns: mergeClaims(base.unknowns, updates.unknowns),
    };
}
export function createThreadSuiteSemanticDiscovery(inventory, updates = {}) {
    return mergeSemanticDiscovery(createBaseSemanticDiscovery(inventory), updates);
}
function inferLanguages(inventory) {
    const languages = [];
    if (inventory.manifests.some((manifest) => manifest.kind === "node")) {
        languages.push({ value: "JavaScript/TypeScript", confidence: "medium", sources: ["package.json"] });
    }
    if (inventory.manifests.some((manifest) => manifest.kind === "rust")) {
        languages.push({ value: "Rust", confidence: "medium", sources: ["Cargo.toml"] });
    }
    if (inventory.manifests.some((manifest) => manifest.kind === "python")) {
        languages.push({ value: "Python", confidence: "medium", sources: ["pyproject.toml"] });
    }
    if (inventory.manifests.some((manifest) => manifest.kind === "go")) {
        languages.push({ value: "Go", confidence: "medium", sources: ["go.mod"] });
    }
    return languages;
}
function mergeClaims(base, updates) {
    if (!updates || updates.length === 0)
        return base;
    const seen = new Set();
    const merged = [];
    for (const claim of [...base, ...updates]) {
        const key = claim.value;
        if (seen.has(key))
            continue;
        seen.add(key);
        merged.push(claim);
    }
    return merged;
}
//# sourceMappingURL=semantic-discovery.js.map