MaestroKit.psm1

# MaestroKit distribution module. Thin wrappers over the canonical scripts
# shipped in this directory — the git repo remains the single source of truth.

$script:BundleRoot = $PSScriptRoot

function Install-Maestro {
    <#
    .SYNOPSIS
    Installs the Maestro bundle (skills, references, agents) into a target repo
    (-Scope Project, the default) or into your profile (-Scope User).
    .EXAMPLE
    Install-Maestro -Target D:\repos\my-app -Locations .omp,.claude -Force
    .EXAMPLE
    Install-Maestro -Scope User -Locations .omp,.claude -Force
    #>

    [CmdletBinding()]
    param(
        [string]$Target = (Get-Location).Path,
        [ValidateSet('Project', 'User')][string]$Scope = 'Project',
        [string[]]$Locations = @(".agents"),
        [switch]$Clean,
        [switch]$Force
    )
    $invokeArgs = @{ Scope = $Scope; Locations = $Locations; Clean = $Clean; Force = $Force }
    if ($PSBoundParameters.ContainsKey('Target')) { $invokeArgs.Target = $Target }
    & (Join-Path $script:BundleRoot "Install-Maestro.ps1") @invokeArgs
}

function Test-MaestroKit {
    <#
    .SYNOPSIS
    Runs the source-bundle consistency validator against a checkout of the Maestro repo.
    #>

    [CmdletBinding()]
    param(
        [string]$Root,
        [string]$ToolsDir = (Join-Path $script:BundleRoot "tools")
    )
    $validator = Join-Path $ToolsDir "validate-bundle.ps1"
    $invokeArgs = @{}
    if ($Root) { $invokeArgs.Root = $Root }
    & $validator @invokeArgs
}

function Invoke-MaestroSmokeInstall {
    <#
    .SYNOPSIS
    End-to-end install gate: installs to a temp dir and asserts structure, substitution, version stamp.
    #>

    [CmdletBinding()]
    param(
        [string]$Root,
        [switch]$Keep
    )
    $smoke = Join-Path $script:BundleRoot "tools/smoke-install.ps1"
    $invokeArgs = @{}
    if ($Root) { $invokeArgs.Root = $Root }
    if ($Keep) { $invokeArgs.Keep = $true }
    & $smoke @invokeArgs
}

Export-ModuleMember -Function Install-Maestro, Test-MaestroKit, Invoke-MaestroSmokeInstall