Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)
Python
patch: clarify installer progress and recovery (#2032)
Ali Khokhar530eacac3689
diff --git a/.github/ISSUE_TEMPLATE/installation-problem.yml b/.github/ISSUE_TEMPLATE/installation-problem.ymlindex 5396c387..1c5e9879 100644--- a/.github/ISSUE_TEMPLATE/installation-problem.yml+++ b/.github/ISSUE_TEMPLATE/installation-problem.yml@@ -7,6 +7,6 @@ body:id: descriptionattributes:label: Installation issue- description: Describe what happened and include the error you received. You can attach screenshots here if helpful.+ description: Describe what happened. Include the terminal error and attach the installer log shown at the end, if available. You can also attach screenshots here.validations:required: truediff --git a/scripts/install.ps1 b/scripts/install.ps1index 2526ed49..25e5e60d 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -42,6 +42,16 @@ $script:InstallAider = $true$script:PiAvailable = $false$script:MuseAvailable = $false$script:EnableRtk = $Rtk.IsPresent+$script:InstallLog = ""+$script:InstallLogWarning = $false+$script:InstallSteps = [ordered] @{}+$script:CurrentInstallStep = ""+$script:InstallStepOutcome = "Completed"+$script:InstallerPath = $PSCommandPath+$script:InstallStageNumber = 0+$script:InstallStageCount = 0+$script:FccVerified = $false+$script:DesktopReady = $false$FccCommands = @(# Include retired entry points so updates reject older FCC processes before replacement."fcc-desktop",@@ -84,6 +94,116 @@ function Write-Step {Write-Host "==> $Message"}+function Write-InstallLog {+ param([string] $Message)++ if (-not $script:InstallLog) { return }+ try {+ [IO.File]::AppendAllText($script:InstallLog, "$(Get-Date -Format o) $Message`n", [Text.UTF8Encoding]::new($false))+ }+ catch {+ $script:InstallLog = ""+ if (-not $script:InstallLogWarning) {+ $script:InstallLogWarning = $true+ Write-Warning "Could not write the installer log. Installation will continue. $($_.Exception.Message)"+ }+ }+}++function Initialize-InstallLog {+ if ($DryRun) { return }+ try {+ $directory = Join-Path $env:USERPROFILE ".fcc\logs"+ [void] [IO.Directory]::CreateDirectory($directory)+ $script:InstallLog = Join-Path $directory ("install-$(Get-Date -Format yyyyMMdd-HHmmss)-$([guid]::NewGuid().ToString('N')).log")+ Write-InstallLog "Starting Free Claude Code installer"+ }+ catch {+ $script:InstallLogWarning = $true+ Write-Warning "Could not create the installer log. Installation will continue. $($_.Exception.Message)"+ }+}++function Complete-InstallStep {+ param([string] $Outcome = $script:InstallStepOutcome)++ if (-not $script:CurrentInstallStep) { return }+ $script:InstallSteps[$script:CurrentInstallStep] = $Outcome+ Write-InstallLog "$Outcome`: $script:CurrentInstallStep"+ $script:CurrentInstallStep = ""+}++function Start-InstallStep {+ param([string] $Name, [string] $Message = $Name)++ if ($DryRun) { Write-Step $Message; return }+ if ($script:InstallSteps.Count -eq 0) { return }+ Complete-InstallStep+ $script:CurrentInstallStep = $Name+ $script:InstallStepOutcome = "Completed"+ $script:InstallSteps[$Name] = "Running"+ Write-InstallLog "Starting: $Name"+ if ($script:InstallStageCount -gt 0) {+ $script:InstallStageNumber+++ Write-Host "`n[$($script:InstallStageNumber)/$($script:InstallStageCount)] $Message"+ }+}++function Get-InstallerRetryCommand {+ $options = @()+ if ($VoiceLocal) { $options += "-VoiceLocal" }+ if ($TorchBackend) { $options += @("-TorchBackend", $TorchBackend) }+ if ($script:EnableRtk) { $options += "-Rtk" }+ if ($script:InstallerPath -and (Test-Path -LiteralPath $script:InstallerPath -PathType Leaf)) {+ return "& " + (Format-Command $script:InstallerPath $options)+ }+ return "& ([scriptblock]::Create((irm 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.ps1'))) " + (($options | ForEach-Object { Format-Argument $_ }) -join " ")+}++function Show-InstallReport {+ param([bool] $Succeeded, [bool] $Cancelled = $false)++ if ($DryRun) { return }+ if (-not $Succeeded) {+ if ($Cancelled) { Write-Host "`nInstallation cancelled." }+ else { Write-Host "`nInstallation did not finish." }+ foreach ($outcome in @("Completed", "Reused", "Skipped", "Failed", "Cancelled", "Not attempted")) {+ $labels = @($script:InstallSteps.GetEnumerator() | Where-Object { $_.Value -eq $outcome } | ForEach-Object { $_.Key })+ if ($labels.Count -gt 0) { Write-Host "${outcome}: $($labels -join ', ')" }+ }+ Write-Host "Completed changes have been kept. Rerun the installer to try again."+ Write-Host "Retry: $(Get-InstallerRetryCommand)"+ if (-not $Cancelled) { Write-Host "For help, include the terminal error and the installer log." }+ }+ if ($script:InstallLog) { Write-Host "Installer log: $script:InstallLog" }+}++function Write-WindowsLaunchGuidance {+ param([string] $FilePath, [Exception] $Exception, [string] $Stderr = "")++ $policyFailure = $Stderr -match '\(os error (4551|1260)\)'+ for ($cause = $Exception; $null -ne $cause; $cause = $cause.InnerException) {+ if ($cause -is [ComponentModel.Win32Exception] -and $cause.NativeErrorCode -in @(4551, 1260)) {+ $policyFailure = $true+ }+ # Start-Process on Windows PowerShell drops the native error code.+ foreach ($code in @(4551, 1260)) {+ if ($cause.Message.Contains([ComponentModel.Win32Exception]::new($code).Message)) {+ $policyFailure = $true+ }+ }+ }+ if ($policyFailure) {+ $guidance = @"+Windows application policy prevented this command from running: '$FilePath'.+Inspect recent policy events to identify the blocked file, then ask your administrator to allow the required application:+Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-CodeIntegrity/Operational'; Id=3077,3089; StartTime=(Get-Date).AddMinutes(-15)} | Format-List TimeCreated,Id,Message+"@+ Write-Host $guidance+ Write-InstallLog $guidance+ }+}+function Test-InteractiveInstaller {return (-not [Console]::IsInputRedirected) -and (-not [Console]::IsOutputRedirected)}@@ -243,11 +363,20 @@ function Invoke-NativeCommand {return}- $global:LASTEXITCODE = 0- & $FilePath @Arguments- $exitCode = $LASTEXITCODE- if ($exitCode -ne 0) {- throw "Command failed with exit code ${exitCode}: $commandText"+ Write-InstallLog "+ $commandText"+ try {+ $global:LASTEXITCODE = 0+ & $FilePath @Arguments+ $exitCode = $LASTEXITCODE+ Write-InstallLog "Exit code ${exitCode}: $commandText"+ if ($exitCode -ne 0) {+ throw "Command failed with exit code ${exitCode}: $commandText"+ }+ }+ catch {+ Write-InstallLog $_.Exception.Message+ Write-WindowsLaunchGuidance -FilePath $FilePath -Exception $_.Exception+ throw}}@@ -259,21 +388,37 @@ function Invoke-Utf8NativeCapture {$commandText = Format-Command -FilePath $FilePath -Arguments $ArgumentsWrite-Host "+ $commandText"+ if ($DryRun) { return "" }+ Write-InstallLog "+ $commandText"$originalOutputEncoding = [Console]::OutputEncoding+ $originalErrorPreference = $ErrorActionPreferencetry {[Console]::OutputEncoding = [Text.UTF8Encoding]::new($false)- $global:LASTEXITCODE = 0- $output = & $FilePath @Arguments+ $ErrorActionPreference = "Continue"+ $global:LASTEXITCODE = $null+ $captured = @(& $FilePath @Arguments 2>&1)$exitCode = $LASTEXITCODE}+ catch {+ Write-InstallLog $_.Exception.Message+ Write-WindowsLaunchGuidance -FilePath $FilePath -Exception $_.Exception+ throw+ }finally {[Console]::OutputEncoding = $originalOutputEncoding+ $ErrorActionPreference = $originalErrorPreference}- if ($exitCode -ne 0) {- throw "Command failed with exit code ${exitCode}: $commandText"+ $output = ($captured | Where-Object { $_ -isnot [Management.Automation.ErrorRecord] } | Out-String).Trim()+ $errors = @($captured | Where-Object { $_ -is [Management.Automation.ErrorRecord] })+ $stderr = ($errors | ForEach-Object { $_.ToString() } | Out-String).Trim()+ Write-InstallLog "Exit code ${exitCode}: $commandText`n$output`n$stderr"+ if ($null -eq $exitCode -or $exitCode -ne 0) {+ $cause = if ($errors.Count) { $errors[0].Exception } else { $null }+ Write-WindowsLaunchGuidance -FilePath $FilePath -Exception $cause -Stderr $stderr+ throw "Command failed with exit code ${exitCode}: $commandText`n$output`n$stderr"}- return ($output | Out-String).Trim()+ return $output}function Get-ApplicationCommand {@@ -482,7 +627,7 @@ function Confirm-Application {if (-not $command) {throw "$DisplayName was installed, but '$CommandName' is not available on PATH."}- Invoke-NativeCommand -FilePath $command.Source -Arguments @("--version")+ Write-Host (Invoke-Utf8NativeCapture -FilePath $command.Source -Arguments @("--version"))}function Test-PiApplication {@@ -515,7 +660,7 @@ function Confirm-PiApplication {if (-not (Test-PiApplication $command)) {throw "The 'pi' command at '$($command.Source)' is not a compatible Pi Coding Agent."}- Invoke-NativeCommand -FilePath $command.Source -Arguments @("--version")+ Write-Host (Invoke-Utf8NativeCapture -FilePath $command.Source -Arguments @("--version"))}function Install-Rtk {@@ -586,7 +731,12 @@ function Invoke-RtkCommand {$previousTelemetryDisabled = $env:RTK_TELEMETRY_DISABLEDtry {$env:RTK_TELEMETRY_DISABLED = "1"- Invoke-NativeCommand -FilePath $command.Source -Arguments $Arguments+ if ($Arguments[0] -in @("--version", "gain")) {+ Write-Host (Invoke-Utf8NativeCapture -FilePath $command.Source -Arguments $Arguments)+ }+ else {+ Invoke-NativeCommand -FilePath $command.Source -Arguments $Arguments+ }}finally {if ($hadTelemetryDisabled) {@@ -670,6 +820,7 @@ function Configure-RtkForSelectedAgents {function Ensure-ClaudeCode {if (Get-ApplicationCommand "claude") {+ $script:InstallStepOutcome = "Reused"Write-Host "Claude Code already found on PATH; verifying it."}else {@@ -682,6 +833,7 @@ function Ensure-ClaudeCode {function Ensure-Codex {if (Get-ApplicationCommand "codex") {+ $script:InstallStepOutcome = "Reused"Write-Host "Codex already found on PATH; verifying it."}else {@@ -697,6 +849,7 @@ function Ensure-Pi {Add-NpmBinDirectories$existingPi = Get-ApplicationCommand "pi"if ($existingPi -and ($DryRun -or (Test-PiApplication $existingPi))) {+ $script:InstallStepOutcome = "Reused"Write-Host "Pi already found on PATH; verifying it."}else {@@ -715,6 +868,7 @@ function Ensure-Pi {-not (Test-PiApplication $currentPi))if ((-not $currentPi) -or $unchangedIncompatiblePi) {+ $script:InstallStepOutcome = "Skipped"Write-Host "Pi was not installed; continuing without it."return}@@ -901,17 +1055,9 @@ function Install-OpenCode {}}-function Ensure-OpenCode {+function Get-OpenCodeInstallState {$command = if ($script:OriginalOpenCode) { $script:OriginalOpenCode } else { Get-ApplicationCommand "opencode" }$nativePath = Join-Path $env:USERPROFILE ".opencode\bin\opencode.exe"- if ($DryRun) {- Write-Host "+ opencode --version"- Write-Host "Install stable OpenCode 2 if absent, or migrate v1 at '$nativePath'; external v1 requires manual upgrade."- Write-Host "Check and back up the recognized old OpenCode RTK plugin if present."- if (-not $command) { Install-OpenCode }- return- }-$install = $trueif ($command) {$version = Get-OpenCodeVersion $command.Source@@ -938,12 +1084,33 @@ function Ensure-OpenCode {throw "OpenCode installation path is linked: '$target'. Migrate it manually."}}+ }+ return [pscustomobject] @{ Install = $install; PluginPath = $pluginPath }+}++function Ensure-OpenCode {+ $command = if ($script:OriginalOpenCode) { $script:OriginalOpenCode } else { Get-ApplicationCommand "opencode" }+ $nativePath = Join-Path $env:USERPROFILE ".opencode\bin\opencode.exe"+ if ($DryRun) {+ Write-Host "+ opencode --version"+ Write-Host "Install stable OpenCode 2 if absent, or migrate v1 at '$nativePath'; external v1 requires manual upgrade."+ Write-Host "Check and back up the recognized old OpenCode RTK plugin if present."+ if (-not $command) { Install-OpenCode }+ return+ }++ $state = Get-OpenCodeInstallState+ $pluginPath = $state.PluginPath+ if ($state.Install) {Install-OpenCodeAdd-KnownBinDirectoriesif ((Get-OpenCodeVersion $nativePath) -notmatch '^2\.') {throw "The OpenCode installer did not install stable OpenCode 2 at '$nativePath'."}}+ else {+ if (-not $pluginPath) { $script:InstallStepOutcome = "Reused" }+ }# Check the command selected after the installer's PATH additions.$command = Get-ApplicationCommand "opencode"if (-not $command) { throw "OpenCode is not available on PATH after installation." }@@ -967,6 +1134,7 @@ function Ensure-Cline {$command = Get-ApplicationCommand "cline"if ($command) {+ $script:InstallStepOutcome = "Reused"Write-Host "Cline already found on PATH; verifying it."}else {@@ -1006,6 +1174,7 @@ function Install-Hermes {function Ensure-Hermes {$command = Get-ApplicationCommand "hermes"if ($command) {+ $script:InstallStepOutcome = "Reused"Write-Host "Hermes Agent already found on PATH; verifying it."}else {@@ -1023,6 +1192,7 @@ function Install-Grok {function Ensure-Grok {$command = Get-ApplicationCommand "grok"if ($command) {+ $script:InstallStepOutcome = "Reused"Write-Host "Grok Build already found on PATH; verifying it."}else {@@ -1078,6 +1248,7 @@ function Ensure-Aider {}if ($command) {+ $script:InstallStepOutcome = "Reused"Write-Host "Aider already found on PATH; verifying it."}else {@@ -1253,6 +1424,7 @@ function Ensure-Dsh {if ($command) {$version = Get-DshVersion $command.Sourceif (Test-DshVersion $version) {+ $script:InstallStepOutcome = "Reused"Write-Host "DeepSeek Harness $version already satisfies >=$DshMinimumVersion; leaving it unchanged."return}@@ -1263,54 +1435,71 @@ function Ensure-Dsh {Confirm-DshApplication}+function Confirm-SelectedPrerequisites {+ if ($DryRun) { return }+ # Pi can bootstrap Node/npm before the dependent agents are installed.+ $installingPi = $script:InstallPi -and -not (Find-InstalledCodingAgent "pi")+ if (-not $installingPi) {+ if ($script:InstallDsh) { [void] (Confirm-DshToolchain) }+ if ($script:InstallCline -and -not (Get-ApplicationCommand "cline") -and -not (Get-ApplicationCommand "npm")) {+ throw "Cline installation requires npm. Install Node.js from https://nodejs.org/en/download, then rerun the installer."+ }+ }+ if ($script:InstallHermes -and -not (Get-ApplicationCommand "hermes")) { Confirm-HermesArchitecture }+ if ($script:InstallOpenCode) {+ $state = Get-OpenCodeInstallState+ if ($state.Install) { [void] (Get-OpenCodeWindowsAssetName) }+ }+}+function Ensure-SelectedCodingAgents {if ($script:InstallClaudeCode) {- Write-Step "Ensuring Claude Code is installed"+ Start-InstallStep "Claude Code" "Ensuring Claude Code is installed"Ensure-ClaudeCode}if ($script:InstallCodex) {- Write-Step "Ensuring Codex is installed"+ Start-InstallStep "Codex" "Ensuring Codex is installed"Ensure-Codex}if ($script:InstallPi) {- Write-Step "Checking or installing Pi"+ Start-InstallStep "Pi" "Checking or installing Pi"Ensure-Pi}if ($script:InstallOpenCode) {- Write-Step "Ensuring OpenCode is installed"+ Start-InstallStep "OpenCode" "Ensuring OpenCode is installed"Ensure-OpenCode}if ($script:InstallCline) {- Write-Step "Ensuring Cline CLI is installed"+ Start-InstallStep "Cline" "Ensuring Cline CLI is installed"Ensure-Cline}if ($script:InstallHermes) {- Write-Step "Ensuring Hermes Agent is installed"+ Start-InstallStep "Hermes" "Ensuring Hermes Agent is installed"Ensure-Hermes}if ($script:InstallDsh) {- Write-Step "Ensuring DeepSeek Harness is installed"+ Start-InstallStep "DeepSeek Harness" "Ensuring DeepSeek Harness is installed"Ensure-Dsh}if ($script:InstallGrok) {- Write-Step "Ensuring Grok Build is installed"+ Start-InstallStep "Grok" "Ensuring Grok Build is installed"Ensure-Grok}if ($script:InstallMuse) {- Write-Step "Ensuring Muse Code is installed"+ Start-InstallStep "Muse" "Ensuring Muse Code is installed"Ensure-Muse}if ($script:InstallAider) {- Write-Step "Ensuring Aider is installed"+ Start-InstallStep "Aider" "Ensuring Aider is installed"Ensure-Aider}@@ -1406,6 +1595,7 @@ function Ensure-Uv {if ($uvCommand) {$version = Get-UvVersion $uvCommand.Sourceif (Test-SupportedStableVersion -Version $version -Minimum $MinUvVersion) {+ $script:InstallStepOutcome = "Reused"Write-Host "uv $version already satisfies >=$MinUvVersion; leaving it unchanged."return}@@ -1490,6 +1680,7 @@ function Export-FccDesktopIcon {}function Configure-AndConfirmFreeClaudeCode {+ Start-InstallStep "PATH configuration"$iconPath = Join-Path $env:USERPROFILE ".fcc\app-icon.ico"if ($DryRun) {Write-Host "+ uv tool update-shell"@@ -1511,6 +1702,7 @@ function Configure-AndConfirmFreeClaudeCode {}Invoke-NativeCommand -FilePath $uvCommand.Source -Arguments @("tool", "update-shell")$toolBin = Add-UvToolBinDirectory -UvPath $uvCommand.Source+ Start-InstallStep "FCC verification"$toolBinPath = ([IO.Path]::GetFullPath($toolBin)).TrimEnd([IO.Path]::DirectorySeparatorChar,[IO.Path]::AltDirectorySeparatorChar@@ -1531,7 +1723,9 @@ function Configure-AndConfirmFreeClaudeCode {$installedCommands[$commandName] = $command.Source}- Invoke-NativeCommand -FilePath $installedCommands["fcc-server"] -Arguments @("--version")+ Write-Host (Invoke-Utf8NativeCapture -FilePath $installedCommands["fcc-server"] -Arguments @("--version"))+ $script:FccVerified = $true+ Start-InstallStep "Desktop integration"Export-FccDesktopIcon `-DesktopCommand $installedCommands["fcc-desktop"] `-IconPath $iconPath@@ -1601,63 +1795,15 @@ function Install-FccDesktopShortcuts {$shortcut.IconLocation = "$IconPath,0"$shortcut.Description = "Run Free Claude Code in the background"$shortcut.Save()+ if ($shortcutPath -eq $shortcutPaths[0]) { $script:DesktopReady = $true }}}-if ($Help) {- Show-Usage- return-}--if ($RemainingArgs.Count -gt 0) {- Show-Usage- throw "Unknown option: $($RemainingArgs -join ' ')"-}--if ((-not [string]::IsNullOrWhiteSpace($TorchBackend)) -and (-not $VoiceLocal)) {- throw "-TorchBackend requires -VoiceLocal."-}--# Preserve the user's winning command before adding installer search paths.-$script:OriginalOpenCode = Get-ApplicationCommand "opencode"-Add-KnownBinDirectories-$script:InstallCline = [bool] ((Get-ApplicationCommand "cline") -or (Get-ApplicationCommand "npm"))-Write-Step "Checking for running Free Claude Code processes"-Assert-NoFccProcessesRunning--if (-not (Test-InteractiveInstaller)) {- $hasDsh = [bool] (Get-ApplicationCommand "dsh")- $hasDryRunToolchain = [bool] (- $DryRun -and- (Get-ApplicationCommand "node") -and- (Get-ApplicationCommand "npm")- )- $script:InstallDsh = $hasDsh -or $hasDryRunToolchain -or (Test-DshToolchain)-}--if (Test-InteractiveInstaller) {- Write-Step "Choosing coding agents"- Select-CodingAgents-}--Write-Step "Ensuring uv $MinUvVersion or newer is installed"-Ensure-Uv--Ensure-SelectedCodingAgents-Configure-RtkForSelectedAgents--Write-Step "Installing or updating Free Claude Code"-Install-FreeClaudeCode--Write-Step "Configuring PATH and verifying Free Claude Code"-Configure-AndConfirmFreeClaudeCode--Write-Host ""-if ($DryRun) {- Write-Host "Dry run complete. No changes were made."-}-else {- Write-Host "Free Claude Code is installed and verified. Open the Free Claude Code desktop shortcut to run it in the background."+function Show-InstallerNextSteps {+ Write-Host "`nFree Claude Code is installed and verified."+ if ($script:DesktopReady) {+ Write-Host "Open the Free Claude Code desktop shortcut to run it in the background."+ }Write-Host "For terminal use, start the proxy with: fcc-server"if ($script:InstallClaudeCode) {Write-Host "Run Claude Code with: fcc-claude"@@ -1674,37 +1820,124 @@ else {if ($script:InstallCline) {Write-Host "Run Cline with: fcc-cline"}- else {- Write-Host "The fcc-cline wrapper is ready after you install Cline CLI."- }if ($script:InstallHermes) {Write-Host "Run Hermes Agent with: fcc-hermes"}- else {- Write-Host "The fcc-hermes wrapper is ready after you install Hermes Agent."- }if ($script:InstallDsh) {Write-Host "Run DeepSeek Harness with: fcc-dsh"}- else {- Write-Host "The fcc-dsh wrapper is ready after you install DeepSeek Harness >=$DshMinimumVersion."- }if ($script:InstallGrok) {Write-Host "Run Grok Build with: fcc-grok"}- else {- Write-Host "The fcc-grok wrapper is ready after you install Grok Build."- }if ($script:MuseAvailable) {Write-Host "Run Muse Code with: fcc-muse"}- else {- Write-Host "The fcc-muse wrapper is ready after you install Muse Code."- }if ($script:InstallAider) {Write-Host "Run Aider with: fcc-aider"}- else {- Write-Host "The fcc-aider wrapper is ready after you install Aider."++}++if ($Help) {+ Show-Usage+ return+}++if ($RemainingArgs.Count -gt 0) {+ Show-Usage+ throw "Unknown option: $($RemainingArgs -join ' ')"+}++if ((-not [string]::IsNullOrWhiteSpace($TorchBackend)) -and (-not $VoiceLocal)) {+ throw "-TorchBackend requires -VoiceLocal."+}++Initialize-InstallLog+$script:InstallSteps["Preflight"] = "Not attempted"+$installSucceeded = $false+$installError = $null+try {+ Start-InstallStep "Preflight"+ # Preserve the user's winning command before adding installer search paths.+ $script:OriginalOpenCode = Get-ApplicationCommand "opencode"+ Add-KnownBinDirectories+ $script:InstallCline = [bool] ((Get-ApplicationCommand "cline") -or (Get-ApplicationCommand "npm"))+ Write-Step "Checking for running Free Claude Code processes"+ Assert-NoFccProcessesRunning++ if (-not (Test-InteractiveInstaller)) {+ $hasDsh = [bool] (Get-ApplicationCommand "dsh")+ $hasDryRunToolchain = [bool] (+ $DryRun -and+ (Get-ApplicationCommand "node") -and+ (Get-ApplicationCommand "npm")+ )+ $script:InstallDsh = $hasDsh -or $hasDryRunToolchain -or (Test-DshToolchain)+ }++ if (Test-InteractiveInstaller) {+ Write-Step "Choosing coding agents"+ Select-CodingAgents+ }++ $script:InstallSteps["uv"] = "Not attempted"+ $selectedAgents = @()+ foreach ($choice in @(+ @("Claude Code", $script:InstallClaudeCode), @("Codex", $script:InstallCodex),+ @("Pi", $script:InstallPi), @("OpenCode", $script:InstallOpenCode),+ @("Cline", $script:InstallCline), @("Hermes", $script:InstallHermes),+ @("DeepSeek Harness", $script:InstallDsh), @("Grok", $script:InstallGrok),+ @("Muse", $script:InstallMuse), @("Aider", $script:InstallAider)+ )) {+ if ($choice[1]) {+ $script:InstallSteps[$choice[0]] = "Not attempted"+ $selectedAgents += $choice[0]+ }+ }+ foreach ($name in @("FCC package", "PATH configuration", "FCC verification", "Desktop integration")) {+ $script:InstallSteps[$name] = "Not attempted"}+ if ($script:EnableRtk) { $script:InstallSteps["RTK configuration"] = "Not attempted" }++ Write-Host "`nInstallation plan:"+ Write-Host " Install or update Free Claude Code."+ Write-Host " Verify or install: $($selectedAgents -join ', ')."+ if ($VoiceLocal) { Write-Host " Include local voice support." }+ if ($TorchBackend) { Write-Host " PyTorch backend: $TorchBackend" }+ if ($script:EnableRtk) { Write-Host " Configure RTK for the selected agents." }+ Write-Host "Press Ctrl+C to cancel. You can rerun the installer afterward."+ $script:InstallStageCount = $script:InstallSteps.Count - 1++ Confirm-SelectedPrerequisites++ Start-InstallStep "uv" "Ensuring uv $MinUvVersion or newer is installed"+ Ensure-Uv++ Ensure-SelectedCodingAgents++ Start-InstallStep "FCC package" "Installing or updating Free Claude Code"+ Install-FreeClaudeCode++ Configure-AndConfirmFreeClaudeCode++ if ($script:EnableRtk) {+ Start-InstallStep "RTK configuration"+ Configure-RtkForSelectedAgents+ }+ Complete-InstallStep+ $installSucceeded = $true+}+catch {+ $installError = $_+ Write-InstallLog $_.Exception.Message+ throw}+finally {+ $cancelled = (-not $installSucceeded) -and ($null -eq $installError)+ if ($cancelled) { Complete-InstallStep "Cancelled" }+ elseif (-not $installSucceeded) { Complete-InstallStep "Failed" }+ Show-InstallReport -Succeeded $installSucceeded -Cancelled $cancelled+ if ($script:FccVerified) { Show-InstallerNextSteps }+}++if ($DryRun) { Write-Host "Dry run complete. No changes were made." }diff --git a/scripts/install.sh b/scripts/install.shindex 1b8044b8..2f991af2 100644--- a/scripts/install.sh+++ b/scripts/install.sh@@ -39,6 +39,23 @@ temporary_binary=""tool_bin=""pi_available=0rtk_path=""+install_log=""+install_log_warning=0+install_report_started=0+install_report=""+pending_steps=""+current_install_step=""+install_step_outcome=Completed+install_stage_number=0+install_stage_count=0+install_cancelled=0+fcc_verified=0+desktop_ready=0+installer_path=$0+# With a piped installer, $0 names the shell, which may be an existing binary.+case "${installer_path##*/}" in+ sh|-sh|bash|-bash|dash|ksh|zsh) installer_path="" ;;+esacshow_usage() {cat <<'USAGE'@@ -56,10 +73,119 @@ USAGE}fail() {+ write_install_log "error: $*"printf 'error: %s\n' "$*" >&2exit 1}+write_install_log() {+ [ -n "$install_log" ] || return 0+ if { printf '%s %s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$*" >>"$install_log"; } 2>/dev/null; then+ return 0+ fi+ install_log=""+ if [ "$install_log_warning" -eq 0 ]; then+ install_log_warning=1+ printf 'warning: Could not write the installer log. Installation will continue.\n' >&2+ fi+}++initialize_install_log() {+ [ "$dry_run" -eq 0 ] || return 0+ log_timestamp=$(date '+%Y%m%d-%H%M%S' 2>/dev/null) || log_timestamp=unknown+ install_log="${HOME:-}/.fcc/logs/install-$log_timestamp-$$.log"+ if [ -n "${HOME:-}" ] && (umask 077; mkdir -p "$HOME/.fcc/logs" && set -C && : >"$install_log") 2>/dev/null; then+ write_install_log "Starting Free Claude Code installer"+ else+ install_log=""+ install_log_warning=1+ printf 'warning: Could not create the installer log. Installation will continue.\n' >&2+ fi+}++complete_install_step() {+ [ -n "$current_install_step" ] || return 0+ install_step_result="${1:-$install_step_outcome}: $current_install_step"+ install_report="${install_report}${install_step_result}+"+ write_install_log "$install_step_result"+ current_install_step=""+}++start_install_step() {+ if [ "$dry_run" -eq 1 ]; then step "${2:-$1}"; return 0; fi+ [ "$install_report_started" -eq 1 ] || return 0+ complete_install_step+ current_install_step=$1+ install_step_outcome=Completed+ install_newline='+'+ case "$pending_steps" in+ "$1") pending_steps="" ;;+ "$1$install_newline"*) pending_steps=${pending_steps#*'+'} ;;+ esac+ write_install_log "Starting: $1"+ if [ "$install_stage_count" -gt 0 ]; then+ install_stage_number=$((install_stage_number + 1))+ printf '\n[%s/%s] %s\n' "$install_stage_number" "$install_stage_count" "${2:-$1}"+ fi+}++print_installer_retry() {+ printf 'Retry: '+ if [ -f "$installer_path" ]; then+ printf 'sh '+ shell_quote "$installer_path"+ else+ printf '%s' "curl -fsSL 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.sh' | sh -s --"+ fi+ [ "$voice_local" -eq 0 ] || printf ' --voice-local'+ if [ -n "$torch_backend" ]; then+ printf ' --torch-backend '+ shell_quote "$torch_backend"+ fi+ [ "$enable_rtk" -eq 0 ] || printf ' --rtk'+ printf '\n'+}++finish_install() {+ install_exit_code=$1+ trap - EXIT+ set +e+ if [ "$install_report_started" -eq 1 ]; then+ if [ "$install_cancelled" -eq 1 ]; then+ complete_install_step Cancelled+ elif [ "$install_exit_code" -ne 0 ]; then+ complete_install_step Failed+ else+ complete_install_step+ fi+ if [ "$install_exit_code" -ne 0 ]; then+ if [ "$install_cancelled" -eq 1 ]; then+ printf '\nInstallation cancelled.\n'+ else+ printf '\nInstallation did not finish.\n'+ fi+ printf '%s' "$install_report"+ if [ -n "$pending_steps" ]; then+ printf '%s\n' "$pending_steps" | while IFS= read -r pending; do+ printf 'Not attempted: %s\n' "$pending"+ done+ fi+ printf 'Completed changes have been kept. Rerun the installer to try again.\n'+ print_installer_retry+ if [ "$install_cancelled" -eq 0 ]; then+ printf 'For help, include the terminal error and the installer log.\n'+ fi+ fi+ [ -z "$install_log" ] || printf 'Installer log: %s\n' "$install_log"+ if [ "$fcc_verified" -eq 1 ]; then show_installer_next_steps; fi+ fi+ cleanup+ exit "$install_exit_code"+}+installer_is_interactive() {[ -t 1 ] && ( : </dev/tty ) 2>/dev/null}@@ -246,7 +372,10 @@ run() {return 0fi+ run_started=$(date +%s)+ write_install_log "$(print_command "$@")"if "$@"; then+ write_install_log "Exit code 0 after $(($(date +%s) - run_started))s: $1"return 0elsestatus=$?@@ -264,9 +393,9 @@ cleanup() {fi}-trap cleanup EXIT-trap 'exit 130' INT-trap 'exit 143' HUP TERM+trap 'finish_install "$?"' EXIT+trap 'install_cancelled=1; exit 130' INT+trap 'install_cancelled=1; exit 143' HUP TERMadd_path_entry() {[ -n "$1" ] || return 0@@ -427,6 +556,8 @@ download_and_run() {fail "The downloaded $label installer was empty."fi+ installer_started=$(date +%s)+ write_install_log "$(print_command "$interpreter" "$temporary_file" "$@")"if [ "$non_interactive" -eq 1 ]; thenprintf '+ CODEX_NON_INTERACTIVE=1 'quote_arg "$interpreter"@@ -453,6 +584,7 @@ download_and_run() {fifi+ write_install_log "$label installer completed after $(($(date +%s) - installer_started))s"rm -f "$temporary_file"temporary_file=""}@@ -614,7 +746,10 @@ run_rtk_init() {return 0fi+ rtk_started=$(date +%s)+ write_install_log "$(print_command "$rtk_path" "$@")"if RTK_TELEMETRY_DISABLED=1 "$rtk_path" "$@"; then+ write_install_log "RTK configuration completed after $(($(date +%s) - rtk_started))s"return 0elsestatus=$?@@ -656,6 +791,7 @@ configure_rtk_for_selected_agents() {ensure_claude() {if command -v claude >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Claude Code already found on PATH; verifying it.\n'elsedownload_and_run "$CLAUDE_INSTALL_URL" bash "Claude Code"@@ -667,6 +803,7 @@ ensure_claude() {ensure_codex() {if command -v codex >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Codex already found on PATH; verifying it.\n'elsedownload_and_run "$CODEX_INSTALL_URL" sh "Codex" 1@@ -682,8 +819,10 @@ ensure_pi() {existing_pi_path=$(command -v pi 2>/dev/null || true)if [ "$dry_run" -eq 1 ] && command -v pi >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Pi already found on PATH; verifying it.\n'elif pi_command_is_compatible; then+ install_step_outcome=Reusedprintf 'Pi already found on PATH; verifying it.\n'elseif [ -n "$existing_pi_path" ]; then@@ -698,6 +837,7 @@ ensure_pi() {{ [ -n "$existing_pi_path" ] &&[ "$current_pi_path" = "$existing_pi_path" ] &&! pi_command_is_compatible; }; then+ install_step_outcome=Skippedprintf 'Pi was not installed; continuing without it.\n'return 0fi@@ -749,20 +889,10 @@ run_opencode_installer() {VERSION= bash "$@"}-ensure_opencode() {+check_opencode_install() {[ -n "${HOME:-}" ] || fail "HOME is required to install OpenCode."opencode_native="$HOME/.opencode/bin/opencode"opencode_path=${original_opencode_path:-$(command -v opencode || true)}- if [ "$dry_run" -eq 1 ]; then- print_command opencode --version- printf 'Install stable OpenCode 2 if absent, or migrate v1 at %s; external v1 requires manual upgrade.\n' "$opencode_native"- printf 'Check and back up the recognized old OpenCode RTK plugin if present.\n'- if [ -z "$opencode_path" ]; then- download_and_run "$OPENCODE_INSTALL_URL" bash "OpenCode"- fi- return 0- fi-opencode_install=1if [ -n "$opencode_path" ]; thenopencode_current=$(opencode_version "$opencode_path") ||@@ -784,6 +914,25 @@ ensure_opencode() {for opencode_target in "$HOME/.opencode" "$HOME/.opencode/bin" "$opencode_native"; do[ ! -L "$opencode_target" ] || fail "OpenCode installation path is linked: $opencode_target. Migrate it manually."done+ fi+}++ensure_opencode() {+ [ -n "${HOME:-}" ] || fail "HOME is required to install OpenCode."+ opencode_native="$HOME/.opencode/bin/opencode"+ opencode_path=${original_opencode_path:-$(command -v opencode || true)}+ if [ "$dry_run" -eq 1 ]; then+ print_command opencode --version+ printf 'Install stable OpenCode 2 if absent, or migrate v1 at %s; external v1 requires manual upgrade.\n' "$opencode_native"+ printf 'Check and back up the recognized old OpenCode RTK plugin if present.\n'+ if [ -z "$opencode_path" ]; then+ download_and_run "$OPENCODE_INSTALL_URL" bash "OpenCode"+ fi+ return 0+ fi++ check_opencode_install+ if [ "$opencode_install" -eq 1 ]; thendownload_and_run "$OPENCODE_INSTALL_URL" run_opencode_installer "OpenCode"add_known_bin_directorieshash -r 2>/dev/null || true@@ -793,6 +942,9 @@ ensure_opencode() {*) fail "The OpenCode installer did not install stable OpenCode 2. See https://opencode.ai/v2/docs/" ;;esacfi+ if [ "$opencode_install" -eq 0 ] && [ -z "$opencode_plugin" ]; then+ install_step_outcome=Reused+ fi# Check the command selected after the installer's PATH additions.hash -r 2>/dev/null || trueopencode_path=$(command -v opencode || true)@@ -820,6 +972,7 @@ ensure_cline() {add_npm_bin_directoriesif command -v cline >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Cline already found on PATH; verifying it.\n'elsecommand -v npm >/dev/null 2>&1 || fail "Cline installation requires npm. Install Node.js from https://nodejs.org/en/download, then rerun the installer."@@ -858,6 +1011,7 @@ install_hermes() {ensure_hermes() {if command -v hermes >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Hermes Agent already found on PATH; verifying it.\n'elseinstall_hermes@@ -1003,6 +1157,7 @@ ensure_dsh() {if command -v dsh >/dev/null 2>&1; thenversion=$(current_dsh_version) || fail "DeepSeek Harness is present, but 'dsh --version' did not return a semantic version."if dsh_version_is_supported "$version"; then+ install_step_outcome=Reusedprintf 'DeepSeek Harness %s already satisfies >=%s; leaving it unchanged.\n' "$version" "$MIN_DSH_VERSION"return 0fi@@ -1020,6 +1175,7 @@ install_grok_build() {ensure_grok() {if command -v grok >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Grok Build already found on PATH; verifying it.\n'elseinstall_grok_build@@ -1039,6 +1195,7 @@ install_muse_code() {ensure_muse() {if command -v muse >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Muse Code already found on PATH; verifying it.\n'elseinstall_muse_code@@ -1057,6 +1214,7 @@ ensure_aider() {fiif command -v aider >/dev/null 2>&1; then+ install_step_outcome=Reusedprintf 'Aider already found on PATH; verifying it.\n'elseinstall_aider_cli@@ -1067,52 +1225,52 @@ ensure_aider() {ensure_selected_coding_agents() {if [ "$install_claude" -eq 1 ]; then- step "Ensuring Claude Code is installed"+ start_install_step "Claude Code" "Ensuring Claude Code is installed"ensure_claudefiif [ "$install_codex" -eq 1 ]; then- step "Ensuring Codex is installed"+ start_install_step "Codex" "Ensuring Codex is installed"ensure_codexfiif [ "$install_pi" -eq 1 ]; then- step "Checking or installing Pi"+ start_install_step "Pi" "Checking or installing Pi"ensure_pifiif [ "$install_opencode" -eq 1 ]; then- step "Ensuring OpenCode is installed"+ start_install_step "OpenCode" "Ensuring OpenCode is installed"ensure_opencodefiif [ "$install_cline" -eq 1 ]; then- step "Ensuring Cline CLI is installed"+ start_install_step "Cline" "Ensuring Cline CLI is installed"ensure_clinefiif [ "$install_hermes" -eq 1 ]; then- step "Ensuring Hermes Agent is installed"+ start_install_step "Hermes" "Ensuring Hermes Agent is installed"ensure_hermesfiif [ "$install_dsh" -eq 1 ]; then- step "Ensuring DeepSeek Harness is installed"+ start_install_step "DeepSeek Harness" "Ensuring DeepSeek Harness is installed"ensure_dshfiif [ "$install_grok" -eq 1 ]; then- step "Ensuring Grok Build is installed"+ start_install_step "Grok" "Ensuring Grok Build is installed"ensure_grokfiif [ "$install_muse" -eq 1 ]; then- step "Ensuring Muse Code is installed"+ start_install_step "Muse" "Ensuring Muse Code is installed"ensure_musefiif [ "$install_aider" -eq 1 ]; then- step "Ensuring Aider is installed"+ start_install_step "Aider" "Ensuring Aider is installed"ensure_aiderfi@@ -1244,6 +1402,7 @@ ensure_uv() {if command -v uv >/dev/null 2>&1; thenversion=$(current_uv_version) || fail "uv is present, but 'uv --version' did not return a valid version."if stable_version_is_supported "$version" "$MIN_UV_VERSION"; then+ install_step_outcome=Reusedprintf 'uv %s already satisfies >=%s; leaving it unchanged.\n' "$version" "$MIN_UV_VERSION"return 0fi@@ -1319,6 +1478,7 @@ install_free_claude_code() {}configure_and_verify_free_claude_code() {+ start_install_step "PATH configuration"run uv tool update-shellif [ "$dry_run" -eq 1 ]; then@@ -1329,12 +1489,14 @@ configure_and_verify_free_claude_code() {fiadd_uv_tool_bin_directory+ start_install_step "FCC verification"for command_name in fcc-desktop fcc-server fcc-claude fcc-codex fcc-pi fcc-opencode fcc-cline fcc-hermes fcc-dsh fcc-grok fcc-muse fcc-aider fcc-doctor fcc-update; do[ -x "$tool_bin/$command_name" ] || fail "Free Claude Code installation did not create $tool_bin/$command_name."donerun "$tool_bin/fcc-server" --version+ fcc_verified=1}shell_quote() {@@ -1426,8 +1588,50 @@ PLISTln -s "$app_dir" "$desktop_link"}+show_installer_next_steps() {+ if [ "$desktop_ready" -eq 1 ]; then+ printf '\nFree Claude Code is installed and verified. Open Free Claude Code from Applications or the desktop to run it in the background.\n'+ printf 'For terminal use, start the proxy with: fcc-server\n'+ else+ printf '\nFree Claude Code is installed and verified. Start the proxy with: fcc-server\n'+ fi+ if [ "$install_claude" -eq 1 ]; then+ printf 'Run Claude Code with: fcc-claude\n'+ fi+ if [ "$install_codex" -eq 1 ]; then+ printf 'Run Codex with: fcc-codex\n'+ fi+ if [ "$pi_available" -eq 1 ]; then+ printf 'Run Pi with: fcc-pi\n'+ fi+ if [ "$install_opencode" -eq 1 ]; then+ printf 'Run OpenCode with: fcc-opencode\n'+ fi+ if [ "$install_cline" -eq 1 ]; then+ printf 'Run Cline with: fcc-cline\n'+ fi+ if [ "$install_hermes" -eq 1 ]; then+ printf 'Run Hermes Agent with: fcc-hermes\n'+ fi+ if [ "$install_dsh" -eq 1 ]; then+ printf 'Run DeepSeek Harness with: fcc-dsh\n'+ fi+ if [ "$install_grok" -eq 1 ]; then+ printf 'Run Grok Build with: fcc-grok\n'+ fi+ if [ "$install_muse" -eq 1 ]; then+ printf 'Run Muse Code with: fcc-muse\n'+ fi+ if [ "$install_aider" -eq 1 ]; then+ printf 'Run Aider with: fcc-aider\n'+ fi+}+parse_args "$@"validate_args+initialize_install_log+if [ "$dry_run" -eq 0 ]; then install_report_started=1; fi+start_install_step Preflight# Preserve the user's winning command before adding installer search paths.original_opencode_path=$(command -v opencode || true)add_known_bin_directories@@ -1453,6 +1657,34 @@ if installer_is_interactive; thenchoose_coding_agents /dev/tty /dev/ttyfi+pending_steps=$(+ [ "$install_claude" -eq 0 ] || printf 'Claude Code\n'+ [ "$install_codex" -eq 0 ] || printf 'Codex\n'+ [ "$install_pi" -eq 0 ] || printf 'Pi\n'+ [ "$install_opencode" -eq 0 ] || printf 'OpenCode\n'+ [ "$install_cline" -eq 0 ] || printf 'Cline\n'+ [ "$install_hermes" -eq 0 ] || printf 'Hermes\n'+ [ "$install_dsh" -eq 0 ] || printf 'DeepSeek Harness\n'+ [ "$install_grok" -eq 0 ] || printf 'Grok\n'+ [ "$install_muse" -eq 0 ] || printf 'Muse\n'+ [ "$install_aider" -eq 0 ] || printf 'Aider\n'+)+printf '\nInstallation plan:\n Install or update Free Claude Code.\n Verify or install: '+printf '%s\n' "$pending_steps" | while IFS= read -r agent; do+ printf '%s%s' "${separator:-}" "$agent"+ separator=', '+done+printf '\n'+[ "$voice_local" -eq 0 ] || printf ' Include local voice support.\n'+[ -z "$torch_backend" ] || printf ' PyTorch backend: %s\n' "$torch_backend"+[ "$enable_rtk" -eq 0 ] || printf ' Configure RTK for the selected agents.\n'+printf 'Press Ctrl+C to cancel. You can rerun the installer afterward.\n'+pending_steps=$(printf 'uv\n%s\nFCC package\nPATH configuration\nFCC verification\n' "$pending_steps"+ [ "$(uname -s)" != Darwin ] || printf 'Desktop integration\n'+ [ "$enable_rtk" -eq 0 ] || printf 'RTK configuration\n'+)+install_stage_count=$(printf '%s\n' "$pending_steps" | wc -l)+step "Checking installation prerequisites"require_command curlif [ "$install_claude" -eq 1 ] || [ "$install_opencode" -eq 1 ] || [ "$install_hermes" -eq 1 ] || [ "$install_grok" -eq 1 ] || [ "$install_muse" -eq 1 ]; then@@ -1469,72 +1701,40 @@ if [ "$enable_rtk" -eq 1 ] && ! command -v rtk >/dev/null 2>&1; thenfifi-step "Ensuring uv $MIN_UV_VERSION or newer is installed"+if [ "$dry_run" -eq 0 ]; then+ # Pi can bootstrap Node/npm before the dependent agents are installed.+ if [ "$install_pi" -eq 0 ] || find_installed_coding_agent pi >/dev/null; then+ if [ "$install_dsh" -eq 1 ]; then require_dsh_toolchain; fi+ if [ "$install_cline" -eq 1 ] && ! command -v cline >/dev/null 2>&1; then+ command -v npm >/dev/null 2>&1 || fail "Cline installation requires npm. Install Node.js from https://nodejs.org/en/download, then rerun the installer."+ fi+ fi+ if [ "$install_hermes" -eq 1 ] && ! command -v hermes >/dev/null 2>&1; then confirm_hermes_platform; fi+ if [ "$install_opencode" -eq 1 ]; then check_opencode_install; fi+ if [ "$enable_rtk" -eq 1 ] && ! command -v rtk >/dev/null 2>&1; then select_rtk_release; fi+fi++start_install_step uv "Ensuring uv $MIN_UV_VERSION or newer is installed"ensure_uvensure_selected_coding_agents-configure_rtk_for_selected_agents-step "Installing or updating Free Claude Code"+start_install_step "FCC package" "Installing or updating Free Claude Code"install_free_claude_code-step "Configuring PATH and verifying Free Claude Code"configure_and_verify_free_claude_codeif [ "$(uname -s)" = "Darwin" ]; then- step "Installing the Free Claude Code desktop launcher"+ start_install_step "Desktop integration" "Installing the Free Claude Code desktop launcher"install_macos_desktop_app+ desktop_ready=1fi+if [ "$enable_rtk" -eq 1 ]; then+ start_install_step "RTK configuration"+ configure_rtk_for_selected_agents+fi+complete_install_stepif [ "$dry_run" -eq 1 ]; thenprintf '\nDry run complete. No changes were made.\n'-else- if [ "$(uname -s)" = "Darwin" ]; then- printf '\nFree Claude Code is installed and verified. Open Free Claude Code from Applications or the desktop to run it in the background.\n'- printf 'For terminal use, start the proxy with: fcc-server\n'- else- printf '\nFree Claude Code is installed and verified. Start the proxy with: fcc-server\n'- fi- if [ "$install_claude" -eq 1 ]; then- printf 'Run Claude Code with: fcc-claude\n'- fi- if [ "$install_codex" -eq 1 ]; then- printf 'Run Codex with: fcc-codex\n'- fi- if [ "$pi_available" -eq 1 ]; then- printf 'Run Pi with: fcc-pi\n'- fi- if [ "$install_opencode" -eq 1 ]; then- printf 'Run OpenCode with: fcc-opencode\n'- fi- if [ "$install_cline" -eq 1 ]; then- printf 'Run Cline with: fcc-cline\n'- else- printf 'The fcc-cline wrapper is ready after you install Cline CLI.\n'- fi- if [ "$install_hermes" -eq 1 ]; then- printf 'Run Hermes Agent with: fcc-hermes\n'- else- printf 'The fcc-hermes wrapper is ready after you install Hermes Agent.\n'- fi- if [ "$install_dsh" -eq 1 ]; then- printf 'Run DeepSeek Harness with: fcc-dsh\n'- else- printf 'The fcc-dsh wrapper is ready after you install DeepSeek Harness >=%s.\n' "$MIN_DSH_VERSION"- fi- if [ "$install_grok" -eq 1 ]; then- printf 'Run Grok Build with: fcc-grok\n'- else- printf 'The fcc-grok wrapper is ready after you install Grok Build.\n'- fi- if [ "$install_muse" -eq 1 ]; then- printf 'Run Muse Code with: fcc-muse\n'- else- printf 'The fcc-muse wrapper is ready after you install Muse Code.\n'- fi- if [ "$install_aider" -eq 1 ]; then- printf 'Run Aider with: fcc-aider\n'- else- printf 'The fcc-aider wrapper is ready after you install Aider.\n'- fifidiff --git a/smoke/installers/test_installers.py b/smoke/installers/test_installers.pyindex 86f6a19c..9e1fe7dd 100644--- a/smoke/installers/test_installers.py+++ b/smoke/installers/test_installers.py@@ -346,6 +346,25 @@ printf '%s\n' "$FCC_PS_OUTPUT"timeout=30,)+ def function_scenario(self, body: str) -> Path:+ source = (_repo_root() / "scripts/install.sh").read_text(encoding="utf-8")+ scenario = self.root / "function-scenario.sh"+ scenario.write_text(+ source.split('\nparse_args "$@"\n', 1)[0] + "\n" + body + "\n",+ encoding="utf-8",+ )+ return scenario++ def run_functions(self, body: str) -> subprocess.CompletedProcess[str]:+ return subprocess.run(+ ["/bin/sh", str(self.function_scenario(body))],+ check=False,+ capture_output=True,+ text=True,+ env=self.env,+ timeout=20,+ )+def calls(self) -> list[str]:if not self.log.exists():return []@@ -1114,6 +1133,7 @@ def test_install_sh_rejects_exact_dsh_on_unsupported_node(posix_harness: PosixHarness,) -> None:posix_harness.add_client("dsh")+ posix_harness.add_client("pi")_write_executable(posix_harness.bin_dir / "node",_posix_command("node").replace("node 22.19.0", "node 23.9.0"),@@ -1123,7 +1143,11 @@ def test_install_sh_rejects_exact_dsh_on_unsupported_node(assert result.returncode != 0assert "requires Node.js ^22.19.0 or >=24.0.0" in result.stderr- _assert_uv_ready_without_fcc_install(posix_harness.calls())+ assert not any(+ call.startswith(("uv:", "download:", "npm:install"))+ for call in posix_harness.calls()+ )+ assert re.search(r"failed.*Preflight", result.stdout, re.IGNORECASE)@pytest.mark.parametrize("node_version", ["22.18.0", "23.9.0", "not-a-version"])@@ -1141,7 +1165,11 @@ def test_install_sh_rejects_incompatible_node_for_selected_dsh(assert result.returncode != 0assert "Free Claude Code is installed and verified." not in result.stdout- _assert_uv_ready_without_fcc_install(posix_harness.calls())+ assert not any(+ call.startswith(("uv:", "download:", "npm:install"))+ for call in posix_harness.calls()+ )+ assert re.search(r"failed.*Preflight", result.stdout, re.IGNORECASE)def test_install_sh_noninteractive_skips_dsh_without_node(@@ -1153,9 +1181,7 @@ def test_install_sh_noninteractive_skips_dsh_without_node(result = posix_harness.run()assert result.returncode == 0, result.stderr- assert (- "fcc-dsh wrapper is ready after you install DeepSeek Harness" in result.stdout- )+ assert "Run DeepSeek Harness with: fcc-dsh" not in result.stdoutassert not any("@deepseek-ai/dsh" in call for call in posix_harness.calls())@@ -1279,7 +1305,8 @@ def test_install_sh_rejects_conflicting_rtk_command(assert result.returncode != 0assert "not a compatible Rust Token Killer installation" in result.stderrassert not any("rtk-ai/rtk" in call for call in posix_harness.calls())- _assert_uv_ready_without_fcc_install(posix_harness.calls())+ assert "fcc-server:--version" in posix_harness.calls()+ assert re.search(r"failed.*RTK configuration", result.stdout, re.IGNORECASE)@pytest.mark.parametrize(@@ -1299,8 +1326,9 @@ def test_install_sh_stops_when_rtk_setup_fails(result = posix_harness.run("--rtk", fail_step=failure)assert result.returncode != 0- assert "Free Claude Code is installed and verified." not in result.stdout- _assert_uv_ready_without_fcc_install(posix_harness.calls())+ assert "Free Claude Code is installed and verified." in result.stdout+ assert "fcc-server:--version" in posix_harness.calls()+ assert re.search(r"failed.*RTK configuration", result.stdout, re.IGNORECASE)def test_install_sh_installs_then_updates_only_selected_agent(@@ -1393,6 +1421,9 @@ def test_install_sh_stops_if_macos_icon_export_fails(assert result.returncode != 0assert "Command failed with exit code 37" in result.stderr+ assert "Free Claude Code is installed and verified." in result.stdout+ assert "Start the proxy with: fcc-server" in result.stdout+ assert "Open Free Claude Code from Applications" not in result.stdoutassert not (posix_harness.root / "home" / "Desktop" / "Free Claude Code.app").exists()@@ -1730,6 +1761,12 @@ def test_install_sh_stops_without_success_on_each_failure("fcc-install": "uv:tool update-shell","fcc-missing": "fcc-server:--version",}.get(failure)+ if failure == "pi-verify":+ # OpenCode is probed during preflight. No later phase may run after Pi fails.+ pi_index = max(+ index for index, call in enumerate(calls) if call.startswith("pi:")+ )+ calls = calls[pi_index + 1 :]if forbidden is not None:assert not any(forbidden in call for call in calls)@@ -1890,74 +1927,26 @@ def _powershells() -> tuple[str, ...]:return tuple(dict.fromkeys(path for path in candidates if path is not None))-def test_install_ps1_waits_for_gui_icon_export() -> None:- installer = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- body = _braced_body(installer, "function Export-FccDesktopIcon")-- assert "Start-Process" in body- assert "-WindowStyle Hidden" in body- assert "-Wait" in body- assert "-PassThru" in body- assert "$process.ExitCode" in body--- "powershell",- _powershells() or (None,),- ids=lambda path: Path(path).name if path is not None else "unavailable",-)def test_install_ps1_gui_icon_export_completes_before_returning(- powershell: str | None,- tmp_path: Path,+ powershell_harness: PowerShellHarness,) -> None:- if powershell is None or os.name != "nt":- pytest.skip("PowerShell GUI process behavior runs on Windows hosts")-- installer = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- function_declarations = (- "function Format-Argument",- "function Format-Command",- "function Export-FccDesktopIcon",- )- functions = "\n".join(- f"{declaration} {{{_braced_body(installer, declaration)}}}"- for declaration in function_declarations- )- installed_desktop_command = Path(sys.executable).with_name("fcc-desktop.exe")- desktop_command = tmp_path / "icon-exporter.exe"- shutil.copy2(installed_desktop_command, desktop_command)- destination = tmp_path / "profile with spaces" / ".fcc" / "app-icon.ico"- env = os.environ | {- "FCC_TEST_DESKTOP_COMMAND": str(desktop_command),- "FCC_TEST_ICON_PATH": str(destination),- }- script = "\n".join(- (- '$ErrorActionPreference = "Stop"',- "$DryRun = $false",- functions,- (- "Export-FccDesktopIcon "- "-DesktopCommand $env:FCC_TEST_DESKTOP_COMMAND "- "-IconPath $env:FCC_TEST_ICON_PATH"- ),- )+ desktop_command = powershell_harness.root / "icon-exporter.exe"+ shutil.copy2(Path(sys.executable).with_name("fcc-desktop.exe"), desktop_command)+ destination = (+ powershell_harness.root / "profile with spaces" / ".fcc" / "app-icon.ico")-- completed = subprocess.run(- [powershell, "-NoProfile", "-Command", script],- check=False,- capture_output=True,- text=True,- env=env,+ powershell_harness.env.update(+ FCC_TEST_DESKTOP_COMMAND=str(desktop_command),+ FCC_TEST_ICON_PATH=str(destination),+ )+ completed = powershell_harness.run_functions(+ "Export-FccDesktopIcon -DesktopCommand $env:FCC_TEST_DESKTOP_COMMAND "+ "-IconPath $env:FCC_TEST_ICON_PATH")-assert completed.returncode == 0, completed.stderrassert (destination.read_bytes()- == (- _repo_root() / "src" / "free_claude_code" / "assets" / "app-icon.ico"- ).read_bytes()+ == (_repo_root() / "src/free_claude_code/assets/app-icon.ico").read_bytes())@@ -2440,7 +2429,7 @@ Add-Content -LiteralPath $env:CALL_LOG -Value "uv-install"$ErrorActionPreference = "Stop"function Invoke-RestMethod {[CmdletBinding()]- param([string] $Uri, [string] $OutFile)+ param([string] $Uri, [string] $OutFile, [int] $TimeoutSec)Add-Content -LiteralPath $env:CALL_LOG -Value "download:$Uri"if (@@ -3536,9 +3525,7 @@ def test_install_ps1_noninteractive_skips_dsh_without_node(result = powershell_harness.run()assert result.returncode == 0, result.stderr- assert (- "fcc-dsh wrapper is ready after you install DeepSeek Harness" in result.stdout- )+ assert "Run DeepSeek Harness with: fcc-dsh" not in result.stdoutassert not any("@deepseek-ai/dsh" in call for call in powershell_harness.calls())@@ -3706,7 +3693,7 @@ $RtkWindowsAssetName = "{asset_name}"$RtkWindowsAssetSha256 = "{checksum}"function Invoke-RestMethod {{[CmdletBinding()]- param([string] $Uri, [string] $OutFile)+ param([string] $Uri, [string] $OutFile, [int] $TimeoutSec)Copy-Item -LiteralPath $env:RTK_TEST_ARCHIVE -Destination $OutFile}}Install-Rtk@@ -3734,6 +3721,9 @@ def test_install_ps1_stops_if_windows_icon_export_fails(assert result.returncode != 0assert "Command failed with exit code 56" in result.stderr+ assert "Free Claude Code is installed and verified." in result.stdout+ assert "start the proxy with: fcc-server" in result.stdout+ assert "Open the Free Claude Code desktop shortcut" not in result.stdouthome = Path(powershell_harness.env["USERPROFILE"])assert not (home / "Desktop" / "Free Claude Code.lnk").exists()@@ -3755,12 +3745,14 @@ def test_install_ps1_preserves_unowned_desktop_shortcut(original_shortcut = desktop_shortcut.read_bytes()result = powershell_harness.run_functions(- "Add-KnownBinDirectories\nEnsure-Uv\nInstall-FreeClaudeCode\nConfigure-AndConfirmFreeClaudeCode"+ "Add-KnownBinDirectories\nEnsure-Uv\nInstall-FreeClaudeCode\nConfigure-AndConfirmFreeClaudeCode\nShow-InstallerNextSteps")assert result.returncode == 0, result.stderrassert "not managed by Free Claude Code" in result.stdoutassert desktop_shortcut.read_bytes() == original_shortcut+ assert "Open the Free Claude Code desktop shortcut" not in result.stdout+ assert "start the proxy with: fcc-server" in result.stdout@pytest.mark.parametrize("uv_version", ("0.12.13", "0.12.13+build.1", "0.12.14"))@@ -4270,42 +4262,19 @@ def test_install_ps1_uses_x64_python_for_windows_arm_compatibility() -> None:assert '$PythonRequest = "cpython-3.14.7-windows-x86_64-none"' in powershell[email protected]("powershell", _powershells())def test_install_ps1_rejects_invalid_download_before_execution(- powershell: str,+ powershell_harness: PowerShellHarness,) -> None:- text = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- body = _braced_body(text, "function Invoke-DownloadedPowerShellInstaller")- script = f"""Set-StrictMode -Version Latest-$ErrorActionPreference = "Stop"-$DryRun = $false-function Format-Argument {{ param([string] $Value) return $Value }}-function Invoke-RestMethod {{- [CmdletBinding()]- param([string] $Uri, [string] $OutFile)- [IO.File]::WriteAllText($OutFile, "<style>div#box {{")-}}-function Get-PowerShellExecutable {{ throw "invalid installer reached execution" }}-function Invoke-DownloadedPowerShellInstaller {{{body}}}-Invoke-DownloadedPowerShellInstaller `- -Url "https://example.test/install.ps1" `- -Name "Example"-"""-- result = subprocess.run(- [powershell, "-NoProfile", "-Command", script],- check=False,- capture_output=True,- text=True,+ (powershell_harness.fixtures / "claude-installer.ps1").write_text(+ "<style>div#box {", encoding="utf-8")-- assert result.returncode != 0- assert (- "Example installer from 'https://example.test/install.ps1' is not valid PowerShell"- in result.stderr+ result = powershell_harness.run_functions(+ "Invoke-DownloadedPowerShellInstaller -Url $ClaudeInstallUrl -Name 'Claude Code'")+ assert result.returncode != 0+ assert "is not valid PowerShell" in result.stderrassert "network proxy or filter" in result.stderr- assert "invalid installer reached execution" not in result.stderr+ assert "claude-install" not in powershell_harness.calls()def test_install_ps1_installs_then_updates_only_selected_agent(@@ -4433,11 +4402,10 @@ Write-Output "selection:$($script:InstallClaudeCode),$($script:InstallCodex),$($assert message in result.stdout[email protected]("powershell", _powershells())-def test_install_ps1_runs_only_selected_coding_agents(powershell: str) -> None:- text = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- body = _braced_body(text, "function Ensure-SelectedCodingAgents")- script = f"""Set-StrictMode -Version Latest+def test_install_ps1_runs_only_selected_coding_agents(+ powershell_harness: PowerShellHarness,+) -> None:+ script = """Set-StrictMode -Version Latest$ErrorActionPreference = "Stop"$script:InstallClaudeCode = $false$script:InstallCodex = $true@@ -4452,28 +4420,21 @@ $script:InstallAider = $false$script:PiAvailable = $false$script:MuseAvailable = $false$script:Calls = @()-function Write-Step {{ param([string] $Message) }}-function Ensure-ClaudeCode {{ $script:Calls += "claude" }}-function Ensure-Codex {{ $script:Calls += "codex" }}-function Ensure-Pi {{ $script:Calls += "pi"; $script:PiAvailable = $true }}-function Ensure-OpenCode {{ $script:Calls += "opencode" }}-function Ensure-Cline {{ $script:Calls += "cline" }}-function Ensure-Hermes {{ $script:Calls += "hermes" }}-function Ensure-Dsh {{ $script:Calls += "dsh" }}-function Ensure-Grok {{ $script:Calls += "grok" }}-function Ensure-Muse {{ $script:Calls += "muse"; $script:MuseAvailable = $true }}-function Ensure-Aider {{ $script:Calls += "aider" }}-function Ensure-SelectedCodingAgents {{{body}}}+function Write-Step { param([string] $Message) }+function Ensure-ClaudeCode { $script:Calls += "claude" }+function Ensure-Codex { $script:Calls += "codex" }+function Ensure-Pi { $script:Calls += "pi"; $script:PiAvailable = $true }+function Ensure-OpenCode { $script:Calls += "opencode" }+function Ensure-Cline { $script:Calls += "cline" }+function Ensure-Hermes { $script:Calls += "hermes" }+function Ensure-Dsh { $script:Calls += "dsh" }+function Ensure-Grok { $script:Calls += "grok" }+function Ensure-Muse { $script:Calls += "muse"; $script:MuseAvailable = $true }+function Ensure-Aider { $script:Calls += "aider" }Ensure-SelectedCodingAgentsWrite-Output "calls:$($script:Calls -join ',')""""-- result = subprocess.run(- [powershell, "-NoProfile", "-Command", script],- check=False,- capture_output=True,- text=True,- )+ result = powershell_harness.run_functions(script)assert result.returncode == 0, result.stderrassert "calls:codex" in result.stdout@@ -4523,11 +4484,10 @@ Write-Output "calls:$($script:Calls -join ',')"assert "calls:ensure,init --global --codex" in result.stdout[email protected]("powershell", _powershells())-def test_install_ps1_rejects_uninstalled_only_selection(powershell: str) -> None:- text = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- body = _braced_body(text, "function Ensure-SelectedCodingAgents")- script = f"""Set-StrictMode -Version Latest+def test_install_ps1_rejects_uninstalled_only_selection(+ powershell_harness: PowerShellHarness,+) -> None:+ script = """Set-StrictMode -Version Latest$ErrorActionPreference = "Stop"$script:InstallClaudeCode = $false$script:InstallCodex = $false@@ -4541,27 +4501,20 @@ $script:InstallMuse = $false$script:InstallAider = $false$script:PiAvailable = $false$script:MuseAvailable = $false-function Write-Step {{ param([string] $Message) }}-function Ensure-ClaudeCode {{ }}-function Ensure-Codex {{ }}-function Ensure-Pi {{ }}-function Ensure-OpenCode {{ }}-function Ensure-Cline {{ }}-function Ensure-Hermes {{ }}-function Ensure-Dsh {{ }}-function Ensure-Grok {{ }}-function Ensure-Muse {{ }}-function Ensure-Aider {{ }}-function Ensure-SelectedCodingAgents {{{body}}}+function Write-Step { param([string] $Message) }+function Ensure-ClaudeCode { }+function Ensure-Codex { }+function Ensure-Pi { }+function Ensure-OpenCode { }+function Ensure-Cline { }+function Ensure-Hermes { }+function Ensure-Dsh { }+function Ensure-Grok { }+function Ensure-Muse { }+function Ensure-Aider { }Ensure-SelectedCodingAgents"""-- result = subprocess.run(- [powershell, "-NoProfile", "-Command", script],- check=False,- capture_output=True,- text=True,- )+ result = powershell_harness.run_functions(script)assert result.returncode != 0assert "No selected coding agent was installed." in result.stderr@@ -5100,37 +5053,24 @@ def test_install_ps1_opencode_rejects_mismatched_archive_before_replacement(assert binary.read_bytes() == original[email protected]("powershell", _powershells())@pytest.mark.parametrize("exit_code", [0, 31])[email protected](os.name != "nt", reason="Windows native command probe")def test_install_ps1_opencode_version_probe_runs_native_command(- tmp_path: Path, powershell: str, exit_code: int+ powershell_harness: PowerShellHarness, exit_code: int) -> None:- binary = tmp_path / "path with spaces" / "opencode.cmd"+ binary = powershell_harness.root / "path with spaces" / "opencode.cmd"_write_executable(- binary,- f"@echo off\necho opencode v2.0.10\nexit /b {exit_code}\n",+ binary, f"@echo off\necho opencode v2.0.10\nexit /b {exit_code}\n")- text = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")- body = _braced_body(text, "function Read-OpenCodeVersionOutput")- script = f"""$ErrorActionPreference = "Stop"-function Read-OpenCodeVersionOutput {{{body}}}-Read-OpenCodeVersionOutput $env:TEST_OPENCODE-"""- result = subprocess.run(- [powershell, "-NoProfile", "-Command", script],- env=os.environ | {"TEST_OPENCODE": str(binary)},- capture_output=True,- text=True,- timeout=20,- check=False,+ powershell_harness.env["TEST_OPENCODE"] = str(binary)+ result = powershell_harness.run_functions(+ "Read-OpenCodeVersionOutput $env:TEST_OPENCODE")if exit_code:assert result.returncode != 0assert f"exit code {exit_code}" in result.stderrelse:assert result.returncode == 0, result.stderr- assert result.stdout.strip() == "opencode v2.0.10"+ assert "opencode v2.0.10" in result.stdout.splitlines()@pytest.mark.parametrize("powershell", _powershells())@@ -5167,3 +5107,413 @@ if ($resolved -ne {str(fallback)!r}) {{)assert result.returncode == 0, result.stderr+++def _assert_installer_recovers_after_verification_failure(+ harness: PosixHarness | PowerShellHarness,+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ for command in CODING_AGENTS:+ harness.add_client(command)+ harness.add_uv("0.12.13")+ harness.add_rtk()+ home = Path(harness.env["USERPROFILE" if windows else "HOME"])+ options = (+ ("-Rtk", "-VoiceLocal", "-TorchBackend", "cu130")+ if windows+ else ("--rtk", "--voice-local", "--torch-backend", "cu130")+ )++ failed = harness.run(*options, fail_step="fcc-verify")++ assert failed.returncode != 0+ assert not any(call.startswith("rtk:init") for call in harness.calls())+ assert not (home / "Desktop" / "Free Claude Code.lnk").exists()+ assert "Free Claude Code is installed and verified." not in failed.stdout+ assert re.search(r"completed.*FCC package", failed.stdout, re.IGNORECASE)+ assert re.search(r"failed.*FCC verification", failed.stdout, re.IGNORECASE)+ assert re.search(r"not attempted.*RTK", failed.stdout, re.IGNORECASE)+ retry = next(+ line for line in failed.stdout.splitlines() if line.startswith("Retry:")+ )+ assert all(option in retry for option in options)+ logs = list((home / ".fcc" / "logs").glob("install-*.log"))+ assert len(logs) == 1+ first_log = logs[0].read_text(encoding="utf-8-sig")+ assert "fcc-server" in first_log+ assert re.search(r"failed.*FCC verification", first_log, re.IGNORECASE)+ calls_before_retry = len(harness.calls())++ recovered = harness.run(*options)++ assert recovered.returncode == 0, recovered.stderr+ assert "Free Claude Code is installed and verified." in recovered.stdout+ retry_calls = harness.calls()[calls_before_retry:]+ assert "claude-install" not in retry_calls+ assert "codex-install:1" not in retry_calls+ verification = retry_calls.index("fcc-server:--version")+ assert all(+ index > verification+ for index, call in enumerate(retry_calls)+ if call.startswith("rtk:init")+ )+ assert len(list((home / ".fcc" / "logs").glob("install-*.log"))) == 2+ assert logs[0].read_text(encoding="utf-8-sig") == first_log+++def test_install_sh_reports_and_recovers_after_verification_failure(+ posix_harness: PosixHarness,+) -> None:+ _assert_installer_recovers_after_verification_failure(posix_harness)+++def test_install_ps1_reports_and_recovers_after_verification_failure(+ powershell_harness: PowerShellHarness,+) -> None:+ _assert_installer_recovers_after_verification_failure(powershell_harness)+++def test_install_ps1_explains_child_policy_failure_without_doctor(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_installed_clients()+ powershell_harness.add_uv("0.12.13")+ fixture = powershell_harness.fixtures / "fcc-command.cmd"+ fixture.write_text(+ "@echo off\n"+ 'echo %~n0:%*>>"%CALL_LOG%"\n'+ 'if "%~n0"=="fcc-server" (\n'+ " echo error: uv trampoline failed to spawn Python child process 1>&2\n"+ " echo Caused by: uncategorized error ^(os error 4551^) 1>&2\n"+ " exit /b 1\n"+ ")\n",+ encoding="utf-8",+ )++ result = powershell_harness.run()++ assert result.returncode != 0+ output = result.stdout + result.stderr+ assert "Windows" in output and "policy" in output.lower()+ assert "Get-WinEvent" in output+ assert "CodeIntegrity/Operational" in output+ assert "3077" in output+ assert not any(+ call.startswith("fcc-doctor:") for call in powershell_harness.calls()+ )+ home = Path(powershell_harness.env["USERPROFILE"])+ logs = list((home / ".fcc" / "logs").glob("install-*.log"))+ assert len(logs) == 1+ assert "os error 4551" in logs[0].read_text(encoding="utf-8-sig")+++def test_install_ps1_log_failure_preserves_installation_failure(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_installed_clients()+ powershell_harness.add_uv("0.12.13")+ home = Path(powershell_harness.env["USERPROFILE"])+ (home / ".fcc").mkdir()+ (home / ".fcc" / "logs").write_text("not a directory", encoding="utf-8")++ result = powershell_harness.run(fail_step="fcc-install")++ assert result.returncode != 0+ output = result.stdout + result.stderr+ assert "53" in output+ assert re.search(r"failed.*FCC package", output, re.IGNORECASE)+ assert (home / ".fcc" / "logs").read_text(encoding="utf-8") == "not a directory"++[email protected]("code", [4551, 1260, 5])+ "invoker", ["Invoke-NativeCommand", "Invoke-Utf8NativeCapture"]+)+def test_install_ps1_identifies_native_policy_launch_errors(+ powershell_harness: PowerShellHarness, code: int, invoker: str+) -> None:+ result = powershell_harness.run_functions(+ f"""function blocked.exe {{+ throw [ComponentModel.Win32Exception]::new({code})+}}+{invoker} -FilePath 'blocked.exe'+"""+ )+ assert result.returncode != 0+ assert ("Get-WinEvent" in result.stdout + result.stderr) == (code != 5)+ assert "blocked.exe" in result.stdout + result.stderr+++def test_install_ps1_checks_selected_prerequisites_before_installing_uv(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_installed_clients()+ (powershell_harness.bin_dir / "node.cmd").unlink()++ result = powershell_harness.run()++ assert result.returncode != 0+ assert "requires Node.js" in result.stdout + result.stderr+ assert not any(call.startswith("download:") for call in powershell_harness.calls())+ assert re.search(r"failed.*Preflight", result.stdout, re.IGNORECASE)+++def test_install_sh_log_failure_preserves_installation_failure(+ posix_harness: PosixHarness,+) -> None:+ for command in CODING_AGENTS:+ posix_harness.add_client(command)+ posix_harness.add_uv("0.12.13")+ home = Path(posix_harness.env["HOME"])+ (home / ".fcc").mkdir()+ (home / ".fcc/logs").write_text("not a directory", encoding="utf-8")+ result = posix_harness.run(fail_step="fcc-install")+ assert result.returncode != 0+ assert "33" in result.stdout + result.stderr+ assert re.search(r"failed.*FCC package", result.stdout, re.IGNORECASE)+ assert (home / ".fcc/logs").read_text(encoding="utf-8") == "not a directory"+++def test_install_ps1_retry_command_preserves_literal_options_and_path(+ powershell_harness: PowerShellHarness,+) -> None:+ script = powershell_harness.root / "install ' & café.ps1"+ output = powershell_harness.root / "retry-options.json"+ script.write_text(+ "param([switch] $VoiceLocal, [string] $TorchBackend, [switch] $Rtk)\n"+ "[IO.File]::WriteAllText($env:TEST_RETRY_OUTPUT, "+ "(ConvertTo-Json @($VoiceLocal.IsPresent, $TorchBackend, $Rtk.IsPresent)), [Text.Encoding]::UTF8)\n",+ encoding="utf-8-sig",+ )+ backend = "cu'130 $literal; &(literal)"+ powershell_harness.env.update(+ TEST_RETRY_PATH=str(script), TEST_RETRY_OUTPUT=str(output)+ )+ result = powershell_harness.run_functions(+ "$script:InstallerPath = $env:TEST_RETRY_PATH\n"+ "& ([scriptblock]::Create((Get-InstallerRetryCommand)))",+ "-VoiceLocal",+ "-TorchBackend",+ backend,+ "-Rtk",+ )+ assert result.returncode == 0, result.stderr+ assert json.loads(output.read_text(encoding="utf-8-sig")) == [True, backend, True]+++def test_install_sh_retry_command_preserves_literal_options_and_path(+ posix_harness: PosixHarness,+) -> None:+ script = posix_harness.root / "install ' & café.sh"+ output = posix_harness.root / "retry-options"+ script.write_text('printf "%s\\n" "$@" >"$TEST_RETRY_OUTPUT"\n', encoding="utf-8")+ backend = "cu'130 $literal; &(literal)"+ posix_harness.env.update(+ TEST_RETRY_PATH=str(script),+ TEST_RETRY_OUTPUT=str(output),+ TEST_BACKEND=backend,+ )+ result = posix_harness.run_functions(+ "installer_path=$TEST_RETRY_PATH\nvoice_local=1\nenable_rtk=1\ntorch_backend=$TEST_BACKEND\n"+ 'retry=$(print_installer_retry)\neval "${retry#Retry: }"'+ )+ assert result.returncode == 0, result.stderr+ assert output.read_text(encoding="utf-8").splitlines() == [+ "--voice-local",+ "--torch-backend",+ backend,+ "--rtk",+ ]++[email protected]("option", ["-Help", "-DryRun"])+def test_install_ps1_preview_creates_no_log_or_probe(+ powershell_harness: PowerShellHarness,+ option: str,+) -> None:+ result = powershell_harness.run(option)+ assert result.returncode == 0, result.stderr+ assert powershell_harness.calls() == []+ assert not (Path(powershell_harness.env["USERPROFILE"]) / ".fcc/logs").exists()++[email protected]("option", ["--help", "--dry-run"])+def test_install_sh_preview_creates_no_log_or_probe(+ posix_harness: PosixHarness,+ option: str,+) -> None:+ result = posix_harness.run(option)+ assert result.returncode == 0, result.stderr+ assert posix_harness.calls() == []+ assert not (Path(posix_harness.env["HOME"]) / ".fcc/logs").exists()+++def _assert_pi_supplies_selected_agent_toolchain(+ harness: PosixHarness | PowerShellHarness, dependent: str+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ suffix = ".cmd" if windows else ""+ harness.add_uv("0.12.13")+ (harness.bin_dir / f"opencode{suffix}").unlink()+ for command in ("node", "npm"):+ source = harness.bin_dir / f"{command}{suffix}"+ (harness.fixtures / f"{command}-command{suffix}").write_bytes(+ source.read_bytes()+ )+ source.unlink()+ installer = harness.fixtures / (+ "pi-installer.ps1" if windows else "pi-installer.sh"+ )+ bootstrap = (+ r"""$nodeBin = Join-Path $env:LOCALAPPDATA 'pi-node\current'+New-Item -ItemType Directory -Force -Path $nodeBin | Out-Null+foreach ($command in @('node', 'npm')) {+ Copy-Item (Join-Path $env:FAKE_FIXTURES "$command-command.cmd") (Join-Path $nodeBin "$command.cmd")+}+"""+ if windows+ else """node_bin="$HOME/.local/share/pi-node/current/bin"+mkdir -p "$node_bin"+for command in node npm; do+ cp "$FAKE_FIXTURES/$command-command" "$node_bin/$command"+ chmod +x "$node_bin/$command"+done+"""+ )+ installer.write_text(+ bootstrap + installer.read_text(encoding="utf-8"), encoding="utf-8"+ )+ answers = [+ "y" if command in ("pi", dependent) else "n" for command in CODING_AGENTS+ ]+ answers.append("n")+ result = (+ harness.run_interactive(answers)+ if windows+ else harness.run_interactive("\n".join(answers) + "\n")+ )+ assert result.returncode == 0, result.stdout + result.stderr+ calls = harness.calls()+ assert "pi-install" in calls+ assert any(call.startswith("npm:install -g ") for call in calls)+ assert f"{dependent}:--version" in calls++[email protected]("dependent", ["cline", "dsh"])+def test_install_ps1_pi_supplies_selected_agent_toolchain(+ powershell_harness: PowerShellHarness, dependent: str+) -> None:+ _assert_pi_supplies_selected_agent_toolchain(powershell_harness, dependent)++[email protected]("dependent", ["cline", "dsh"])+def test_install_sh_pi_supplies_selected_agent_toolchain(+ posix_harness: PosixHarness, dependent: str+) -> None:+ _assert_pi_supplies_selected_agent_toolchain(posix_harness, dependent)+++def test_install_sh_piped_failure_retries_downloaded_installer(+ posix_harness: PosixHarness,+) -> None:+ for command in CODING_AGENTS:+ posix_harness.add_client(command)+ posix_harness.add_uv("0.12.13")+ result = posix_harness.run_interactive("n\n", fail_step="fcc-install")+ assert result.returncode != 0+ retry = next(+ line for line in result.stdout.splitlines() if line.startswith("Retry:")+ )+ assert (+ "https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.sh"+ in retry+ )+ assert "| sh -s --" in retry+++def _assert_installer_shows_selected_plan_and_next_steps(+ harness: PosixHarness | PowerShellHarness,+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ harness.add_client("claude")+ harness.add_uv("0.12.13")+ (harness.bin_dir / ("opencode.cmd" if windows else "opencode")).unlink()+ answers = ["n"] * len(CODING_AGENTS)+ result = (+ harness.run_interactive(answers)+ if windows+ else harness.run_interactive("\n".join(answers) + "\n")+ )+ assert result.returncode == 0, result.stdout + result.stderr+ assert "Installation plan:" in result.stdout+ plan = result.stdout.split("Installation plan:", 1)[1].split("Press Ctrl+C", 1)[0]+ assert "Claude Code" in plan+ assert "Codex" not in plan+ assert "RTK" not in plan+ stages = re.findall(r"\[(\d+)/(\d+)\]", result.stdout)+ assert stages+ assert [int(number) for number, _ in stages] == list(range(1, len(stages) + 1))+ assert {int(total) for _, total in stages} == {len(stages)}+ assert re.findall(r"Run .* with: (fcc-\S+)", result.stdout) == ["fcc-claude"]+ assert "wrapper is ready after" not in result.stdout+ assert "Skipped:" not in result.stdout+++def test_install_ps1_shows_selected_plan_and_next_steps(+ powershell_harness: PowerShellHarness,+) -> None:+ _assert_installer_shows_selected_plan_and_next_steps(powershell_harness)+++def test_install_sh_shows_selected_plan_and_next_steps(+ posix_harness: PosixHarness,+) -> None:+ _assert_installer_shows_selected_plan_and_next_steps(posix_harness)+++def _assert_installer_keeps_launch_instructions_after_rtk_failure(+ harness: PosixHarness | PowerShellHarness,+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ for command in CODING_AGENTS:+ harness.add_client(command)+ harness.add_uv("0.12.13")+ harness.add_rtk()+ result = harness.run("-Rtk" if windows else "--rtk", fail_step="rtk-init-claude")+ assert result.returncode != 0+ assert "Free Claude Code is installed and verified." in result.stdout+ assert "Run Claude Code with: fcc-claude" in result.stdout+ assert "Failed: RTK configuration" in result.stdout+ assert "Retry:" in result.stdout+++def test_install_ps1_keeps_launch_instructions_after_rtk_failure(+ powershell_harness: PowerShellHarness,+) -> None:+ _assert_installer_keeps_launch_instructions_after_rtk_failure(powershell_harness)+++def test_install_sh_keeps_launch_instructions_after_rtk_failure(+ posix_harness: PosixHarness,+) -> None:+ _assert_installer_keeps_launch_instructions_after_rtk_failure(posix_harness)+++def test_install_sh_keeps_package_output_attached_to_terminal(+ posix_harness: PosixHarness,+) -> None:+ for command in CODING_AGENTS:+ posix_harness.add_client(command)+ posix_harness.add_uv("0.12.13")+ uv = posix_harness.bin_dir / "uv"+ source = uv.read_text(encoding="utf-8")+ uv.write_text(+ source.replace(+ "#!/bin/sh\n",+ '#!/bin/sh\nif [ "$1" = tool ] && [ "$2" = install ]; then [ -t 1 ] || exit 99; fi\n',+ 1,+ ),+ encoding="utf-8",+ )+ result = posix_harness.run_interactive("n\n")+ assert result.returncode == 0, result.stdout + result.stderr