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
Skip installer prompts for installed coding agents and RTK (#1842)
Ali Khokhare40be9fc6840
diff --git a/pyproject.toml b/pyproject.tomlindex 89205d5d..19faaab3 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "free-claude-code"-version = "6.2.46"+version = "6.2.47"description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"readme = "README.md"requires-python = ">=3.14.0"diff --git a/scripts/install.ps1 b/scripts/install.ps1index bd17117c..b65b2257 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -113,29 +113,92 @@ function Read-YesNo {}}+function Find-InstalledCodingAgent {+ param([string] $CommandName)++ $originalPath = $env:Path+ try {+ if ($CommandName -eq "opencode" -and $script:OriginalOpenCode) {+ return $script:OriginalOpenCode+ }+ if ($CommandName -in @("pi", "cline", "dsh")) {+ try {+ Add-NpmBinDirectories+ }+ catch {+ # An optional lookup must not prevent choosing other harnesses.+ }+ }+ $command = Get-ApplicationCommand $CommandName+ if (-not $command) {+ if ($CommandName -eq "aider") {+ if ($env:UV_TOOL_BIN_DIR) {+ Add-PathEntry $env:UV_TOOL_BIN_DIR+ }+ elseif ($env:XDG_BIN_HOME) {+ Add-PathEntry $env:XDG_BIN_HOME+ }+ elseif ($env:XDG_DATA_HOME) {+ Add-PathEntry (Join-Path $env:XDG_DATA_HOME "..\bin")+ }+ elseif ($env:USERPROFILE) {+ Add-PathEntry (Join-Path $env:USERPROFILE ".local\bin")+ }+ $command = Get-ApplicationCommand $CommandName+ }+ elseif ($CommandName -eq "muse") {+ $userPath = [Environment]::GetEnvironmentVariable("Path", "User")+ if (-not [string]::IsNullOrWhiteSpace($userPath)) {+ $env:Path = "$originalPath$([IO.Path]::PathSeparator)$userPath"+ $command = Get-ApplicationCommand $CommandName+ }+ }+ }+ if ($CommandName -eq "pi" -and $command -and (-not $DryRun)) {+ if (-not (Test-PiApplication $command)) {+ return $null+ }+ }+ return $command+ }+ finally {+ # Environment variables are process-wide, even inside a function.+ $env:Path = $originalPath+ }+}++function Read-CodingAgentSelection {+ param(+ [string] $CommandName,+ [string] $DisplayName,+ [string] $FccCommand,+ [bool] $DefaultYes = $true+ )++ if (Find-InstalledCodingAgent $CommandName) {+ Write-Host "$DisplayName already installed; will verify."+ return $true+ }+ return Read-YesNo -Prompt "Install $DisplayName for ${FccCommand}?" -DefaultYes $DefaultYes+}+function Select-CodingAgents {while ($true) {- $script:InstallClaudeCode = Read-YesNo "Install or verify Claude Code for fcc-claude?"- $script:InstallCodex = Read-YesNo "Install or verify Codex for fcc-codex?"- $script:InstallPi = Read-YesNo "Install or verify Pi for fcc-pi?"- $script:InstallOpenCode = Read-YesNo "Install or verify OpenCode for fcc-opencode?"- $script:InstallCline = Read-YesNo `- -Prompt "Install or verify Cline CLI for fcc-cline?" `+ $script:InstallClaudeCode = Read-CodingAgentSelection claude "Claude Code" fcc-claude+ $script:InstallCodex = Read-CodingAgentSelection codex Codex fcc-codex+ $script:InstallPi = Read-CodingAgentSelection pi Pi fcc-pi+ $script:InstallOpenCode = Read-CodingAgentSelection opencode OpenCode fcc-opencode+ $script:InstallCline = Read-CodingAgentSelection cline "Cline CLI" fcc-cline `-DefaultYes $script:InstallCline- $script:InstallHermes = Read-YesNo `- -Prompt "Install or verify Hermes Agent for fcc-hermes?" `+ $script:InstallHermes = Read-CodingAgentSelection hermes "Hermes Agent" fcc-hermes `-DefaultYes $script:InstallHermes- $script:InstallDsh = Read-YesNo `- -Prompt "Install or verify DeepSeek Harness for fcc-dsh?" `+ $script:InstallDsh = Read-CodingAgentSelection dsh "DeepSeek Harness" fcc-dsh `-DefaultYes $script:InstallDsh- $script:InstallGrok = Read-YesNo `- -Prompt "Install or verify Grok Build for fcc-grok?" `+ $script:InstallGrok = Read-CodingAgentSelection grok "Grok Build" fcc-grok `-DefaultYes $script:InstallGrok- $script:InstallMuse = Read-YesNo `- -Prompt "Install or verify Muse Code for fcc-muse?" `+ $script:InstallMuse = Read-CodingAgentSelection muse "Muse Code" fcc-muse `-DefaultYes $script:InstallMuse- $script:InstallAider = Read-YesNo `- -Prompt "Install or verify Aider for fcc-aider?" `+ $script:InstallAider = Read-CodingAgentSelection aider Aider fcc-aider `-DefaultYes $script:InstallAiderif ($script:InstallClaudeCode -or $script:InstallCodex -or $script:InstallPi -or $script:InstallOpenCode -or $script:InstallCline -or $script:InstallHermes -or $script:InstallDsh -or $script:InstallGrok -or $script:InstallMuse -or $script:InstallAider) {@@ -146,9 +209,15 @@ function Select-CodingAgents {}if (-not $script:EnableRtk) {- $script:EnableRtk = Read-YesNo `- -Prompt "Enable RTK token optimization globally for the selected coding agents?" `- -DefaultYes $false+ if (Get-ApplicationCommand "rtk") {+ Write-Host "RTK already installed; will verify."+ $script:EnableRtk = $true+ }+ else {+ $script:EnableRtk = Read-YesNo `+ -Prompt "Enable RTK token optimization globally for the selected coding agents?" `+ -DefaultYes $false+ }}}@@ -1032,7 +1101,15 @@ function Ensure-Muse {$script:MuseAvailable = $falseInvoke-DownloadedPowerShellInstaller -Url $MuseInstallUrl -Name "Muse Code"Add-KnownBinDirectories- Confirm-Application -CommandName "muse" -DisplayName "Muse Code"+ $commandName = "muse"+ if (-not $DryRun) {+ $command = Find-InstalledCodingAgent "muse"+ if (-not $command) {+ throw "Muse Code was installed, but 'muse' is not available on PATH."+ }+ $commandName = $command.Source+ }+ Confirm-Application -CommandName $commandName -DisplayName "Muse Code"$script:MuseAvailable = $true}diff --git a/scripts/install.sh b/scripts/install.shindex 7f56cf77..58be2568 100644--- a/scripts/install.sh+++ b/scripts/install.sh@@ -97,6 +97,46 @@ prompt_yes_no() {done}+find_installed_coding_agent() (+ # Lookup may prepare search paths, but must not change the installer's state.+ case "$1" in+ pi|cline|dsh)+ add_npm_bin_directories+ ;;+ aider)+ if ! command -v aider >/dev/null 2>&1; then+ if [ -n "${UV_TOOL_BIN_DIR:-}" ]; then+ add_path_entry "$UV_TOOL_BIN_DIR"+ elif [ -n "${XDG_BIN_HOME:-}" ]; then+ add_path_entry "$XDG_BIN_HOME"+ elif [ -n "${XDG_DATA_HOME:-}" ]; then+ add_path_entry "$XDG_DATA_HOME/../bin"+ elif [ -n "${HOME:-}" ]; then+ add_path_entry "$HOME/.local/bin"+ fi+ fi+ ;;+ esac++ if [ "$1" = opencode ] && [ -n "$original_opencode_path" ]; then+ printf '%s\n' "$original_opencode_path"+ return 0+ fi+ command_path=$(command -v "$1" 2>/dev/null) || return 1+ if [ "$1" = pi ] && [ "$dry_run" -eq 0 ]; then+ pi_command_is_compatible || return 1+ fi+ printf '%s\n' "$command_path"+)++select_coding_agent() {+ if find_installed_coding_agent "$1" >/dev/null; then+ printf '%s already installed; will verify.\n' "$2" >&4+ return 0+ fi+ prompt_yes_no "Install $2 for $3?" "${4:-yes}"+}+choose_coding_agents() {selection_input=$1selection_output=$2@@ -104,22 +144,22 @@ choose_coding_agents() {exec 4>"$selection_output"while :; do- if prompt_yes_no "Install or verify Claude Code for fcc-claude?"; then+ if select_coding_agent claude "Claude Code" fcc-claude; theninstall_claude=1elseinstall_claude=0fi- if prompt_yes_no "Install or verify Codex for fcc-codex?"; then+ if select_coding_agent codex Codex fcc-codex; theninstall_codex=1elseinstall_codex=0fi- if prompt_yes_no "Install or verify Pi for fcc-pi?"; then+ if select_coding_agent pi Pi fcc-pi; theninstall_pi=1elseinstall_pi=0fi- if prompt_yes_no "Install or verify OpenCode for fcc-opencode?"; then+ if select_coding_agent opencode OpenCode fcc-opencode; theninstall_opencode=1elseinstall_opencode=0@@ -130,7 +170,7 @@ choose_coding_agents() {elsecline_default=nofi- if prompt_yes_no "Install or verify Cline CLI for fcc-cline?" "$cline_default"; then+ if select_coding_agent cline "Cline CLI" fcc-cline "$cline_default"; theninstall_cline=1elseinstall_cline=0@@ -141,7 +181,7 @@ choose_coding_agents() {elsehermes_default=nofi- if prompt_yes_no "Install or verify Hermes Agent for fcc-hermes?" "$hermes_default"; then+ if select_coding_agent hermes "Hermes Agent" fcc-hermes "$hermes_default"; theninstall_hermes=1elseinstall_hermes=0@@ -152,7 +192,7 @@ choose_coding_agents() {elsedsh_default=nofi- if prompt_yes_no "Install or verify DeepSeek Harness for fcc-dsh?" "$dsh_default"; then+ if select_coding_agent dsh "DeepSeek Harness" fcc-dsh "$dsh_default"; theninstall_dsh=1elseinstall_dsh=0@@ -163,7 +203,7 @@ choose_coding_agents() {elsegrok_default=nofi- if prompt_yes_no "Install or verify Grok Build for fcc-grok?" "$grok_default"; then+ if select_coding_agent grok "Grok Build" fcc-grok "$grok_default"; theninstall_grok=1elseinstall_grok=0@@ -174,7 +214,7 @@ choose_coding_agents() {elsemuse_default=nofi- if prompt_yes_no "Install or verify Muse Code for fcc-muse?" "$muse_default"; then+ if select_coding_agent muse "Muse Code" fcc-muse "$muse_default"; theninstall_muse=1elseinstall_muse=0@@ -185,7 +225,7 @@ choose_coding_agents() {elseaider_default=nofi- if prompt_yes_no "Install or verify Aider for fcc-aider?" "$aider_default"; then+ if select_coding_agent aider Aider fcc-aider "$aider_default"; theninstall_aider=1elseinstall_aider=0@@ -197,9 +237,13 @@ choose_coding_agents() {printf 'Select at least one coding agent.\n\n' >&4done- if [ "$enable_rtk" -eq 0 ] &&- prompt_yes_no "Enable RTK token optimization globally for the selected coding agents?" no; then- enable_rtk=1+ if [ "$enable_rtk" -eq 0 ]; then+ if command -v rtk >/dev/null 2>&1; then+ printf 'RTK already installed; will verify.\n' >&4+ enable_rtk=1+ elif prompt_yes_no "Enable RTK token optimization globally for the selected coding agents?" no; then+ enable_rtk=1+ fifiexec 3<&-diff --git a/tests/scripts/test_installers.py b/tests/scripts/test_installers.pyindex 80ba5bb9..55aefdc7 100644--- a/tests/scripts/test_installers.py+++ b/tests/scripts/test_installers.py@@ -1,6 +1,8 @@import hashlibimport io+import jsonimport os+import reimport shutilimport subprocessimport sys@@ -28,6 +30,19 @@ FCC_COMMANDS = ("free-claude-code",)+CODING_AGENTS = (+ "claude",+ "codex",+ "pi",+ "opencode",+ "cline",+ "hermes",+ "dsh",+ "grok",+ "muse",+ "aider",+)+def _repo_root() -> Path:return Path(__file__).resolve().parents[2]@@ -286,9 +301,23 @@ printf '%s\n' "$FCC_PS_OUTPUT"*args: str,fail_step: str = "",) -> subprocess.CompletedProcess[str]:+ source = (_repo_root() / "scripts/install.sh").read_text(encoding="utf-8")+ source = source.replace(+ ' step "Choosing coding agents"',+ " selection_path_before=$PATH\n"+ " selection_opencode_before=$original_opencode_path\n"+ ' step "Choosing coding agents"',+ ).replace(+ " choose_coding_agents /dev/tty /dev/tty",+ " choose_coding_agents /dev/tty /dev/tty\n"+ ' [ "$PATH" = "$selection_path_before" ] || fail "Selection changed PATH"\n'+ ' [ "$original_opencode_path" = "$selection_opencode_before" ] || fail "Selection changed original OpenCode"',+ )+ installer = self.root / "interactive-installer.sh"+ installer.write_text(source, encoding="utf-8")env = self.env | {"FAIL_STEP": fail_step,- "FCC_INSTALLER": str(_repo_root() / "scripts" / "install.sh"),+ "FCC_INSTALLER": str(installer),}command = ["/bin/sh",@@ -613,6 +642,171 @@ printf '%s %s\n' "$checksum" "$1"return PosixHarness(tmp_path, bin_dir, fixtures, tool_bin, log, env)[email protected]("rtk", (False, True, None))+def test_install_sh_auto_selects_installed_harnesses(+ posix_harness: PosixHarness, rtk: bool | None+) -> None:+ if rtk is not None:+ posix_harness.add_rtk()+ for command in CODING_AGENTS:+ posix_harness.add_client(command)++ result = posix_harness.run_interactive(+ "\n" if rtk is None else "", *(("--rtk",) if rtk else ())+ )++ assert result.returncode == 0, result.stdout+ assert "Install or verify" not in result.stdout+ assert "for fcc-" not in result.stdout+ assert ("Enable RTK token optimization" in result.stdout) is (rtk is None)+ for command in CODING_AGENTS:+ assert f"{command}:--version" in posix_harness.calls()+ assert ("rtk:--version:telemetry=1" in posix_harness.calls()) is (rtk is not None)+ assert ("rtk:init --global --codex:telemetry=1" in posix_harness.calls()) is (+ rtk is not None+ )++[email protected]("install_codex", (False, True))[email protected]("rtk", (False, True))+def test_install_sh_asks_only_about_missing_harnesses(+ posix_harness: PosixHarness, install_codex: bool, rtk: bool+) -> None:+ posix_harness.add_client("claude")+ if rtk:+ posix_harness.add_rtk()++ result = posix_harness.run_interactive(+ ("y\n" if install_codex else "n\n") + "n\n" * (7 if rtk else 8)+ )++ assert result.returncode == 0, result.stdout+ assert re.findall(r"for fcc-(\w+)\?", result.stdout) == [+ "codex",+ "pi",+ "cline",+ "hermes",+ "dsh",+ "grok",+ "muse",+ "aider",+ ]+ calls = posix_harness.calls()+ assert "claude:--version" in calls+ assert "opencode:--version" in calls+ assert ("codex-install:1" in calls) is install_codex+ assert not any(f"{command}:--version" in calls for command in CODING_AGENTS[4:])+ assert ("Enable RTK token optimization" in result.stdout) is not rtk+ assert ("rtk:init --global --codex:telemetry=1" in calls) is (rtk and install_codex)+ if rtk and install_codex:+ assert calls.index("codex:--version") < calls.index(+ "rtk:init --global --codex:telemetry=1"+ )+++def test_install_sh_discovers_installed_npm_harnesses_before_questions(+ posix_harness: PosixHarness,+) -> None:+ prefix = posix_harness.root / "custom npm"+ posix_harness.add_npm_prefix(prefix)+ for command in ("pi", "cline", "dsh"):+ _write_executable(prefix / "bin" / command, _posix_command(command))++ result = posix_harness.run_interactive("n\n" * 7)++ assert result.returncode == 0, result.stdout+ assert re.findall(r"for fcc-(\w+)\?", result.stdout) == [+ "claude",+ "codex",+ "hermes",+ "grok",+ "muse",+ "aider",+ ]+ calls = posix_harness.calls()+ assert "pi-install" not in calls+ assert not any(call.startswith("npm:install") for call in calls)+ for command in ("pi", "cline", "dsh"):+ assert f"{command}:--version" in calls+++ "location", ("UV_TOOL_BIN_DIR", "XDG_BIN_HOME", "XDG_DATA_HOME", "home")+)+def test_install_sh_discovers_installed_aider_without_uv(+ posix_harness: PosixHarness, location: str+) -> None:+ tool_bin = _aider_discovery_location(+ posix_harness.root, posix_harness.env, location+ )+ _write_executable(tool_bin / "aider", _posix_command("aider"))++ result = posix_harness.run_interactive("n\n" * 9)++ assert result.returncode == 0, result.stdout+ assert "for fcc-aider?" not in result.stdout+ calls = posix_harness.calls()+ assert "aider:--version" in calls+ assert not any("aider-chat@latest" in call for call in calls)+ assert "uv-install" in calls+++def test_install_sh_asks_about_unrelated_pi(posix_harness: PosixHarness) -> None:+ posix_harness.add_unrelated_pi()++ result = posix_harness.run_interactive("n\n" * 10)++ assert result.returncode == 0, result.stdout+ assert "Install Pi for fcc-pi?" in result.stdout+ calls = posix_harness.calls()+ assert "unrelated-pi:--help" in calls+ assert "unrelated-pi:--version" not in calls+ assert "pi-install" not in calls+++def test_install_sh_interactive_dry_run_does_not_execute_probes(+ posix_harness: PosixHarness,+) -> None:+ for command in CODING_AGENTS:+ posix_harness.add_client(command)++ result = posix_harness.run_interactive("n\n", "--dry-run")++ assert result.returncode == 0, result.stdout+ assert "for fcc-" not in result.stdout+ assert posix_harness.calls() == []+++def test_install_sh_failed_npm_discovery_does_not_block_selection(+ posix_harness: PosixHarness,+) -> None:+ _write_executable(+ posix_harness.bin_dir / "npm",+ '#!/bin/sh\necho "npm:$*" >> "$CALL_LOG"\nexit 72\n',+ )++ result = posix_harness.run_interactive("n\n" * 10)++ assert result.returncode == 0, result.stdout+ assert "opencode:--version" in posix_harness.calls()+ assert "npm:config get prefix" in posix_harness.calls()++[email protected]("variable", ("UV_INSTALL_DIR", "UV_UNMANAGED_INSTALL"))+def test_install_sh_does_not_use_uv_install_directory_for_aider(+ posix_harness: PosixHarness, variable: str+) -> None:+ uv_bin = posix_harness.root / "uv bin"+ posix_harness.env[variable] = str(uv_bin)+ _write_executable(uv_bin / "aider", _posix_command("aider"))++ result = posix_harness.run_interactive("n\n" * 10)++ assert result.returncode == 0, result.stdout+ assert "Install Aider for fcc-aider?" in result.stdout+ assert "aider:--version" not in posix_harness.calls()++def test_install_sh_fresh_install_is_verified(posix_harness: PosixHarness) -> None:(posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run()@@ -677,6 +871,7 @@ def test_install_sh_discovers_grok_in_custom_bin_directory(def test_install_sh_installs_selected_hermes_without_setup(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\ny\nn\nn\nn\nn\nn\n")assert result.returncode == 0, result.stdout@@ -696,6 +891,7 @@ def test_install_sh_stops_when_selected_hermes_install_fails(posix_harness: PosixHarness,failure: str,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\ny\nn\nn\nn\nn\nn\n", fail_step=failure)@@ -708,6 +904,7 @@ def test_install_sh_stops_when_selected_hermes_install_fails(def test_install_sh_rejects_unsupported_hermes_platform_before_download(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()posix_harness.env["FAKE_UNAME"] = "Darwin"posix_harness.env["FAKE_UNAME_MACHINE"] = "x86_64"@@ -756,6 +953,7 @@ def test_install_sh_stops_when_grok_install_fails(posix_harness: PosixHarness,failure: str,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\nn\ny\nn\nn\nn\n", fail_step=failure)@@ -770,6 +968,7 @@ def test_install_sh_stops_when_muse_install_fails(posix_harness: PosixHarness,failure: str,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\nn\nn\ny\nn\nn\n", fail_step=failure)@@ -782,6 +981,7 @@ def test_install_sh_stops_when_muse_install_fails(def test_install_sh_stops_when_aider_install_fails(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\nn\nn\nn\ny\nn\n", fail_step="aider-install")@@ -800,6 +1000,7 @@ def test_install_sh_stops_when_aider_install_fails(def test_install_sh_accepts_aider_as_the_only_selected_agent(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\nn\nn\nn\ny\nn\n")assert result.returncode == 0, result.stdout@@ -817,6 +1018,7 @@ def test_install_sh_accepts_aider_as_the_only_selected_agent(def test_install_sh_discovers_aider_in_custom_uv_tool_bin(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()custom_tool_bin = posix_harness.root / "custom-tool-bin"posix_harness.env["UV_TOOL_BIN_DIR"] = str(custom_tool_bin)@@ -843,16 +1045,15 @@ def test_install_sh_checks_existing_aider_in_custom_uv_tool_bin_before_installin)original = existing_aider.read_bytes()- result = posix_harness.run_interactive(- "n\nn\nn\nn\nn\nn\nn\nn\nn\ny\nn\n", fail_step=fail_step- )+ result = posix_harness.run_interactive("n\n" * 9, fail_step=fail_step)if fail_step:assert result.returncode != 0else:assert result.returncode == 0, result.stderrcalls = posix_harness.calls()- assert calls.index("uv:tool dir --bin") < calls.index("aider:--version")+ assert "for fcc-aider?" not in result.stdout+ assert "aider:--version" in callsassert not any("aider-chat@latest" in call for call in calls)assert existing_aider.read_bytes() == original@@ -874,6 +1075,7 @@ def test_install_sh_rejects_broken_existing_aider_without_replacing_it(def test_install_sh_installs_selected_dsh_at_exact_preview(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\ny\nn\nn\nn\nn\n")assert result.returncode == 0, result.stdout@@ -886,17 +1088,21 @@ def test_install_sh_installs_selected_dsh_at_exact_preview(assert not any(call.startswith("rtk:init") for call in calls)[email protected]("interactive", (False, True))def test_install_sh_replaces_mismatched_dsh_preview(posix_harness: PosixHarness,+ interactive: bool,) -> None:_write_executable(posix_harness.bin_dir / "dsh",_posix_command("dsh").replace("0.1.0-rc.8", "0.1.0-rc.7"),)- result = posix_harness.run()+ result = (+ posix_harness.run_interactive("n\n" * 9) if interactive else posix_harness.run()+ )- assert result.returncode == 0, result.stderr+ assert result.returncode == 0, result.stdout + result.stderrassert "does not match 0.1.0-rc.8" in result.stdoutassert "npm:install -g @deepseek-ai/[email protected]" in posix_harness.calls()@@ -922,6 +1128,7 @@ def test_install_sh_rejects_incompatible_node_for_selected_dsh(posix_harness: PosixHarness,node_version: str,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()_write_executable(posix_harness.bin_dir / "node",_posix_command("node").replace("node 22.19.0", f"node {node_version}"),@@ -952,6 +1159,7 @@ def test_install_sh_noninteractive_skips_dsh_without_node(def test_install_sh_stops_when_selected_dsh_install_fails(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\nn\nn\nn\nn\ny\nn\nn\nn\nn\n", fail_step="dsh-install")@@ -1045,6 +1253,7 @@ def test_install_sh_rejects_unsupported_rtk_platform(def test_install_sh_preserves_existing_rtk_and_configures_only_selected_agent(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()posix_harness.add_rtk()result = posix_harness.run_interactive("n\ny\nn\nn\nn\nn\nn\nn\nn\nn\ny\n")@@ -1094,6 +1303,7 @@ def test_install_sh_stops_when_rtk_setup_fails(def test_install_sh_reprompts_then_installs_only_selected_agent(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\n" * 11 + "y\n" + "n\n" * 9)assert result.returncode == 0, result.stdout@@ -1113,6 +1323,7 @@ def test_install_sh_reprompts_then_installs_only_selected_agent(def test_install_sh_rejects_uninstalled_only_selection(posix_harness: PosixHarness,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()result = posix_harness.run_interactive("n\nn\ny\nn\nn\nn\nn\nn\nn\nn\nn\n", fail_step="pi-skip")@@ -1229,19 +1440,26 @@ def test_install_sh_preserves_valid_existing_tools(assert "leaving it unchanged" in result.stdout[email protected]("interactive", (False, True))def test_install_sh_replaces_unrelated_pi_command(posix_harness: PosixHarness,+ interactive: bool,) -> None:posix_harness.add_client("claude")posix_harness.add_client("codex")posix_harness.add_unrelated_pi()posix_harness.add_uv("0.12.13")- result = posix_harness.run()+ result = (+ posix_harness.run_interactive("y\n" + "n\n" * 7)+ if interactive+ else posix_harness.run()+ )- assert result.returncode == 0, result.stderr+ assert result.returncode == 0, result.stdout + result.stderrassert "is not Pi Coding Agent; installing Pi" in result.stdoutassert "pi-install" in posix_harness.calls()+ assert "pi:--version" in posix_harness.calls()def test_install_sh_discovers_custom_pi_npm_prefix(@@ -1403,6 +1621,7 @@ def test_install_sh_infers_home_for_replacement_uv(posix_harness: PosixHarness,cargo_layout: bool,) -> None:+ (posix_harness.bin_dir / "opencode").unlink()inferred_home = Path(posix_harness.env["FAKE_INFERRED_HOME"])posix_harness.env.pop("HOME")if cargo_layout:@@ -1952,6 +2171,12 @@ exit /b 76env=env,)+ def run_interactive(+ self, answers: list[str], *args: str, fail_step: str = ""+ ) -> subprocess.CompletedProcess[str]:+ self.env["FCC_INSTALLER_ANSWERS"] = json.dumps({"answers": answers})+ return self.run(*args, fail_step=fail_step)+def calls(self) -> list[str]:if not self.log.exists():return []@@ -2074,7 +2299,12 @@ Add-Content -LiteralPath $env:CALL_LOG -Value "grok-install")(fixtures / "muse-installer.ps1").write_text(r"""if ($env:FAIL_STEP -eq "muse-install") { exit 68 }+$originalPath = $env:Path+if ($env:FCC_TEST_USER_PATH) {+ $env:Path = "$originalPath$([IO.Path]::PathSeparator)$env:FCC_TEST_USER_PATH"+}$existing = Get-Command "muse" -CommandType Application -ErrorAction SilentlyContinue+$env:Path = $originalPathif ($existing) {Add-Content -LiteralPath $env:CALL_LOG -Value "muse-install:external"return@@ -2224,6 +2454,43 @@ function Get-Process {}}$installerSource = [IO.File]::ReadAllText($env:FCC_INSTALLER)+$installerSource = $installerSource.Replace(+ '[Environment]::GetEnvironmentVariable("Path", "User")',+ '$env:FCC_TEST_USER_PATH'+)+if ($env:FCC_INSTALLER_ANSWERS) {+ $script:InstallerAnswers = (ConvertFrom-Json $env:FCC_INSTALLER_ANSWERS).answers+ $script:InstallerAnswerIndex = 0+ function Read-Host {+ param([string] $Prompt)+ Write-Host $Prompt+ if ($script:InstallerAnswerIndex -ge $script:InstallerAnswers.Count) {+ throw "Unexpected extra installer question: $Prompt"+ }+ $answer = $script:InstallerAnswers[$script:InstallerAnswerIndex]+ $script:InstallerAnswerIndex += 1+ return $answer+ }+ $installerSource = $installerSource.Replace(+ 'return (-not [Console]::IsInputRedirected) -and (-not [Console]::IsOutputRedirected)',+ 'return $true'+ )+ $installerSource = $installerSource.Replace(+ ' Write-Step "Choosing coding agents"',+ @'+ $selectionPathBefore = $env:Path+ $selectionOpenCodeBefore = $script:OriginalOpenCode+ Write-Step "Choosing coding agents"+'@+ ).Replace(+ ' Select-CodingAgents',+ @'+ Select-CodingAgents+ if ($env:Path -cne $selectionPathBefore) { throw "Selection changed PATH" }+ if ($script:OriginalOpenCode -ne $selectionOpenCodeBefore) { throw "Selection changed original OpenCode" }+'@+ )+}$nativeVersionProbe = ' $output = Read-OpenCodeVersionOutput $OpenCodePath'$fakeArchiveVersionProbe = @'$output = if ([IO.Path]::GetExtension($OpenCodePath) -eq ".exe") {@@ -2276,6 +2543,8 @@ $installer = [scriptblock]::Create($installerSource)"FAIL_STEP": "","FAKE_OPENCODE_RELEASE": "","FAKE_OPENCODE_ARCHIVE_VERSION": "",+ "FCC_INSTALLER_ANSWERS": "",+ "FCC_TEST_USER_PATH": "",})env.pop("XDG_BIN_HOME", None)@@ -2290,6 +2559,520 @@ $installer = [scriptblock]::Create($installerSource))[email protected]("rtk", (False, True, None))+def test_install_ps1_auto_selects_installed_harnesses(+ powershell_harness: PowerShellHarness,+ rtk: bool | None,+) -> None:+ if rtk is not None:+ powershell_harness.add_rtk()+ for command in CODING_AGENTS:+ powershell_harness.add_client(command)++ result = powershell_harness.run_interactive(+ [""] if rtk is None else [], *(("-Rtk",) if rtk else ())+ )++ assert result.returncode == 0, result.stderr+ assert "Install or verify" not in result.stdout+ assert "for fcc-" not in result.stdout+ assert ("Enable RTK token optimization" in result.stdout) is (rtk is None)+ for command in CODING_AGENTS:+ assert f"{command}:--version" in powershell_harness.calls()+ assert "muse-install:external" in powershell_harness.calls()+ assert ("rtk:--version:telemetry=1" in powershell_harness.calls()) is (+ rtk is not None+ )+ assert ("rtk:init --global --codex:telemetry=1" in powershell_harness.calls()) is (+ rtk is not None+ )++[email protected]("install_codex", (False, True))[email protected]("rtk", (False, True))+def test_install_ps1_asks_only_about_missing_harnesses(+ powershell_harness: PowerShellHarness, install_codex: bool, rtk: bool+) -> None:+ powershell_harness.add_client("claude")+ if rtk:+ powershell_harness.add_rtk()++ result = powershell_harness.run_interactive(+ ["y" if install_codex else "n"] + ["n"] * (7 if rtk else 8)+ )++ assert result.returncode == 0, result.stderr+ assert re.findall(r"for fcc-(\w+)\?", result.stdout) == [+ "codex",+ "pi",+ "cline",+ "hermes",+ "dsh",+ "grok",+ "muse",+ "aider",+ ]+ calls = powershell_harness.calls()+ assert "claude:--version" in calls+ assert "opencode:--version" in calls+ assert ("codex-install:1" in calls) is install_codex+ assert not any(f"{command}:--version" in calls for command in CODING_AGENTS[4:])+ assert ("Enable RTK token optimization" in result.stdout) is not rtk+ assert ("rtk:init --global --codex:telemetry=1" in calls) is (rtk and install_codex)+ if rtk and install_codex:+ assert calls.index("codex:--version") < calls.index(+ "rtk:init --global --codex:telemetry=1"+ )+++def test_install_ps1_discovers_installed_npm_harnesses_before_questions(+ powershell_harness: PowerShellHarness,+) -> None:+ prefix = powershell_harness.root / "custom npm"+ powershell_harness.add_npm_prefix(prefix)+ for command in ("pi", "cline", "dsh"):+ _write_executable(prefix / f"{command}.cmd", _batch_client(command))++ result = powershell_harness.run_interactive(["n"] * 7)++ assert result.returncode == 0, result.stderr+ assert re.findall(r"for fcc-(\w+)\?", result.stdout) == [+ "claude",+ "codex",+ "hermes",+ "grok",+ "muse",+ "aider",+ ]+ calls = powershell_harness.calls()+ assert "pi-install" not in calls+ assert not any(call.startswith("npm:install") for call in calls)+ for command in ("pi", "cline", "dsh"):+ assert f"{command}:--version" in calls+++def _prepare_discovery_collision(+ harness: PosixHarness | PowerShellHarness, discovery: str, command: str+) -> str:+ windows = isinstance(harness, PowerShellHarness)+ suffix = ".cmd" if windows else ""+ make_command = _batch_client if windows else _posix_command+ home = Path(harness.env["USERPROFILE" if windows else "HOME"])+ harness.add_uv("0.12.13")+ for name in ("claude", "codex"):+ _write_executable(+ home / ".local" / "bin" / f"{name}{suffix}", make_command(name)+ )+ extra_bin = harness.root / "extra bin"+ if discovery == "npm":+ harness.add_npm_prefix(extra_bin)+ if not windows:+ extra_bin /= "bin"+ candidate = "cline"+ else:+ harness.env["UV_TOOL_BIN_DIR"] = str(extra_bin)+ candidate = "aider"+ _write_executable(extra_bin / f"{candidate}{suffix}", make_command(candidate))+ _write_executable(+ extra_bin / f"{command}{suffix}", make_command(f"stale-{command}")+ )+ return candidate++[email protected]("discovery", ("npm", "uv"))[email protected]("command", ("claude", "codex"))+def test_install_sh_discovery_preserves_existing_command_priority(+ posix_harness: PosixHarness, discovery: str, command: str+) -> None:+ candidate = _prepare_discovery_collision(posix_harness, discovery, command)++ result = posix_harness.run_interactive(+ "n\n" * 7, fail_step=f"stale-{command}-verify"+ )++ assert result.returncode == 0, result.stdout+ assert f"for fcc-{candidate}?" not in result.stdout+ calls = posix_harness.calls()+ assert "claude:--version" in calls+ assert "codex:--version" in calls+ assert f"{candidate}:--version" in calls+ assert "uv-install" not in calls+ assert not any(call.startswith(f"stale-{command}:") for call in calls)++[email protected]("discovery", ("npm", "uv"))[email protected]("command", ("claude", "codex"))+def test_install_ps1_discovery_preserves_existing_command_priority(+ powershell_harness: PowerShellHarness, discovery: str, command: str+) -> None:+ candidate = _prepare_discovery_collision(powershell_harness, discovery, command)++ result = powershell_harness.run_interactive(+ ["n"] * 7, fail_step=f"stale-{command}-verify"+ )++ assert result.returncode == 0, result.stderr+ assert f"for fcc-{candidate}?" not in result.stdout+ calls = powershell_harness.calls()+ assert "claude:--version" in calls+ assert "codex:--version" in calls+ assert f"{candidate}:--version" in calls+ assert "uv-install" not in calls+ assert not any(call.startswith(f"stale-{command}:") for call in calls)+++def _assert_setup_preserves_other_commands(+ harness: PosixHarness | PowerShellHarness, installing: str, other: str+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ suffix = ".cmd" if windows else ""+ make_command = _batch_client if windows else _posix_command+ prefix = harness.root / "other npm"+ harness.add_npm_prefix(prefix)+ npm_bin = prefix if windows else prefix / "bin"+ npm_bin.mkdir(exist_ok=True)+ if other == "uv":+ stale_uv = (+ '@echo off\necho stale-uv:%*>>"%CALL_LOG%"\n'+ 'if "%1"=="--version" (echo uv 0.11.0& exit /b 0)\nexit /b 77\n'+ if windows+ else '#!/bin/sh\necho "stale-uv:$*" >> "$CALL_LOG"\n'+ 'if [ "$1" = --version ]; then echo "uv 0.11.0"; else exit 77; fi\n'+ )+ _write_executable(npm_bin / f"uv{suffix}", stale_uv)+ harness.env["PATH"] = str(npm_bin) + os.pathsep + harness.env["PATH"]+ else:+ harness.add_uv("0.12.13")+ harness.add_client(other)+ _write_executable(npm_bin / f"{other}{suffix}", make_command(f"stale-{other}"))+ harness.env["PATH"] += os.pathsep + str(npm_bin)+ installed = {"opencode", other}+ if installing == "dsh":+ _write_executable(+ npm_bin / f"dsh{suffix}",+ make_command("dsh").replace("0.1.0-rc.8", "0.1.0-rc.7"),+ )+ installed.add("dsh")+ answers = [+ "y" if name == installing else "n"+ for name in CODING_AGENTS+ if name not in installed+ ] + ["n"]+ failure = "" if other == "uv" else f"stale-{other}-verify"+ result = (+ harness.run_interactive(answers, fail_step=failure)+ if windows+ else harness.run_interactive("\n".join(answers) + "\n", fail_step=failure)+ )++ assert result.returncode == 0, result.stdout + result.stderr+ calls = harness.calls()+ assert f"{installing}:--version" in calls+ assert f"{other}:--version" in calls+ if other == "uv":+ assert "uv-install" in calls+ assert not any(call.startswith("stale-uv:tool") for call in calls)+ else:+ assert not any(call.startswith(f"stale-{other}:") for call in calls)+ assert any("--refresh-package free-claude-code" in call for call in calls)+++ ("installing", "other"),+ (("pi", "cline"), ("dsh", "grok"), ("pi", "uv"), ("dsh", "uv")),+)+def test_install_sh_setup_preserves_other_commands(+ posix_harness: PosixHarness, installing: str, other: str+) -> None:+ _assert_setup_preserves_other_commands(posix_harness, installing, other)+++ ("installing", "other"),+ (("pi", "cline"), ("dsh", "grok"), ("pi", "uv"), ("dsh", "uv")),+)+def test_install_ps1_setup_preserves_other_commands(+ powershell_harness: PowerShellHarness, installing: str, other: str+) -> None:+ _assert_setup_preserves_other_commands(powershell_harness, installing, other)+++def test_install_ps1_verifies_new_fcc_after_custom_tool_discovery(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_uv("0.12.13")+ powershell_harness.env["UV_TOOL_BIN_DIR"] = str(powershell_harness.tool_bin)+ _write_executable(+ powershell_harness.bin_dir / "fcc-server.cmd", _batch_client("stale-fcc")+ )++ result = powershell_harness.run_interactive(["n"] * 10)++ assert result.returncode == 0, result.stdout + result.stderr+ calls = powershell_harness.calls()+ assert "fcc-server:--version" in calls+ assert not any(call.startswith("stale-fcc:") for call in calls)+++def _assert_lookup_is_isolated(+ harness: PosixHarness | PowerShellHarness, command: str, present: bool+) -> None:+ windows = isinstance(harness, PowerShellHarness)+ suffix = ".cmd" if windows else ""+ make_command = _batch_client if windows else _posix_command+ tool_bin = harness.root / "query tool bin"+ harness.env["UV_TOOL_BIN_DIR"] = str(tool_bin)+ harness.env["FCC_TEST_USER_PATH"] = str(tool_bin)+ harness.env["QUERY_COMMAND"] = command+ harness.env["QUERY_PRESENT"] = "1" if present else "0"+ if command == "opencode":+ (harness.bin_dir / f"opencode{suffix}").unlink()+ if command in ("pi", "cline", "dsh"):+ destination = Path(harness.env["FAKE_NPM_PREFIX"])+ if not windows:+ destination /= "bin"+ elif command == "aider" or (windows and command == "muse"):+ destination = tool_bin+ else:+ destination = harness.bin_dir+ if present:+ _write_executable(destination / f"{command}{suffix}", make_command(command))++ source = (+ _repo_root() / "scripts" / f"install.{'ps1' if windows else 'sh'}"+ ).read_text(encoding="utf-8")+ if windows:+ source = (+ source.split("\nif ($Help) {", 1)[0]+ + """+$script:OriginalOpenCode = $null+Add-KnownBinDirectories+$pathBefore = $env:Path+$found = Find-InstalledCodingAgent $env:QUERY_COMMAND+if ($env:Path -cne $pathBefore) { throw "Lookup changed PATH" }+if ([bool] $found -ne ($env:QUERY_PRESENT -eq "1")) { throw "Wrong presence result" }+if ($found -and (-not (Test-Path -LiteralPath $found.Source -PathType Leaf))) {+ throw "Lookup did not return an application"+}+Write-Output "lookup isolated"+"""+ )+ installer = harness.root / "query.ps1"+ installer.write_text(source, encoding="utf-8")+ harness.env["FCC_INSTALLER"] = str(installer)+ result = harness.run()+ else:+ source = (+ source.split('\nparse_args "$@"\n', 1)[0]+ + """+original_opencode_path=""+add_known_bin_directories+path_before=$PATH+command_path=keep-command+pi_npm_prefix=keep-prefix+tool_bin=keep-tool-bin+found=""+if find_installed_coding_agent "$QUERY_COMMAND" > "$HOME/query-result"; then+ IFS= read -r found < "$HOME/query-result"+ [ "$QUERY_PRESENT" = 1 ] || fail "Unexpected command"+ [ -x "$found" ] || fail "Lookup did not return an executable"+else+ [ "$QUERY_PRESENT" = 0 ] || fail "Missing command"+fi+[ "$PATH" = "$path_before" ] || fail "Lookup changed PATH"+[ "$command_path:$pi_npm_prefix:$tool_bin" = keep-command:keep-prefix:keep-tool-bin ] || fail "Lookup changed helper state"+printf 'lookup isolated\\n'+"""+ )+ installer = harness.root / "query.sh"+ installer.write_text(source, encoding="utf-8")+ result = subprocess.run(+ ["/bin/sh", str(installer)],+ env=harness.env,+ capture_output=True,+ text=True,+ check=False,+ timeout=30,+ )+ assert result.returncode == 0, result.stdout + result.stderr+ assert "lookup isolated" in result.stdout+ assert not any("install" in call or "--version" in call for call in harness.calls())++[email protected]("command", (*CODING_AGENTS, "rtk"))[email protected]("present", (False, True))+def test_install_sh_lookup_is_isolated(+ posix_harness: PosixHarness, command: str, present: bool+) -> None:+ _assert_lookup_is_isolated(posix_harness, command, present)++[email protected]("command", (*CODING_AGENTS, "rtk"))[email protected]("present", (False, True))+def test_install_ps1_lookup_is_isolated(+ powershell_harness: PowerShellHarness, command: str, present: bool+) -> None:+ _assert_lookup_is_isolated(powershell_harness, command, present)+++def test_install_ps1_lookup_restores_path_after_exception(+ powershell_harness: PowerShellHarness,+) -> None:+ source = (_repo_root() / "scripts/install.ps1").read_text(encoding="utf-8")+ source = (+ source.split("\nif ($Help) {", 1)[0]+ + """+$script:OriginalOpenCode = $null+$env:UV_TOOL_BIN_DIR = Join-Path $env:USERPROFILE "exception lookup"+$pathBefore = $env:Path+function Get-ApplicationCommand {+ param([string] $Name)+ if ($env:Path.Contains($env:UV_TOOL_BIN_DIR)) { throw "query failed after PATH change" }+ return $null+}+$caught = $false+try {+ $null = Find-InstalledCodingAgent "aider"+}+catch {+ if ($_.Exception.Message -ne "query failed after PATH change") { throw }+ $caught = $true+}+if (-not $caught) { throw "Expected lookup exception" }+if ($env:Path -cne $pathBefore) { throw "Failed lookup changed PATH" }+Write-Output "exception isolated"+"""+ )+ installer = powershell_harness.root / "exception.ps1"+ installer.write_text(source, encoding="utf-8")+ powershell_harness.env["FCC_INSTALLER"] = str(installer)++ result = powershell_harness.run()++ assert result.returncode == 0, result.stdout + result.stderr+ assert "exception isolated" in result.stdout+ assert powershell_harness.calls() == []+++def _aider_discovery_location(root: Path, env: dict[str, str], location: str) -> Path:+ # Competing configuration must not hide the installed tool's chosen directory.+ locations = ("UV_TOOL_BIN_DIR", "XDG_BIN_HOME", "XDG_DATA_HOME", "home")+ bins = []+ for variable in locations[locations.index(location) :]:+ if variable == "home":+ directory = root / "home" / ".local" / "bin"+ elif variable == "XDG_DATA_HOME":+ data = root / "xdg" / "data"+ data.mkdir(parents=True)+ env[variable] = str(data)+ directory = data.parent / "bin"+ else:+ directory = root / f"{variable.lower()} bin"+ env[variable] = str(directory)+ directory.mkdir(parents=True)+ bins.append(directory)+ return bins[0]+++ "location", ("UV_TOOL_BIN_DIR", "XDG_BIN_HOME", "XDG_DATA_HOME", "home")+)+def test_install_ps1_discovers_installed_aider_without_uv(+ powershell_harness: PowerShellHarness, location: str+) -> None:+ tool_bin = _aider_discovery_location(+ powershell_harness.root, powershell_harness.env, location+ )+ _write_executable(tool_bin / "aider.cmd", _batch_client("aider"))++ result = powershell_harness.run_interactive(["n"] * 9)++ assert result.returncode == 0, result.stderr+ assert "for fcc-aider?" not in result.stdout+ calls = powershell_harness.calls()+ assert "aider:--version" in calls+ assert not any("aider-chat@latest" in call for call in calls)+ assert "uv-install" in calls+++def test_install_ps1_asks_about_unrelated_pi(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_unrelated_pi()++ result = powershell_harness.run_interactive(["n"] * 10)++ assert result.returncode == 0, result.stderr+ assert "Install Pi for fcc-pi?" in result.stdout+ calls = powershell_harness.calls()+ assert "unrelated-pi:--help" in calls+ assert "unrelated-pi:--version" not in calls+ assert "pi-install" not in calls+++def test_install_ps1_discovers_muse_from_user_path(+ powershell_harness: PowerShellHarness,+) -> None:+ powershell_harness.add_client("codex")+ user_bin = powershell_harness.root / "user bin"+ _write_executable(user_bin / "muse.cmd", _batch_client("muse"))+ _write_executable(user_bin / "codex.cmd", _batch_client("wrong-codex"))+ powershell_harness.env["FCC_TEST_USER_PATH"] = str(user_bin)++ result = powershell_harness.run_interactive(["n"] * 8)++ assert result.returncode == 0, result.stderr+ assert "for fcc-muse?" not in result.stdout+ calls = powershell_harness.calls()+ assert "muse:--version" in calls+ assert "muse-install:external" in calls+ assert "codex:--version" in calls+ assert "wrong-codex:--version" not in calls+++def test_install_ps1_interactive_dry_run_does_not_execute_probes(+ powershell_harness: PowerShellHarness,+) -> None:+ for command in CODING_AGENTS:+ powershell_harness.add_client(command)++ result = powershell_harness.run_interactive(["n"], "-DryRun")++ assert result.returncode == 0, result.stderr+ assert "for fcc-" not in result.stdout+ assert powershell_harness.calls() == []+++def test_install_ps1_failed_npm_discovery_does_not_block_selection(+ powershell_harness: PowerShellHarness,+) -> None:+ _write_executable(+ powershell_harness.bin_dir / "npm.cmd",+ '@echo off\necho npm:%*>>"%CALL_LOG%"\nexit /b 72\n',+ )++ result = powershell_harness.run_interactive(["n"] * 10)++ assert result.returncode == 0, result.stderr+ assert "opencode:--version" in powershell_harness.calls()+ assert "npm:config get prefix" in powershell_harness.calls()++[email protected]("variable", ("UV_INSTALL_DIR", "UV_UNMANAGED_INSTALL"))+def test_install_ps1_does_not_use_uv_install_directory_for_aider(+ powershell_harness: PowerShellHarness, variable: str+) -> None:+ uv_bin = powershell_harness.root / "uv bin"+ powershell_harness.env[variable] = str(uv_bin)+ _write_executable(uv_bin / "aider.cmd", _batch_client("aider"))++ result = powershell_harness.run_interactive(["n"] * 10)++ assert result.returncode == 0, result.stderr+ assert "Install Aider for fcc-aider?" in result.stdout+ assert "aider:--version" not in powershell_harness.calls()++def test_install_ps1_fresh_install_is_verified(powershell_harness: PowerShellHarness,) -> None:@@ -2483,9 +3266,11 @@ def test_install_ps1_discovers_aider_in_custom_uv_tool_bin(@pytest.mark.parametrize("fail_step", ("", "aider-verify"), ids=("valid", "broken"))[email protected]("interactive", (False, True))def test_install_ps1_checks_existing_aider_in_custom_uv_tool_bin_before_installing(powershell_harness: PowerShellHarness,fail_step: str,+ interactive: bool,) -> None:custom_tool_bin = powershell_harness.root / "custom-tool-bin"existing_aider = custom_tool_bin / "aider.cmd"@@ -2497,14 +3282,22 @@ def test_install_ps1_checks_existing_aider_in_custom_uv_tool_bin_before_installi)original = existing_aider.read_bytes()- result = powershell_harness.run(fail_step=fail_step)+ result = (+ powershell_harness.run_interactive(["n"] * 9, fail_step=fail_step)+ if interactive+ else powershell_harness.run(fail_step=fail_step)+ )if fail_step:assert result.returncode != 0else:assert result.returncode == 0, result.stderrcalls = powershell_harness.calls()- assert calls.index("uv:tool dir --bin") < calls.index("aider:--version")+ if interactive:+ assert "for fcc-aider?" not in result.stdout+ assert "aider:--version" in calls+ else:+ assert calls.index("uv:tool dir --bin") < calls.index("aider:--version")assert not any("aider-chat@latest" in call for call in calls)assert existing_aider.read_bytes() == original@@ -2537,17 +3330,23 @@ def test_install_ps1_preserves_exact_dsh_preview()[email protected]("interactive", (False, True))def test_install_ps1_replaces_mismatched_dsh_preview(powershell_harness: PowerShellHarness,+ interactive: bool,) -> None:(powershell_harness.bin_dir / "dsh.cmd").write_text(_batch_client("dsh").replace("0.1.0-rc.8", "0.1.0-rc.7"),encoding="utf-8",)- result = powershell_harness.run()+ result = (+ powershell_harness.run_interactive(["n"] * 9)+ if interactive+ else powershell_harness.run()+ )- assert result.returncode == 0, result.stderr+ assert result.returncode == 0, result.stdout + result.stderrassert "does not match 0.1.0-rc.8" in result.stdoutassert "npm:install -g @deepseek-ai/[email protected]" in (powershell_harness.calls())@@ -2848,19 +3647,26 @@ def test_install_ps1_preserves_valid_existing_tools(assert "leaving it unchanged" in result.stdout[email protected]("interactive", (False, True))def test_install_ps1_replaces_unrelated_pi_command(powershell_harness: PowerShellHarness,+ interactive: bool,) -> None:powershell_harness.add_client("claude")powershell_harness.add_client("codex")powershell_harness.add_unrelated_pi()powershell_harness.add_uv("0.12.13")- result = powershell_harness.run()+ result = (+ powershell_harness.run_interactive(["y"] + ["n"] * 7)+ if interactive+ else powershell_harness.run()+ )- assert result.returncode == 0, result.stderr+ assert result.returncode == 0, result.stdout + result.stderrassert "is not Pi Coding Agent; installing Pi" in result.stdoutassert "pi-install" in powershell_harness.calls()+ assert "pi:--version" in powershell_harness.calls()def test_install_ps1_discovers_custom_pi_npm_prefix(@@ -3317,11 +4123,16 @@ def test_install_ps1_selects_at_least_one_coding_agent() -> None:text = (_repo_root() / "scripts" / "install.ps1").read_text(encoding="utf-8")read_yes_no = _braced_body(text, "function Read-YesNo")+ read_selection = _braced_body(text, "function Read-CodingAgentSelection")select_agents = _braced_body(text, "function Select-CodingAgents")answer_array = ", ".join(repr(answer) for answer in answers)script = f"""Set-StrictMode -Version Latest$ErrorActionPreference = "Stop"$script:Answers = @({answer_array})+$script:OriginalOpenCode = $null+$DryRun = $false+function Get-ApplicationCommand {{ param([string] $Name) return $null }}+function Find-InstalledCodingAgent {{ param([string] $CommandName) return $null }}$script:AnswerIndex = 0$script:InstallClaudeCode = $true$script:InstallCodex = $true@@ -3341,6 +4152,7 @@ function Read-Host {{return $answer}}function Read-YesNo {{{read_yes_no}}}+function Read-CodingAgentSelection {{{read_selection}}}function Select-CodingAgents {{{select_agents}}}Select-CodingAgentsWrite-Output "selection:$($script:InstallClaudeCode),$($script:InstallCodex),$($script:InstallPi),$($script:InstallOpenCode),$($script:InstallCline),$($script:InstallHermes),$($script:InstallDsh),$($script:InstallGrok),$($script:InstallMuse),$($script:InstallAider),$($script:EnableRtk)"@@ -3767,6 +4579,7 @@ def test_install_ps1_opencode_running_blocks_native_migration(def _assert_external_opencode_is_not_shadowed(harness: PosixHarness | PowerShellHarness,+ interactive: bool,) -> None:windows = isinstance(harness, PowerShellHarness)home = Path(harness.env["USERPROFILE" if windows else "HOME"])@@ -3777,26 +4590,42 @@ def _assert_external_opencode_is_not_shadowed("opencode", version_output="opencode v1.18.31"),)- native = home / ".opencode" / "bin" / ("opencode.exe" if windows else "opencode")+ native_bin = home / ".opencode" / "bin"+ if interactive:+ native_bin = harness.root / "custom-tool-bin"+ harness.env["UV_TOOL_BIN_DIR"] = str(native_bin)+ native = native_bin / ("opencode.exe" if windows else "opencode")_write_executable(native, "native-v2" if windows else _posix_command("opencode"))original = native.read_bytes()- result = harness.run()+ if interactive:+ result = (+ harness.run_interactive(["n"] * 10)+ if isinstance(harness, PowerShellHarness)+ else harness.run_interactive("n\n" * 10)+ )+ assert "for fcc-opencode?" not in result.stdout+ else:+ result = harness.run()assert result.returncode != 0- assert str(external) in "".join(result.stderr.split())+ assert str(external) in "".join((result.stdout + result.stderr).split())assert native.read_bytes() == originalassert not any("opencode.ai" in call for call in harness.calls())[email protected]("interactive", (False, True))def test_install_sh_opencode_does_not_shadow_external_v1(posix_harness: PosixHarness,+ interactive: bool,) -> None:- _assert_external_opencode_is_not_shadowed(posix_harness)+ _assert_external_opencode_is_not_shadowed(posix_harness, interactive)[email protected]("interactive", (False, True))def test_install_ps1_opencode_does_not_shadow_external_v1(powershell_harness: PowerShellHarness,+ interactive: bool,) -> None:- _assert_external_opencode_is_not_shadowed(powershell_harness)+ _assert_external_opencode_is_not_shadowed(powershell_harness, interactive)def _assert_opencode_validates_current_path(diff --git a/uv.lock b/uv.lockindex ce8b749d..d0013737 100644--- a/uv.lock+++ b/uv.lock@@ -599,7 +599,7 @@ wheels = [[[package]]name = "free-claude-code"-version = "6.2.46"+version = "6.2.47"source = { editable = "." }dependencies = [{ name = "aiohttp" },