param( [string]$DriveRoot = (Resolve-Path "$PSScriptRoot\..\..").Path, [switch]$DownloadBackends, [switch]$PullModels, [switch]$BuildRust, [string]$BrandName = "JackAILocal" ) $ErrorActionPreference = 'Stop' Set-Location $DriveRoot Write-Host "Preparing $BrandName at $DriveRoot" New-Item -ItemType Directory -Force -Path bin, logs, diagnostics, cache\tmp, cache\runtime, models\ollama, models\gguf, models\hf | Out-Null if ($BuildRust) { & "$DriveRoot\factory\powershell\Build-RustBinaries.ps1" -DriveRoot $DriveRoot } if ($DownloadBackends) { & "$DriveRoot\factory\powershell\Install-Backends.ps1" -DriveRoot $DriveRoot } if ($PullModels) { & "$DriveRoot\factory\powershell\Install-Models.ps1" -DriveRoot $DriveRoot } & "$DriveRoot\factory\powershell\Apply-Branding.ps1" -DriveRoot $DriveRoot -BrandName $BrandName & "$DriveRoot\factory\powershell\Generate-Manifest.ps1" -DriveRoot $DriveRoot & "$DriveRoot\windows\Preflight-Windows.ps1" Write-Host "Factory preparation complete."