Public/Invoke-LeadForge.ps1

function Invoke-LeadForge {
    <#
    .SYNOPSIS
        Run the LeadForge email-to-opportunity pipeline.
    .DESCRIPTION
        Processes a folder of .eml files through 8 structured stages:
        gather → analyse → enrich → research-pass1 → triage → research-pass2 → score → export

        Each stage writes output to data/. Completed stages are skipped on re-run unless -Force.
    .EXAMPLE
        Invoke-LeadForge -Path "./emails/Q1-2026"
    .EXAMPLE
        Invoke-LeadForge -Path "./emails" -Steps gather,analyse -DryRun
    .EXAMPLE
        Invoke-LeadForge -Path "./emails" -Profile Default -Force
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [ValidateScript({ Test-Path $_ -PathType Container })]
        [string]$Path,

        [string]$OutputPath,

        [ValidateSet('gather', 'analyse', 'enrich', 'research-pass1', 'triage', 'research-pass2', 'score', 'export')]
        [string[]]$Steps = @('gather', 'analyse', 'enrich', 'research-pass1', 'triage', 'research-pass2', 'score', 'export'),

        [string]$Profile = 'Default',

        [string]$Model,

        [string]$Provider,

        [switch]$Force,

        [switch]$DryRun
    )

    # Delegate to the standalone pipeline script
    $moduleRoot = $PSScriptRoot | Split-Path -Parent
    $scriptPath = Join-Path $moduleRoot 'Invoke-LeadForge.ps1'

    $scriptParams = @{
        Path  = $Path
        Steps = $Steps
    }
    if ($OutputPath) { $scriptParams['OutputPath'] = $OutputPath }
    if ($Profile) { $scriptParams['Profile'] = $Profile }
    if ($Model) { $scriptParams['Model'] = $Model }
    if ($Provider) { $scriptParams['Provider'] = $Provider }
    if ($Force) { $scriptParams['Force'] = $true }
    if ($DryRun) { $scriptParams['DryRun'] = $true }

    & $scriptPath @scriptParams
}