feat(installer): install via managed manifest with non-interactive params (PowerShell)

install.ps1 now delegates every destination to Sync-ManagedDestination
instead of a blind copy-and-backup loop, so repeated installs are cheap
and safe by default.

Adds -Client and -Platform parameters so CI or scripts can run fully
non-interactively (install.ps1 -Client Both -Platform Windows); both fall
back to the existing interactive prompts when omitted. Plugin updates now
require an explicit -UpdatePlugins switch instead of always updating
already-installed plugins, so a configuration update never silently
changes third-party plugin code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Julian lechner
2026-09-11 15:42:59 +02:00
co-authored by Claude Sonnet 5
parent 80cff169f4
commit f72af0ee39
+21 -27
View File
@@ -1,24 +1,38 @@
[CmdletBinding()]
param([switch]$DryRun)
param(
[switch]$DryRun,
[ValidateSet('Codex','Claude','Both')][string]$Client,
[ValidateSet('Windows','Linux')][string]$Platform,
[switch]$UpdatePlugins
)
$ErrorActionPreference = 'Stop'
$root = Split-Path $PSScriptRoot -Parent
. (Join-Path $PSScriptRoot 'lib/plugins.ps1')
. (Join-Path $PSScriptRoot 'lib/manifest.ps1')
$buildScript = Join-Path $PSScriptRoot 'build.ps1'
& $buildScript
if (-not $?) { throw 'Build failed. Installation was not started.' }
$generated = Join-Path $root 'generated'
if (-not (Test-Path $generated)) { throw 'Generated output is missing after a successful build.' }
if (-not $Platform) {
Write-Output 'Select target platform:'
Write-Output '1) Windows'
Write-Output '2) Linux'
do { $platformSelection = Read-Host 'Selection [1-2]' } while ($platformSelection -notin @('1','2'))
$platform = @{'1'='windows'; '2'='linux'}[$platformSelection]
$Platform = @{'1'='Windows'; '2'='Linux'}[$platformSelection]
}
$platform = $Platform.ToLowerInvariant()
if (-not $Client) {
Write-Output 'Select installation target:'
Write-Output '1) Codex'
Write-Output '2) Claude'
Write-Output '3) Both'
do { $selection = Read-Host 'Selection [1-3]' } while ($selection -notin @('1','2','3'))
$Client = @{'1'='Codex'; '2'='Claude'; '3'='Both'}[$selection]
}
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$homePath = [Environment]::GetFolderPath('UserProfile')
$shellCommand = 'pwsh -NoProfile -ExecutionPolicy Bypass -File'
@@ -28,31 +42,11 @@ $targets = @()
if ($Client -in @('Codex','Both')) { $targets += @{ Source=(Join-Path $generated "codex-$platform"); Destination=(Join-Path $homePath '.codex') } }
if ($Client -in @('Codex','Both')) { $targets += @{ Source=(Join-Path $generated "codex-$platform/skills"); Destination=(Join-Path $homePath '.agents/skills') } }
if ($Client -in @('Claude','Both')) { $targets += @{ Source=(Join-Path $generated "claude-$platform"); Destination=(Join-Path $homePath '.claude') } }
foreach ($item in $targets) {
$backupRoot = Join-Path $item.Destination 'backups'
Get-ChildItem $item.Source -File -Recurse | ForEach-Object {
$relative = $_.FullName.Substring($item.Source.Length).TrimStart([char[]]@('\','/'))
$target = Join-Path $item.Destination $relative
if ($DryRun) { Write-Output "DRYRUN $($_.FullName) -> $target"; return }
if (Test-Path $target) {
$backup = Join-Path $backupRoot $relative
New-Item (Split-Path $backup -Parent) -ItemType Directory -Force | Out-Null
Copy-Item $target "$backup.$stamp" -Force
Sync-ManagedDestination -Source $item.Source -Destination $item.Destination -Stamp $stamp `
-AiConfigRoot $item.Destination.Replace('\','/') -ShellCommand $shellCommand -WindowsShellCommand $windowsShellCommand -DryRun:$DryRun
}
New-Item (Split-Path $target -Parent) -ItemType Directory -Force | Out-Null
$content = Get-Content $_.FullName -Raw
if ($content.Contains('__AI_CONFIG_ROOT__') -or $content.Contains('__HOOK_COMMAND__') -or $content.Contains('__WINDOWS_HOOK_COMMAND__')) {
$replacement = $item.Destination.Replace('\','/')
$content = $content.Replace('__AI_CONFIG_ROOT__', $replacement)
$content = $content.Replace('__HOOK_COMMAND__', $shellCommand)
$content = $content.Replace('__WINDOWS_HOOK_COMMAND__', $windowsShellCommand)
$content = $content.Replace('__HOOK_SCRIPT__', 'flashbang.ps1')
$content = $content.Replace('__WINDOWS_HOOK_SCRIPT__', 'flashbang.ps1')
[System.IO.File]::WriteAllText($target, $content, (New-Object System.Text.UTF8Encoding($false)))
}
else { Copy-Item $_.FullName $target -Force }
Write-Output "INSTALL $target"
}
}
Install-ConfiguredPlugins -RepositoryRoot $root -Client $Client -DryRun:$DryRun -Update
Install-ConfiguredPlugins -RepositoryRoot $root -Client $Client -DryRun:$DryRun -Update:$UpdatePlugins
Write-Output ($(if ($DryRun) { 'PASS install dry-run' } else { 'PASS install' }))