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: bind updates to the selected FCC release (#2076)
FengCi261ecf7a181d
diff --git a/README.md b/README.mdindex a5752c15..974eebc8 100644--- a/README.md+++ b/README.md@@ -478,6 +478,8 @@ Stop all running FCC commands, then run:fcc-update```+The update installs the checked stable FCC release with its matching installer.+To reinstall FCC or change optional components while already up to date, run the [installer](#install) directly.For local voice support, include `--voice-local` (macOS/Linux) or `-VoiceLocal` (Windows), plus your `--torch-backend` or `-TorchBackend` option if used.diff --git a/scripts/install.ps1 b/scripts/install.ps1index 456e5435..73aef607 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -43,6 +43,7 @@ $script:InstallAider = $true$script:PiAvailable = $false$script:MuseAvailable = $false$script:EnableRtkHeadroom = $RtkHeadroom.IsPresent+$FccInstallVersion = [Environment]::GetEnvironmentVariable("FCC_INSTALL_VERSION")$script:InstallLog = ""$script:InstallLogWarning = $false$script:InstallSteps = [ordered] @{}@@ -153,13 +154,19 @@ function Start-InstallStep {function Get-InstallerRetryCommand {$options = @()+ $prefix = ""+ $installerRef = "main"+ if ($FccInstallVersion) {+ $prefix = "`$env:FCC_INSTALL_VERSION = '$FccInstallVersion'; "+ $installerRef = "v$FccInstallVersion"+ }if ($VoiceLocal) { $options += "-VoiceLocal" }if ($TorchBackend) { $options += @("-TorchBackend", $TorchBackend) }if ($script:EnableRtkHeadroom) { $options += "-RtkHeadroom" }if ($script:InstallerPath -and (Test-Path -LiteralPath $script:InstallerPath -PathType Leaf)) {- return "& " + (Format-Command $script:InstallerPath $options)+ return $prefix + "& " + (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 " ")+ return $prefix + "& ([scriptblock]::Create((irm 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/$installerRef/scripts/install.ps1'))) " + (($options | ForEach-Object { Format-Argument $_ }) -join " ")}function Show-InstallReport {@@ -1656,10 +1663,9 @@ function Ensure-Uv {}function Get-PackageSpec {- if ($VoiceLocal) {- return "free-claude-code[voice_local]"- }- return "free-claude-code"+ $spec = if ($VoiceLocal) { "free-claude-code[voice_local]" } else { "free-claude-code" }+ if ($FccInstallVersion) { $spec += "==$FccInstallVersion" }+ return $spec}function Install-FreeClaudeCode {@@ -1893,6 +1899,10 @@ if ($RemainingArgs.Count -gt 0) {throw "Unknown option: $($RemainingArgs -join ' ')"}+if ($FccInstallVersion -and $FccInstallVersion -notmatch '\A(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\z') {+ throw "FCC_INSTALL_VERSION must be a canonical major.minor.patch release."+}+if ((-not [string]::IsNullOrWhiteSpace($TorchBackend)) -and (-not $VoiceLocal)) {throw "-TorchBackend requires -VoiceLocal."}diff --git a/scripts/install.sh b/scripts/install.shindex 20c0c5b9..b2843c76 100644--- a/scripts/install.sh+++ b/scripts/install.sh@@ -23,6 +23,7 @@ FCC_COMMANDS="fcc-desktop fcc-server fcc-claude fcc-codex fcc-pi fcc-opencode fcdry_run=0voice_local=0+fcc_install_version=${FCC_INSTALL_VERSION:-}install_claude=1install_codex=1install_pi=1@@ -137,10 +138,23 @@ start_install_step() {print_installer_retry() {printf 'Retry: 'if [ -f "$installer_path" ]; then+ if [ -n "$fcc_install_version" ]; then+ printf 'FCC_INSTALL_VERSION='+ shell_quote "$fcc_install_version"+ printf ' '+ fiprintf 'sh 'shell_quote "$installer_path"else- printf '%s' "curl -fsSL 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.sh' | sh -s --"+ installer_ref=main+ [ -z "$fcc_install_version" ] || installer_ref="v$fcc_install_version"+ printf "curl -fsSL 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/%s/scripts/install.sh' | " "$installer_ref"+ if [ -n "$fcc_install_version" ]; then+ printf 'FCC_INSTALL_VERSION='+ shell_quote "$fcc_install_version"+ printf ' '+ fi+ printf 'sh -s --'fi[ "$voice_local" -eq 0 ] || printf ' --voice-local'if [ -n "$torch_backend" ]; then@@ -1487,6 +1501,13 @@ parse_args() {}validate_args() {+ if [ -n "$fcc_install_version" ]; then+ case "$fcc_install_version" in+ *[!0-9.]*) fail "FCC_INSTALL_VERSION must be a canonical major.minor.patch release." ;;+ esac+ printf '%s\n' "$fcc_install_version" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' ||+ fail "FCC_INSTALL_VERSION must be a canonical major.minor.patch release."+ fiif [ -n "$torch_backend" ] && [ "$voice_local" -ne 1 ]; thenfail "--torch-backend requires --voice-local."fi@@ -1498,6 +1519,7 @@ package_spec() {elseprintf '%s' 'free-claude-code'fi+ [ -z "$fcc_install_version" ] || printf '==%s' "$fcc_install_version"}install_free_claude_code() {diff --git a/scripts/update/fcc-update b/scripts/update/fcc-updateindex b7709519..a46a44a3 100644--- a/scripts/update/fcc-update+++ b/scripts/update/fcc-update@@ -1,11 +1,18 @@#!/bin/shset -eustatus=0-"$(dirname "$0")/_fcc-update-check" || status=$?+release_version=$("$(dirname "$0")/_fcc-update-check" --print-version) || status=$?case "$status" in0) exit 0 ;;10) ;;*) exit "$status" ;;esac-installer=$(curl -fsSL "https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.sh")-exec sh -c "$installer" sh "$@"+case "$release_version" in+ ''|*[!0-9.]*) printf 'error: Invalid FCC update version.\n' >&2; exit 1 ;;+esac+if ! printf '%s\n' "$release_version" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'; then+ printf 'error: Invalid FCC update version.\n' >&2+ exit 1+fi+installer=$(curl -fsSL "https://raw.githubusercontent.com/Alishahryar1/free-claude-code/v$release_version/scripts/install.sh")+FCC_INSTALL_VERSION=$release_version exec sh -c "$installer" sh "$@"diff --git a/scripts/update/fcc-update.cmd b/scripts/update/fcc-update.cmdindex 85f06c4d..90c44cd8 100644--- a/scripts/update/fcc-update.cmd+++ b/scripts/update/fcc-update.cmd@@ -1,8 +1,7 @@@echo off-"%~dp0_fcc-update-check.exe"-if %errorlevel%==0 exit /b 0-if not %errorlevel%==10 exit /b %errorlevel%+setlocal+set "FCC_UPDATE_CHECKER=%~dp0_fcc-update-check.exe"(- powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference = 'Stop'; & ([scriptblock]::Create((Invoke-RestMethod 'https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install.ps1')))" %*+ powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference = 'Continue'; $release = & $env:FCC_UPDATE_CHECKER --print-version; $status = $LASTEXITCODE; $ErrorActionPreference = 'Stop'; if ($status -isnot [int]) { throw 'FCC update preflight could not run.' }; if ($status -eq 0) { exit 0 }; if ($status -ne 10) { exit $status }; if ($release -isnot [string] -or $release -notmatch '\A(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\z') { throw 'Invalid FCC update version.' }; $env:FCC_INSTALL_VERSION = $release; & ([scriptblock]::Create((Invoke-RestMethod ('https://raw.githubusercontent.com/Alishahryar1/free-claude-code/v' + $release + '/scripts/install.ps1'))))" %*call exit /b %%errorlevel%%)diff --git a/smoke/installers/test_installers.py b/smoke/installers/test_installers.pyindex 5988c49b..1646550a 100644--- a/smoke/installers/test_installers.py+++ b/smoke/installers/test_installers.py@@ -46,6 +46,83 @@ CODING_AGENTS = ()[email protected]("voice", [False, True])+def test_install_sh_pins_selected_fcc_release(posix_harness, voice):+ posix_harness.env["FCC_INSTALL_VERSION"] = "2.0.0"+ posix_harness.add_uv("0.12.13")+ result = posix_harness.run_functions(+ f"voice_local={int(voice)}\nvalidate_args\ninstall_free_claude_code\ninstaller_path=''\nprint_installer_retry"+ )+ assert result.returncode == 0, result.stdout + result.stderr+ spec = (+ "free-claude-code[voice_local]==2.0.0" if voice else "free-claude-code==2.0.0"+ )+ assert any(call.endswith(spec) for call in posix_harness.calls())+ assert "/v2.0.0/scripts/install.sh" in result.stdout+ assert "FCC_INSTALL_VERSION=" in result.stdout++[email protected]("voice", [False, True])+def test_install_ps1_pins_selected_fcc_release(powershell_harness, voice):+ powershell_harness.env["FCC_INSTALL_VERSION"] = "2.0.0"+ powershell_harness.add_uv("0.12.13")+ result = powershell_harness.run_functions(+ "Install-FreeClaudeCode\n$script:InstallerPath = ''\nWrite-Output (Get-InstallerRetryCommand)",+ *(["-VoiceLocal"] if voice else []),+ )+ assert result.returncode == 0, result.stdout + result.stderr+ spec = (+ "free-claude-code[voice_local]==2.0.0" if voice else "free-claude-code==2.0.0"+ )+ assert any(call.endswith(spec) for call in powershell_harness.calls())+ assert "/v2.0.0/scripts/install.ps1" in result.stdout+ assert "$env:FCC_INSTALL_VERSION = '2.0.0'" in result.stdout+++ "version",+ [+ "2.0",+ "v2.0.0",+ "02.0.0",+ "2.0.0rc1",+ "2.0.0+local",+ "2.0.0\n3.0.0",+ "2.0.0/../main",+ ],+)+def test_install_sh_rejects_invalid_fcc_release_before_changes(posix_harness, version):+ posix_harness.env["FCC_INSTALL_VERSION"] = version+ result = posix_harness.run("--dry-run")+ assert result.returncode != 0+ assert "FCC_INSTALL_VERSION" in result.stderr+ assert posix_harness.calls() == []+ assert not (Path(posix_harness.env["HOME"]) / ".fcc/logs").exists()+++ "version",+ [+ "2.0",+ "v2.0.0",+ "02.0.0",+ "2.0.0rc1",+ "2.0.0+local",+ "2.0.0\n3.0.0",+ "2.0.0/../main",+ ],+)+def test_install_ps1_rejects_invalid_fcc_release_before_changes(+ powershell_harness, version+):+ powershell_harness.env["FCC_INSTALL_VERSION"] = version+ result = powershell_harness.run("-DryRun")+ assert result.returncode != 0+ assert "FCC_INSTALL_VERSION" in result.stderr+ assert powershell_harness.calls() == []+ assert not (Path(powershell_harness.env["USERPROFILE"]) / ".fcc/logs").exists()++def test_install_ps1_bundle_dry_run_includes_headroom(powershell_harness):result = powershell_harness.run("-RtkHeadroom", "-DryRun")assert result.returncode == 0, result.stderrdiff --git a/src/free_claude_code/updater/check.py b/src/free_claude_code/updater/check.pyindex d2d6368d..07b621c3 100644--- a/src/free_claude_code/updater/check.py+++ b/src/free_claude_code/updater/check.py@@ -1,5 +1,7 @@"""Standalone version preflight for the native update launchers."""+import argparse+import reimport sysfrom importlib.metadata import PackageNotFoundError, version@@ -10,8 +12,11 @@ PYPI_URL = "https://pypi.org/pypi/free-claude-code/json"UPDATE_AVAILABLE = 10-def main() -> int:+def main(argv: list[str] | None = None) -> int:"""Return 10 to authorize installation, 0 to skip, or 1 on check failure."""+ parser = argparse.ArgumentParser(prog="_fcc-update-check")+ parser.add_argument("--print-version", action="store_true")+ arguments = parser.parse_args(argv)try:installed = Version(version("free-claude-code"))if str(installed) == "0+unknown":@@ -20,15 +25,19 @@ def main() -> int:response = client.get(PYPI_URL)response.raise_for_status()metadata = response.json()- latest = Version(metadata["info"]["version"])- files = metadata["urls"]+ published = metadata["info"]["version"]if (- latest.is_prerelease- or latest.is_devrelease- or not isinstance(files, list)- or not any(- isinstance(file, dict) and file.get("yanked") is False for file in files+ not isinstance(published, str)+ or re.fullmatch(+ r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)", published)+ is None+ ):+ raise ValueError("PyPI did not return a canonical FCC release version")+ latest = Version(published)+ files = metadata["urls"]+ if not isinstance(files, list) or not any(+ isinstance(file, dict) and file.get("yanked") is False for file in files):raise ValueError("PyPI did not return an available stable FCC release")except (@@ -41,13 +50,20 @@ def main() -> int:print(f"Could not check for FCC updates: {exc}. Please retry.", file=sys.stderr)return 1+ output = sys.stderr if arguments.print_version else sys.stdoutif installed == latest:- print(f"FCC {installed} is already up to date.")+ print(f"FCC {installed} is already up to date.", file=output)return 0if installed > latest:print(- f"FCC {installed} is newer than the published version {latest}. No update needed."+ f"FCC {installed} is newer than the published version {latest}. No update needed.",+ file=output,)return 0- print(f"FCC update available: {installed} -> {latest}. Running the installer.")+ print(+ f"FCC update available: {installed} -> {latest}. Running the installer.",+ file=output,+ )+ if arguments.print_version:+ print(published)return UPDATE_AVAILABLEdiff --git a/tests/cli/test_update_check.py b/tests/cli/test_update_check.pyindex edeb5c62..965c0887 100644--- a/tests/cli/test_update_check.py+++ b/tests/cli/test_update_check.py@@ -16,7 +16,14 @@ def release(version="1.10.0", *, yanked=False):def check(monkeypatch):original_client = httpx.Client- def run(installed="1.9.0", payload=None, status=200, error=None, body=None):+ def run(+ installed="1.9.0",+ payload=None,+ status=200,+ error=None,+ body=None,+ print_version=False,+ ):monkeypatch.setattr(update_check, "version", lambda name: installed)def respond(request):@@ -34,7 +41,7 @@ def check(monkeypatch):transport=httpx.MockTransport(respond), **kwargs),)- return update_check.main()+ return update_check.main(["--print-version"] if print_version else [])return run@@ -65,6 +72,13 @@ def test_version_comparison(check, capsys, installed, expected):release("invalid"),release("2.0rc1"),release("2.0.dev1"),+ release("2.0"),+ release("v2.0.0"),+ release("02.0.0"),+ release("2.0.0.post1"),+ release("2.0.0+local"),+ release("2.0.0\n3.0.0"),+ release("2.0.0/../main"),release(yanked=True),{"info": {"version": "2.0"}, "urls": []},{"info": {"version": "2.0"}, "urls": [{}]},@@ -85,7 +99,7 @@ def test_missing_distribution(monkeypatch, capsys):raise PackageNotFoundError(name)monkeypatch.setattr(update_check, "version", missing)- assert update_check.main() == 1+ assert update_check.main([]) == 1assert capsys.readouterr().err@@ -102,3 +116,19 @@ def test_timeout(check, capsys):def test_malformed_json(check, capsys):assert check(body="not JSON") == 1assert capsys.readouterr().err++[email protected]("installed", ["1.9.0", "1.10.0", "1.11.0"])+def test_print_version_is_only_the_authorized_release(check, capsys, installed):+ expected = 10 if installed == "1.9.0" else 0+ assert check(installed, release(), print_version=True) == expected+ output = capsys.readouterr()+ assert output.out == ("1.10.0\n" if expected == 10 else "")+ assert installed in output.err+++def test_failed_preflight_prints_no_release(check, capsys):+ assert check(payload=release("2.0.0/../main"), print_version=True) == 1+ output = capsys.readouterr()+ assert output.out == ""+ assert output.errdiff --git a/tests/cli/test_update_wrapper.py b/tests/cli/test_update_wrapper.pyindex 43d41e6e..4237fac3 100644--- a/tests/cli/test_update_wrapper.py+++ b/tests/cli/test_update_wrapper.py@@ -14,7 +14,7 @@ from pathlib import Pathimport pytestROOT = Path(__file__).resolve().parents[2]-INSTALL_URL = "https://raw.githubusercontent.com/Alishahryar1/free-claude-code/main/scripts/install"+RELEASE_URL = "https://raw.githubusercontent.com/Alishahryar1/free-claude-code"SCRIPTS = ("fcc-update", "fcc-update.cmd")@@ -29,7 +29,7 @@ def installer_server(body, status, outcome):response_status = statusif self.path == "/metadata":version = {"current": "1.0.0", "newer-installed": "0.9.0"}.get(- outcome, "2.0.0"+ outcome, "2.0.0rc1" if outcome == "invalid-release" else "2.0.0")payload = json.dumps({"info": {"version": version}, "urls": [{"yanked": False}]}@@ -50,14 +50,14 @@ def installer_server(body, status, outcome):)thread.start()try:- yield f"http://127.0.0.1:{server.server_port}/install", requests+ yield f"http://127.0.0.1:{server.server_port}", requestsfinally:server.shutdown()server.server_close()thread.join()-def fixture_wheel(area, url):+def fixture_wheel(area, url, outcome):wheel = area / "free_claude_code-1.0.0-py3-none-any.whl"dist = "free_claude_code-1.0.0"with zipfile.ZipFile(wheel, "w") as archive:@@ -73,7 +73,7 @@ def fixture_wheel(area, url):for name in SCRIPTS:source = (ROOT / "scripts/update" / name).read_text(encoding="utf-8")archive.writestr(- f"{dist}.data/scripts/{name}", source.replace(INSTALL_URL, url)+ f"{dist}.data/scripts/{name}", source.replace(RELEASE_URL, url))archive.writestr(f"{dist}.dist-info/entry_points.txt",@@ -81,11 +81,26 @@ def fixture_wheel(area, url):)for name in ("__init__.py", "updater/__init__.py", "updater/check.py"):source = (ROOT / "src/free_claude_code" / name).read_text(encoding="utf-8")+ if (+ name == "updater/check.py"+ and outcome.startswith("checker-")+ and outcome != "checker-missing"+ ):+ invalid = {+ "checker-invalid": "2.0.0/../main",+ "checker-multiline": "2.0.0\n3.0.0",+ "checker-empty": "",+ "checker-exit": "2.0.0",+ }[outcome]+ exit_code = 37 if outcome == "checker-exit" else 10+ source = (+ f"def main():\n print({invalid!r})\n return {exit_code}\n"+ )archive.writestr(f"free_claude_code/{name}",source.replace("https://pypi.org/pypi/free-claude-code/json",- url.removesuffix("/install") + "/metadata",+ url + "/metadata",),)archive.writestr(@@ -106,6 +121,12 @@ def fixture_wheel(area, url):"current","newer-installed","check-error",+ "invalid-release",+ "checker-invalid",+ "checker-multiline",+ "checker-empty",+ "checker-exit",+ "checker-missing",],)def test_installed_update_delegates_and_survives_replacement(tmp_path, outcome):@@ -120,6 +141,7 @@ def test_installed_update_delegates_and_survives_replacement(tmp_path, outcome):UV_TOOL_BIN_DIR=str(area / "bin"),UV_NO_CONFIG="1",UV_PYTHON_DOWNLOADS="never",+ FCC_INSTALL_VERSION="9.9.9",FCC_TEST_LAUNCHER=str(area / "bin" / ("fcc-update.cmd" if os.name == "nt" else "fcc-update")),@@ -132,12 +154,12 @@ def test_installed_update_delegates_and_survives_replacement(tmp_path, outcome):if os.name == "nt":body = """param([switch] $VoiceLocal, [string] $TorchBackend)$answer = Read-Host 'Continue'-Write-Output "installer:$VoiceLocal|$TorchBackend|$answer"+Write-Output "installer:$VoiceLocal|$TorchBackend|$answer|$env:FCC_INSTALL_VERSION"[IO.File]::WriteAllText($env:FCC_TEST_LAUNCHER, 'exit /b 99')[IO.File]::WriteAllText($env:FCC_TEST_CHECKER, 'replaced after checker exited')"""arguments = "-VoiceLocal -TorchBackend cu130"- expected = "installer:True|cu130|yes"+ expected = "installer:True|cu130|yes|2.0.0"body += {"success": "","exit": "exit 23",@@ -146,12 +168,12 @@ Write-Output "installer:$VoiceLocal|$TorchBackend|$answer"}.get(outcome, "")else:body = """read -r answer-printf 'installer:%s|%s|%s|%s\\n' "$1" "$2" "$3" "$answer"+printf 'installer:%s|%s|%s|%s|%s\\n' "$1" "$2" "$3" "$answer" "$FCC_INSTALL_VERSION"printf 'exit 99\\n' > "$FCC_TEST_LAUNCHER"printf 'replaced after checker exited' > "$FCC_TEST_CHECKER""""arguments = ["--voice-local", "--torch-backend", "cu130"]- expected = "installer:--voice-local|--torch-backend|cu130|yes"+ expected = "installer:--voice-local|--torch-backend|cu130|yes|2.0.0"body += {"success": "","exit": "exit 23",@@ -164,7 +186,7 @@ printf 'replaced after checker exited' > "$FCC_TEST_CHECKER"url,requests,):- wheel = fixture_wheel(area, url)+ wheel = fixture_wheel(area, url, outcome)result = subprocess.run([uv,@@ -179,6 +201,8 @@ printf 'replaced after checker exited' > "$FCC_TEST_CHECKER"timeout=90,)assert result.returncode == 0, result.stderr+ if outcome == "checker-missing":+ Path(env["FCC_TEST_CHECKER"]).unlink()launcher = env["FCC_TEST_LAUNCHER"]command = (f'"{os.environ.get("COMSPEC", "cmd.exe")}" /d /s /c ""{launcher}" {arguments}"'@@ -194,12 +218,25 @@ printf 'replaced after checker exited' > "$FCC_TEST_CHECKER"text=True,timeout=30,)- skipped = outcome in {"current", "newer-installed", "check-error"}- assert requests == ["/metadata"] + (- [] if skipped else ["/install.ps1" if os.name == "nt" else "/install.sh"]+ skipped = outcome in {+ "current",+ "newer-installed",+ "check-error",+ "invalid-release",+ } or outcome.startswith("checker-")+ assert requests == ([] if outcome.startswith("checker-") else ["/metadata"]) + (+ []+ if skipped+ else [f"/v2.0.0/scripts/install.{'ps1' if os.name == 'nt' else 'sh'}"]), result.stdout + result.stderrif skipped:- assert result.returncode == (1 if outcome == "check-error" else 0)+ expected_exit = 37 if outcome == "checker-exit" else 1+ if outcome in {"current", "newer-installed"}:+ expected_exit = 0+ if outcome == "checker-missing":+ assert result.returncode != 0+ else:+ assert result.returncode == expected_exitassert "installer:" not in result.stdoutelif outcome == "download-error":assert result.returncode != 0