// tools/generate-adr/helpers.ts — ADR I/O and analysis helpers
import { readFile } from 'node:fs/promises';
export async function readSpecContent(spec) {
    let content = spec.title + ' ' + spec.type + ' ' + spec.scope;
    try {
        if (spec.specPath) {
            content += ' ' + (await readFile(spec.specPath, 'utf-8'));
        }
    }
    catch {
        /* file not available */
    }
    try {
        if (spec.technicalPath) {
            content += ' ' + (await readFile(spec.technicalPath, 'utf-8'));
        }
    }
    catch {
        /* file not available */
    }
    return content;
}
export function buildEcosystemAnalysis(knowledge) {
    const parts = [
        `Stack: ${knowledge.stack.join(', ')}.`,
        `Architecture: ${knowledge.architecture.primary}.`,
        `Database: ${knowledge.database}.`,
        `Layers: ${knowledge.layers.join(', ') || 'not detected'}.`,
    ];
    if (knowledge.apiContracts.length > 0) {
        parts.push(`API contracts: ${knowledge.apiContracts.map((c) => c.type).join(', ')}.`);
    }
    return parts.join(' ');
}
export function buildRecommendation(decisions, knowledge) {
    const chosen = decisions.map((d) => `- ${d.decision}: ${d.chosen}`).join('\n');
    return `Recommended decisions for the current ${knowledge.architecture.primary} architecture:\n${chosen}\n\nAll decisions prioritize consistency with the existing ecosystem. Re-evaluate if requirements change significantly.`;
}
//# sourceMappingURL=helpers.js.map