let your agent control your phone
Install on any OS: Apple frameworks only on macOS, Android default elsewhere
ShawnPana3e211d1c8274
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlnew file mode 100644index 0000000..852537d--- /dev/null+++ b/.github/workflows/ci.yml@@ -0,0 +1,41 @@+# Installs on every OS and proves the Android path imports without Apple frameworks.+name: ci++on:+ pull_request:+ push:+ branches: [main]++jobs:+ install:+ strategy:+ fail-fast: false+ matrix:+ os: [ubuntu-latest, windows-latest, macos-latest]+ runs-on: ${{ matrix.os }}+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-python@v5+ with: { python-version: "3.12" }+ - run: python -m pip install .+ - name: the CLI runs and the Android backend imports without pyobjc+ run: |+ phone-harness skill > /dev/null+ python -c "import phone_harness.android, phone_harness.transport, phone_harness.config as c; print('default platform:', c.get('platform'))"+ - name: doctor names the adb install for this OS when adb is missing+ shell: bash+ run: |+ out=$(PHONE_HARNESS_PLATFORM=android phone-harness --doctor android 2>&1 || true)+ echo "$out"+ echo "$out" | grep -q "adb found"+ - name: iPhone is refused with a clear message off macOS+ if: runner.os != 'macOS'+ run: |+ python -c "+ import phone_harness.transport as t+ try:+ t.connect('ios'); raise SystemExit('expected a refusal')+ except RuntimeError as e:+ assert 'needs macOS' in str(e), e+ print('ok:', e)+ "diff --git a/README.md b/README.mdindex 092f9e4..1f921f7 100644--- a/README.md+++ b/README.md@@ -3,7 +3,8 @@**[phone-harness](https://phone-harness.com?utm_source=github&utm_medium=readme&utm_campaign=header)** · let your agent control your phone.Connect Claude Code, Codex, or any agent to your real phone. **iPhone** through-the Mac's iPhone Mirroring window, **Android** over adb. No jailbreak, no+the Mac's iPhone Mirroring window, **Android** over adb from macOS, Linux or+Windows. No jailbreak, noXcode, nothing installed on the phone. The agent sees the screen, taps, types,and reads the result.diff --git a/install.md b/install.mdindex b9c3519..63564a4 100644--- a/install.md+++ b/install.md@@ -10,7 +10,7 @@ either way; you choose a default and can switch per call.```bashgit clone https://github.com/ShawnPana/phone-harness ~/.phone-harness # canonical homecd ~/.phone-harness-pip install -e . # the global `phone-harness` command (pulls pyobjc)+pip install -e . # the global `phone-harness` command (pulls pyobjc on macOS only)# register as an agent skill so Claude Code / Codex reach for it automaticallymkdir -p ~/.claude/skills/phone-harness@@ -19,7 +19,9 @@ mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills/phone-harness"phone-harness skill > "${CODEX_HOME:-$HOME/.codex}/skills/phone-harness/SKILL.md"```-- Python 3.10+. Only the CLI? `pip install phone-harness` works too; the+- Python 3.10+, any OS. **iPhone needs a Mac** (it drives iPhone Mirroring);+ **Android works on macOS, Linux and Windows** and is the default off a Mac.+ Only the CLI? `pip install phone-harness` works too; thecheckout is what makes the harness editable (`agent-workspace/agent_helpers.py`).- The default phone is `phone-harness config set platform ios|android`;`phone-harness config` shows every setting and where it came from;@@ -51,8 +53,10 @@ the agent's copy matches the code.## Android-- `brew install android-platform-tools` (adb). Optional: `brew install scrcpy`- for a live mirror window during `phone-harness android awake`.+- adb: `brew install android-platform-tools` (macOS), `apt install adb` (Debian/Ubuntu),+ `winget install Google.PlatformTools` (Windows). Optional: `scrcpy` (`brew` /+ `apt` / `winget install Genymobile.scrcpy`) for a live mirror window during+ `phone-harness android awake`.- On the phone, once: Settings → About phone → tap **Build number** 7× →Settings → System → **Developer options**.- **USB**: Developer options → **USB debugging** on → plug in → tap **Allow**diff --git a/pyproject.toml b/pyproject.tomlindex 62a1821..3b2571d 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[project]name = "phone-harness"-version = "0.2.0"+version = "0.3.0"description = "Control a real iPhone through macOS iPhone Mirroring: OCR eyes, CGEvent hands"readme = "README.md"license = "MIT"@@ -15,10 +15,12 @@ classifiers = ["Topic :: Software Development :: Testing",]dependencies = [- "pyobjc-framework-Quartz",- "pyobjc-framework-Vision",- "pyobjc-framework-Cocoa",- "pyobjc-framework-ApplicationServices",+ # iPhone control (iPhone Mirroring, Vision OCR) needs macOS. Android is+ # plain adb and installs everywhere; these are skipped off macOS.+ "pyobjc-framework-Quartz; sys_platform == 'darwin'",+ "pyobjc-framework-Vision; sys_platform == 'darwin'",+ "pyobjc-framework-Cocoa; sys_platform == 'darwin'",+ "pyobjc-framework-ApplicationServices; sys_platform == 'darwin'",][project.urls]diff --git a/src/phone_harness/admin.py b/src/phone_harness/admin.pyindex cdb376c..890b762 100644--- a/src/phone_harness/admin.py+++ b/src/phone_harness/admin.py@@ -3,6 +3,7 @@ helpers would drive — the config default, or `--doctor ios|android`."""import osimport shutilimport subprocess+import sysimport tempfilefrom pathlib import Path@@ -98,16 +99,21 @@ def _doctor_ios():# --- Android: adb -> a phone -> authorised -> awake -> tree ------------------+_ADB_INSTALL = {"darwin": "brew install android-platform-tools",+ "win32": "winget install Google.PlatformTools"}.get(sys.platform, "apt install adb (or your distro's android-tools)")+_SCRCPY_INSTALL = {"darwin": "brew install scrcpy", "win32": "winget install Genymobile.scrcpy"}.get(sys.platform, "apt install scrcpy")++def _doctor_android():from . import configadb = str(config.get("android.adb"))if not shutil.which(adb):_check(f"adb found ({adb})", False,- "brew install android-platform-tools, or set android.adb to the binary")+ _ADB_INSTALL + ", or set android.adb to the binary")return_check(f"adb found ({shutil.which(adb)})", True)_check("scrcpy found (optional: live mirror during `android awake`)",- bool(shutil.which("scrcpy")), "brew install scrcpy — not required", fatal=False)+ bool(shutil.which("scrcpy")), _SCRCPY_INSTALL + " — not required", fatal=False)from . import androidphone = android.Android()diff --git a/src/phone_harness/config.py b/src/phone_harness/config.pyindex f6181f9..8a862d7 100644--- a/src/phone_harness/config.py+++ b/src/phone_harness/config.py@@ -33,7 +33,7 @@ from pathlib import PathVERSION = 1DEFAULTS = {- "platform": "ios",+ "platform": "ios" if sys.platform == "darwin" else "android", # iPhone needs a Mac"telemetry": True, # anonymous usage events; `config set telemetry false`"android": {"adb": "adb", # the binary; a path if it is not on PATHdiff --git a/src/phone_harness/transport.py b/src/phone_harness/transport.pyindex d93e20c..e27dac5 100644--- a/src/phone_harness/transport.py+++ b/src/phone_harness/transport.py@@ -74,6 +74,7 @@ supports(op) rather than guessing."""import importlibimport os+import sysclass Unsupported(RuntimeError):@@ -137,6 +138,10 @@ def connect(platform=None, **kw):from . import configplatform = (platform or config.get("platform")).lower()if platform in ("ios", "iphone", "ipad"):+ if sys.platform != "darwin":+ raise RuntimeError("iPhone control needs macOS (it drives the iPhone Mirroring app); "+ "on this machine use Android: PHONE_HARNESS_PLATFORM=android "+ "or `phone-harness config set platform android`")return importlib.import_module(".ios", __package__).IPhone(**kw)if platform == "android":return importlib.import_module(".android", __package__).Android(**kw)