//! Provisioning generator for typedialog projects.
//!
//! Generates complete provisioning/ directory structures with 7-layer validation
//! (Forms → Constraints → Values → Validators → Schemas → Defaults → JSON)
//! from project specifications using TypeDialog + Nickel.

pub mod ai;
pub mod cli;
pub mod config;
pub mod error;
pub mod generator;
pub mod input;
pub mod models;
pub mod template;

pub use error::{ProvisioningGenError, Result};
pub use models::{ConfigField, DomainFeature, InfrastructureSpec, ProjectSpec};

/// Run provisioning generation from project specification.
pub async fn generate(spec: ProjectSpec, output_dir: impl AsRef<std::path::Path>) -> Result<()> {
    let output_dir = output_dir.as_ref();

    // Ensure output directory exists
    std::fs::create_dir_all(output_dir)?;

    // Generation pipeline:
    // 1. Constraints (required by fragments and validators)
    // 2. Schemas (domain-specific types)
    // 3. Validators (validation logic using constraints)
    // 4. Defaults (sensible defaults)
    // 5. Fragments (form UI sections using constraints)
    // 6. Scripts (orchestration bash + nushell)
    // 7. Infrastructure (copy generic templates)
    // 8. Form (assemble main config-form.toml)
    // 9. README (documentation)

    tracing::info!(
        "Starting provisioning generation for project: {}",
        spec.name
    );
    tracing::info!("Output directory: {}", output_dir.display());

    Ok(())
}
