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

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

function Install-Maestro {
    [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
}

<#
.SYNOPSIS
Runs the source-bundle consistency validator against a checkout of the Maestro repo.
.NOTES
Audience: maintainers + end users running post-install self-checks.
#>

function Test-MaestroKit {
    [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
}

<#
.SYNOPSIS
End-to-end install gate: installs to a temp dir and asserts structure, substitution, version stamp.
.NOTES
Audience: maintainers + end users verifying their installed copy.
#>

function Invoke-MaestroSmokeInstall {
    [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