CI / CI configuration security checks (push) Successful in 4s
CI / Capabilities and shell quality (push) Successful in 12s
CI / Python tests and compilation (push) Successful in 31s
CI / QMD unit tests (push) Successful in 7s
CI / Build and inspect generated packages (push) Successful in 25s
CI / PowerShell tests on Ubuntu (push) Successful in 1m41s
CI / Installed client configuration smoke tests (push) Successful in 1m8s
CI / Bash integration and installation guards (push) Successful in 1m39s
add-credentials.ps1 and remove-credentials.ps1 saved $Client and $Key before dot-sourcing with-credential.ps1 and assigned them back afterwards. Without -Client, that assignment put an empty string into a ValidateSet variable, and the script stopped with ValidateSetFailure before it could ask which client to use. with-credential.ps1 now uses its own variable names, so the save-and-restore is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.4 KiB
PowerShell
36 lines
1.4 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet('Codex', 'Claude', 'Both')][string]$Client,
|
|
[string]$Key,
|
|
[switch]$ValueFromStdin,
|
|
[string]$HomePath = [Environment]::GetFolderPath('UserProfile')
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
|
|
. (Join-Path $root 'scripts/lib/install-targets.ps1')
|
|
. (Join-Path $root 'scripts/lib/with-credential.ps1')
|
|
|
|
if (-not $Client) { $Client = Read-InstallClient -Client $Client }
|
|
if (-not $Key) { $Key = Read-Host 'Credential key' }
|
|
Assert-CredentialKey $Key
|
|
if (-not [System.IO.Path]::IsPathRooted($HomePath)) { throw 'HomePath must be absolute.' }
|
|
if ($ValueFromStdin) {
|
|
$text = [Console]::In.ReadToEnd().TrimEnd("`r", "`n")
|
|
$Value = ConvertTo-SecureString $text -AsPlainText -Force
|
|
$text = $null
|
|
} else {
|
|
$Value = Read-Host 'Credential value' -AsSecureString
|
|
}
|
|
|
|
$bin = Join-Path $HomePath '.my-ai-configuration/bin'
|
|
New-Item -ItemType Directory -Path $bin -Force | Out-Null
|
|
foreach ($source in @('with-credential.ps1', 'with-credential.sh')) {
|
|
# Always refresh so fixes to the helper reach machines that already have it.
|
|
Copy-Item -LiteralPath (Join-Path $root "scripts/lib/$source") -Destination (Join-Path $bin $source) -Force
|
|
}
|
|
foreach ($target in $(if ($Client -eq 'Both') { @('Codex', 'Claude') } else { @($Client) })) {
|
|
Set-ManagedCredential $target $Key $Value
|
|
Write-Output "Credential stored for $($target.ToLowerInvariant())."
|
|
}
|
|
$Value = $null
|