[CmdletBinding(SupportsShouldProcess = $true, DefaultParameterSetName = 'List')] param( [Parameter(ParameterSetName = 'List')][switch]$List, [Parameter(Mandatory = $true, ParameterSetName = 'Selected')][string[]]$Skill, [Parameter(Mandatory = $true, ParameterSetName = 'All')][switch]$All ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' try { Import-Module (Join-Path $PSScriptRoot 'scripts/XasSkills.psm1') -Force $catalog = @(Get-XasSkillCatalog -RepositoryRoot $PSScriptRoot) if ($PSCmdlet.ParameterSetName -eq 'List') { if ($catalog.Count -eq 0) { Write-Host 'No installable skills found.' } $catalog | Select-Object Name, Description | Format-Table -AutoSize Write-Host 'Usage: .\skills install | .\skills install --all (add --preview to inspect first)' exit 0 } if ($All) { $Skill = @($catalog | ForEach-Object { $_.Name }) } if (@($Skill).Count -eq 0) { Write-Host 'No installable skills found.'; exit 0 } $skillsRoot = Get-XasDefaultSkillsRoot if ($WhatIfPreference) { Invoke-XasInstall -RepositoryRoot $PSScriptRoot -SkillsRoot $skillsRoot -Skill $Skill -Preview | Format-Table -AutoSize Write-Host "Preview only. Destination: $skillsRoot" } elseif ($PSCmdlet.ShouldProcess($skillsRoot, 'Install selected xas-skills')) { Invoke-XasInstall -RepositoryRoot $PSScriptRoot -SkillsRoot $skillsRoot -Skill $Skill | ForEach-Object { Write-Host ("{0}: {1}" -f $_.Name, $_.Status) } Write-Host 'Skills are available on the next turn. If they do not appear, restart Codex.' } exit 0 } catch { Write-Error $_ -ErrorAction Continue exit 1 }