"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.gatherLayer2Parallel = gatherLayer2Parallel;
const cloc_1 = require("./cloc");
const gitleaks_1 = require("./gitleaks");
const graphify_1 = require("./graphify");
async function gatherLayer2Parallel(cwd, _verbose = false) {
    const clocPartial = (0, cloc_1.gatherClocMetrics)(cwd);
    const toolsUsed = [...(clocPartial.toolsUsed ?? [])];
    const toolsUnavailable = [...(clocPartial.toolsUnavailable ?? [])];
    const gitleaks = (0, gitleaks_1.gatherGitleaksResult)(cwd);
    if (gitleaks.kind === 'success') {
        toolsUsed.push('gitleaks');
    }
    else {
        // `not installed` renders as bare `gitleaks`, every other failure
        // mode carries its reason as a parenthetical — byte-identical to
        // the pre-C.7 string the report surfaces.
        toolsUnavailable.push(gitleaks.reason === 'not installed' ? 'gitleaks' : `gitleaks (${gitleaks.reason})`);
    }
    const graphify = await (0, graphify_1.gatherGraphifyResult)(cwd);
    if (graphify.kind === 'success') {
        toolsUsed.push('graphify');
    }
    else {
        toolsUnavailable.push(`graphify (${graphify.reason})`);
    }
    // Trigger the graph.json side-effect write. Shares the Python
    // invocation with gatherGraphifyResult above via the promise-
    // coalesced cache — no second shell-out. The disk write powers
    // the explore CLI (Sprint 2) + dashboard viz (Sprint 3) + future
    // 2.8 context CLI + reachability flows, all of which read from
    // .dxkit/reports/graph.json via the canonical loader.
    await (0, graphify_1.gatherGraphifyGraph)(cwd);
    return {
        sourceFiles: clocPartial.sourceFiles,
        totalLines: clocPartial.totalLines,
        clocLanguages: clocPartial.clocLanguages,
        toolsUsed,
        toolsUnavailable,
    };
}
//# sourceMappingURL=parallel.js.map