[CmdletBinding()]
param(
  [string]$ProjectRoot = (Get-Location).Path,
  [switch]$Plan,
  [switch]$Force,
  [switch]$InitSmoke,
  [switch]$InitGitIfNeeded,
  [switch]$SkipBaselineCommit,
  [switch]$CommitBaseline
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$installScript = Join-Path $PSScriptRoot 'install-agent.ps1'
if (-not (Test-Path -LiteralPath $installScript -PathType Leaf)) {
  throw "找不到 install-agent.ps1: $installScript"
}

$forwardArgs = @{
  ProjectRoot = $ProjectRoot
  Scope = 'project'
}

if ($Plan.IsPresent) {
  $forwardArgs['Plan'] = $true
}

if ($Force.IsPresent) {
  $forwardArgs['Force'] = $true
}

if ($InitSmoke.IsPresent) {
  $forwardArgs['InitSmoke'] = $true
}

if ($InitGitIfNeeded.IsPresent) {
  $forwardArgs['InitGitIfNeeded'] = $true
}

if ($SkipBaselineCommit.IsPresent) {
  $forwardArgs['SkipBaselineCommit'] = $true
}

if ($CommitBaseline.IsPresent) {
  $forwardArgs['CommitBaseline'] = $true
}

Write-Output 'AliasScope: project'
& $installScript @forwardArgs
exit $LASTEXITCODE
