// Section builder functions for project-knowledge-based rules generation
export function buildProjectOverviewSection(knowledge) {
    const rules = [];
    rules.push({
        rule: `This is a ${knowledge.language} project${knowledge.framework ? ` using ${knowledge.framework}` : ''}.`,
        enforcement: 'strict',
    });
    if (knowledge.database !== 'unknown') {
        rules.push({
            rule: `Database: ${knowledge.database}. All database operations must use the established ORM/client.`,
            enforcement: 'strict',
        });
    }
    if (knowledge.packageManager) {
        rules.push({
            rule: `Package manager: ${knowledge.packageManager}. Always use this for dependency management.`,
            enforcement: 'strict',
        });
    }
    if (knowledge.stack.length > 0) {
        rules.push({
            rule: `Tech stack: ${knowledge.stack.join(', ')}`,
            enforcement: 'recommended',
        });
    }
    return { title: 'Project Overview', rules };
}
export function buildArchitectureSection(knowledge) {
    const rules = [];
    const arch = knowledge.architecture;
    rules.push({
        rule: `Architecture pattern: ${arch.primary}. Maintain this pattern in all new code.`,
        enforcement: 'strict',
    });
    for (const layer of arch.layers) {
        rules.push({
            rule: `Layer "${layer.name}" (${layer.directories.join(', ')}): ${layer.responsibility}`,
            enforcement: 'strict',
        });
        if (layer.neverDependsOn.length > 0) {
            rules.push({
                rule: `NEVER import from ${layer.neverDependsOn.join(', ')} in "${layer.name}" layer.`,
                enforcement: 'strict',
            });
        }
    }
    for (const boundary of arch.boundaries) {
        rules.push({
            rule: `Module "${boundary.name}" (${boundary.directories.join(', ')}): use only its public API from outside.`,
            enforcement: 'recommended',
        });
    }
    return { title: 'Architecture', rules };
}
export function buildConventionsSection(knowledge) {
    const rules = [];
    for (const [key, value] of Object.entries(knowledge.conventions)) {
        rules.push({
            rule: `Convention "${key}": ${value}`,
            enforcement: 'recommended',
        });
    }
    // Standard conventions
    rules.push({
        rule: 'Use descriptive, intention-revealing names for all identifiers.',
        enforcement: 'strict',
    });
    rules.push({
        rule: 'Keep functions under 30 lines and limit parameters to 3.',
        enforcement: 'recommended',
    });
    rules.push({
        rule: 'Write pure functions where possible; minimize side effects.',
        enforcement: 'recommended',
    });
    return { title: 'Conventions', rules };
}
export function buildQualitySection(knowledge) {
    const rules = [];
    const profile = knowledge.qualityProfile;
    for (const principle of profile.principles) {
        rules.push({
            rule: `Follow ${principle} principles in all code.`,
            enforcement: profile.strictness === 'strict' ? 'strict' : 'recommended',
        });
    }
    rules.push({
        rule: 'Never commit code with critical security issues (hardcoded secrets, SQL injection, XSS).',
        enforcement: 'strict',
    });
    rules.push({
        rule: 'Handle all errors explicitly. No empty catch blocks.',
        enforcement: 'strict',
    });
    rules.push({
        rule: 'Write tests for all new functionality. Minimum: unit tests for business logic.',
        enforcement: 'recommended',
    });
    return { title: 'Quality', rules };
}
export function buildWorkflowSection(knowledge) {
    const rules = [];
    rules.push({
        rule: `Specs are stored in ${knowledge.specLocation}. Always check for an existing spec before implementing.`,
        enforcement: 'strict',
    });
    rules.push({
        rule: 'Follow the SDD workflow: spec first, then implement, then validate.',
        enforcement: 'recommended',
    });
    if (knowledge.buildCommand) {
        rules.push({
            rule: `Build command: ${knowledge.buildCommand}. Verify builds pass before committing.`,
            enforcement: 'strict',
        });
    }
    if (knowledge.testCommand) {
        rules.push({
            rule: `Test command: ${knowledge.testCommand}. Run tests before committing.`,
            enforcement: 'strict',
        });
    }
    return { title: 'Workflow', rules };
}
export function buildConstitutionSection(constitution) {
    const rules = [];
    for (const principle of constitution.principles) {
        rules.push({
            rule: `[${principle.category}] ${principle.principle} — ${principle.rationale}`,
            enforcement: principle.enforceLevel,
        });
    }
    return { title: 'Project Constitution', rules };
}
//# sourceMappingURL=sections-knowledge.js.map