feat(customizations): add removal commands

This commit is contained in:
Julian lechner committed 2026-09-30 17:08:59 +02:00
1 parent 29c0e98272
commit 05663197f7
6 files changed
+333

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
[CmdletBinding()]
param(
[ValidateSet('Codex','Claude','Both')][string]$Client,
[string]$Key
)
$ErrorActionPreference = 'Stop'
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
. (Join-Path $root 'scripts/lib/install-targets.ps1')
$selectedClient = $Client
$selectedKey = $Key
. (Join-Path $root 'scripts/lib/credentials.ps1')
$Client = $selectedClient
$Key = $selectedKey
if (-not $Client) { $Client = Read-InstallClient -Client $Client }
if (-not $Key) { $Key = Read-Host 'Credential key to remove' }
Assert-CredentialKey $Key
foreach ($target in $(if ($Client -eq 'Both') { @('Codex', 'Claude') } else { @($Client) })) {
try {
Remove-ManagedCredential $target $Key
Write-Output "Credential removed for $($target.ToLowerInvariant())."
} catch [ComponentModel.Win32Exception] {
if ($_.Exception.NativeErrorCode -ne 1168) { throw }
Write-Output "Credential not found for $($target.ToLowerInvariant())."
}
}
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
client=
key=
while [ $# -gt 0 ]; do
case "$1" in
--client) client=${2:?--client requires a value}; shift 2 ;;
--key) key=${2:?--key requires a value}; shift 2 ;;
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;;
esac
done
[ -n "$client" ] || read -r -p 'Select client (codex, claude, or both) ' client
[ -n "$key" ] || read -r -p 'Credential key to remove ' key
case "$client" in codex|Codex|claude|Claude|both|Both) ;; *) printf 'Unknown --client value: %s\n' "$client" >&2; exit 1 ;; esac
[[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]{0,127}$ ]] || { printf 'Credential key must be an environment-variable-compatible name.\n' >&2; exit 1; }
powershell_command=$(command -v powershell.exe || command -v powershell || command -v pwsh || true)
[ -n "$powershell_command" ] || { printf 'PowerShell is required to remove credentials from the Windows credential store.\n' >&2; exit 1; }
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
"$powershell_command" -NoProfile -ExecutionPolicy Bypass -File "$script_dir/remove-credentials.ps1" -Client "$client" -Key "$key"
+15
View File
@@ -0,0 +1,15 @@
[CmdletBinding()]
param(
[ValidateSet('Codex','Claude','Both')][string]$Client,
[AllowEmptyString()][string]$Instruction,
[string]$HomePath = [Environment]::GetFolderPath('UserProfile')
)
$ErrorActionPreference = 'Stop'
$root = Split-Path (Split-Path $PSScriptRoot -Parent) -Parent
. (Join-Path $root 'scripts/lib/install-targets.ps1')
if (-not $Client) { $Client = Read-InstallClient -Client $Client }
if (-not $PSBoundParameters.ContainsKey('Instruction')) { $Instruction = Read-Host 'Instruction to remove' }
if ([string]::IsNullOrWhiteSpace($Instruction) -or $Instruction.Length -gt 65536) { throw 'Instruction must contain between 1 and 65536 characters.' }
& python (Join-Path $root 'scripts/lib/remove-instruction.py') --client $Client.ToLowerInvariant() --instruction $Instruction.TrimEnd() --home $HomePath
if ($LASTEXITCODE -ne 0) { throw 'Instruction removal failed.' }
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
client=
instruction=
home_path=${HOME:?HOME is required}
while [ $# -gt 0 ]; do
case "$1" in
--client) client=${2:?--client requires a value}; shift 2 ;;
--instruction) instruction=${2:?--instruction requires a value}; shift 2 ;;
--home) home_path=${2:?--home requires a value}; shift 2 ;;
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;;
esac
done
[ -n "$client" ] || read -r -p 'Select client (codex, claude, or both) ' client
[ -n "$instruction" ] || read -r -p 'Instruction to remove ' instruction
case "$client" in codex|Codex|claude|Claude|both|Both) ;; *) printf 'Unknown --client value: %s\n' "$client" >&2; exit 1 ;; esac
case "$home_path" in /*|[A-Za-z]:[\\/]*) ;; *) printf 'Home path must be absolute.\n' >&2; exit 1 ;; esac
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
python_command=$(command -v python || command -v python3 || true)
[ -n "$python_command" ] || { printf 'Python is required to remove instructions.\n' >&2; exit 1; }
"$python_command" "$script_dir/../lib/remove-instruction.py" --client "${client,,}" --instruction "$instruction" --home "$home_path"