// ci-generator/index.ts — Public API for the CI workflow generator (SPEC-066)
import { detectCIStack } from './stack-detector.js';
import { buildWorkflow, serializeWorkflow } from './yaml-builder.js';
const DEFAULT_JOBS = ['lint', 'test', 'build'];
const DEFAULT_TRIGGERS = ['push', 'pull_request'];
const DEFAULT_WORKFLOW_NAME = 'CI';
/**
 * Generate a GitHub Actions CI workflow for a project.
 * Detects the project stack and generates a valid workflow YAML.
 */
export async function generateCI(input) {
    const { projectPath, jobs = DEFAULT_JOBS, triggers = DEFAULT_TRIGGERS, nodeVersion, pythonVersion, goVersion, rustChannel, javaVersion, workflowName = DEFAULT_WORKFLOW_NAME, } = input;
    // Detect stack from project files, create a mutable copy
    const detected = await detectCIStack(projectPath);
    const stackContext = { ...detected };
    // Override detected versions with explicit user inputs
    if (nodeVersion !== undefined) {
        stackContext.nodeVersion = nodeVersion;
    }
    if (pythonVersion !== undefined) {
        stackContext.pythonVersion = pythonVersion;
    }
    if (goVersion !== undefined) {
        stackContext.goVersion = goVersion;
    }
    if (rustChannel !== undefined) {
        stackContext.rustChannel = rustChannel;
    }
    if (javaVersion !== undefined) {
        stackContext.javaVersion = javaVersion;
    }
    // Build the workflow model
    const workflow = buildWorkflow(stackContext, jobs, triggers, workflowName);
    // Serialize to YAML
    const yamlContent = serializeWorkflow(workflow);
    return {
        ecosystem: stackContext.ecosystem,
        workflowPath: workflow.filename,
        yamlContent,
        jobs,
        stackContext,
    };
}
//# sourceMappingURL=index.js.map