mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-11-16 07:06:58 +08:00
## Why
Fixes #2092. Launching the macOS app through its shell wrapper replaces
the app executable with Python. AppKit then sees Python's bundle instead
of Free Claude Code, and the menu-bar item can have a zero-height window
even though pystray reports it visible.
## How
- Run the installed uv-managed Python runtime inside a native app
executable, preserving the app's bundle identity and main thread. Enable
UTF-8 and retain the tool environment for imports and child processes.
- Build arm64 and x86_64 launchers during release staging and include
both in the existing wheel and source distribution. Select the launcher
matching the installed Python architecture.
- Create and ad-hoc sign the app through a Python installer helper.
Validate its runtime, stage replacements, preserve foreign apps and
Desktop entries, and recognize existing FCC ownership markers during
upgrades and uninstall.
- Add native macOS coverage for bundle identity, visible menu-bar
geometry, server lifecycle, duplicate launches, child processes, and
reinstall. Add Windows and Linux source-distribution rebuild checks and
require these jobs in CI.
<!-- greptile_comment -->
<!-- greptile_summary -->
<h2><a
href="https://app.greptile.com/api/retrigger?id=81926736"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/alishahryar1/github/Alishahryar1/free-claude-code/-/pull/2095"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>
<!-- greptile-impact-verdict --> No outstanding findings prevent
merging.
<details open><summary><h3>Summary</h3></summary>
The PR replaces the macOS shell launcher with a native executable that
keeps Free Claude Code's app identity while running its installed Python
environment.
- The macOS app keeps its identity while running the desktop app.
- Release packages carry native launchers for both Mac architectures.
- CI checks the native Mac app on Intel and Apple silicon.
</details>
<!-- greptile_confidence_score:5 -->
<sub>Reviews (2) · Last reviewed commit: ["Restore POSIX uv reuse
regression
covera..."](b50bb8449e)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=alishahryar1/free-claude-code)</sub>
<!-- /greptile_comment -->
235 lines
6.1 KiB
PowerShell
235 lines
6.1 KiB
PowerShell
param(
|
|
[string[]] $Only = @(),
|
|
[string[]] $Skip = @(),
|
|
[switch] $DryRun,
|
|
[switch] $Help,
|
|
[Parameter(ValueFromRemainingArguments = $true)]
|
|
[object[]] $RemainingArgs = @()
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$CheckOrder = @(
|
|
"suppressions",
|
|
"ruff-format",
|
|
"ruff-check",
|
|
"ty",
|
|
"pytest",
|
|
"playwright",
|
|
"macos-desktop"
|
|
)
|
|
|
|
function Show-Usage {
|
|
@"
|
|
Usage: ci.ps1 [options]
|
|
|
|
Runs the local sequence for the same check IDs enforced by GitHub CI.
|
|
Requires uv on PATH when running ruff, ty, pytest, or Playwright checks.
|
|
Local ruff checks repair formatting and autofixable lint before later checks.
|
|
|
|
Checks (in order):
|
|
suppressions Ban type ignores and legacy future annotations
|
|
ruff-format uv run ruff format
|
|
ruff-check uv run ruff check --fix
|
|
ty uv run ty check
|
|
pytest uv run pytest -v --tb=short
|
|
playwright Install Chromium and run deterministic Admin browser tests
|
|
macos-desktop Build and test the native app (macOS GUI required, -Only)
|
|
|
|
Options:
|
|
-Only ID Run only the given check (repeatable)
|
|
-Skip ID Skip the given check (repeatable)
|
|
-DryRun Print commands without running them.
|
|
-Help Show this help text.
|
|
"@
|
|
}
|
|
|
|
function Write-Step {
|
|
param([string] $Message)
|
|
|
|
Write-Host ""
|
|
Write-Host "==> $Message"
|
|
}
|
|
|
|
function Format-Argument {
|
|
param([string] $Value)
|
|
|
|
if ($Value -match '^[A-Za-z0-9_./:@%+=,\[\]-]+$') {
|
|
return $Value
|
|
}
|
|
|
|
return "'" + ($Value -replace "'", "''") + "'"
|
|
}
|
|
|
|
function Invoke-CiCommand {
|
|
param(
|
|
[string] $FilePath,
|
|
[string[]] $Arguments = @()
|
|
)
|
|
|
|
$parts = @($FilePath) + $Arguments
|
|
$commandText = ($parts | ForEach-Object { Format-Argument ([string] $_) }) -join " "
|
|
Write-Host "+ $commandText"
|
|
|
|
if (-not $DryRun) {
|
|
& $FilePath @Arguments
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Command failed with exit code ${LASTEXITCODE}: $commandText"
|
|
}
|
|
}
|
|
}
|
|
|
|
function Test-ValidCheckId {
|
|
param([string] $CheckId)
|
|
|
|
return $CheckOrder -contains $CheckId
|
|
}
|
|
|
|
function Assert-ValidCheckId {
|
|
param([string] $CheckId)
|
|
|
|
if (-not (Test-ValidCheckId $CheckId)) {
|
|
throw "unknown check id: $CheckId (expected one of: $($CheckOrder -join ', '))"
|
|
}
|
|
}
|
|
|
|
function Test-ShouldRunCheck {
|
|
param([string] $CheckId)
|
|
|
|
if ($CheckId -eq "macos-desktop" -and $Only.Count -eq 0) {
|
|
return $false
|
|
}
|
|
|
|
if ($Only.Count -gt 0 -and ($Only -notcontains $CheckId)) {
|
|
return $false
|
|
}
|
|
|
|
if ($Skip -contains $CheckId) {
|
|
return $false
|
|
}
|
|
|
|
return $true
|
|
}
|
|
|
|
function Assert-UvAvailable {
|
|
if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
|
|
throw "uv is required but was not found on PATH. Install uv first (see README or scripts/install.ps1)."
|
|
}
|
|
}
|
|
|
|
function Test-SelectedChecksNeedUv {
|
|
if ($DryRun) {
|
|
return $false
|
|
}
|
|
|
|
foreach ($checkId in $CheckOrder) {
|
|
if ((Test-ShouldRunCheck $checkId) -and $checkId -ne "suppressions") {
|
|
return $true
|
|
}
|
|
}
|
|
|
|
return $false
|
|
}
|
|
|
|
function Invoke-SuppressionsCheck {
|
|
Write-Step "Ban suppressions and legacy annotations"
|
|
$pattern = '# type: ignore|# ty: ignore|from __future__ import annotations'
|
|
Write-Host "+ Get-ChildItem -Recurse -Filter *.py (excluding .venv, .git) | Select-String '$pattern'"
|
|
|
|
if (-not $DryRun) {
|
|
$matches = Get-ChildItem -Path . -Recurse -Filter *.py -File |
|
|
Where-Object {
|
|
$full = $_.FullName
|
|
$full -notmatch '[\\/]\.venv[\\/]' -and
|
|
$full -notmatch '[\\/]\.git[\\/]'
|
|
} |
|
|
Select-String -Pattern $pattern
|
|
|
|
if ($matches) {
|
|
$matches | ForEach-Object { Write-Host $_.Line }
|
|
throw "type: ignore / ty: ignore comments and legacy future annotations are not allowed. Fix the underlying type/import issue instead."
|
|
}
|
|
}
|
|
}
|
|
|
|
function Invoke-RuffFormatCheck {
|
|
Write-Step "ruff format"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "ruff", "format")
|
|
}
|
|
|
|
function Invoke-RuffLintCheck {
|
|
Write-Step "ruff check --fix"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "ruff", "check", "--fix")
|
|
}
|
|
|
|
function Invoke-TyCheck {
|
|
Write-Step "ty check"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "ty", "check")
|
|
}
|
|
|
|
function Invoke-PytestCheck {
|
|
Write-Step "pytest"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "pytest", "-v", "--tb=short")
|
|
}
|
|
|
|
function Invoke-PlaywrightCheck {
|
|
Write-Step "playwright"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "playwright", "install", "chromium")
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @(
|
|
"run", "pytest", "e2e", "-v", "--tb=short",
|
|
"--tracing=retain-on-failure", "--screenshot=only-on-failure",
|
|
"--full-page-screenshot", "--output=test-results"
|
|
)
|
|
}
|
|
|
|
function Invoke-Check {
|
|
param([string] $CheckId)
|
|
|
|
switch ($CheckId) {
|
|
"suppressions" { Invoke-SuppressionsCheck }
|
|
"ruff-format" { Invoke-RuffFormatCheck }
|
|
"ruff-check" { Invoke-RuffLintCheck }
|
|
"ty" { Invoke-TyCheck }
|
|
"pytest" { Invoke-PytestCheck }
|
|
"playwright" { Invoke-PlaywrightCheck }
|
|
"macos-desktop" {
|
|
Write-Step "macOS desktop"
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "--locked", "python", "scripts/build_macos_launcher.py")
|
|
Invoke-CiCommand -FilePath "uv" -Arguments @("run", "--locked", "pytest", "--confcutdir=smoke/desktop", "-n", "0", "-s", "-v", "smoke/desktop")
|
|
}
|
|
default { throw "unknown check id: $CheckId" }
|
|
}
|
|
}
|
|
|
|
if ($Help) {
|
|
Show-Usage
|
|
return
|
|
}
|
|
|
|
if ($RemainingArgs.Count -gt 0) {
|
|
Show-Usage
|
|
throw "Unknown option: $($RemainingArgs -join ' ')"
|
|
}
|
|
|
|
foreach ($checkId in $Only) {
|
|
Assert-ValidCheckId $checkId
|
|
}
|
|
|
|
foreach ($checkId in $Skip) {
|
|
Assert-ValidCheckId $checkId
|
|
}
|
|
|
|
if (Test-SelectedChecksNeedUv) {
|
|
Assert-UvAvailable
|
|
}
|
|
|
|
foreach ($checkId in $CheckOrder) {
|
|
if (Test-ShouldRunCheck $checkId) {
|
|
Invoke-Check $checkId
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "All selected CI checks passed."
|