Skip to content

let your agent control your phone

Document a uv tool install as the normal setup path. (#120)

shawn pana5a119c727895
diff --git a/README.md b/README.md
index b21f17e..c405957 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ https://github.com/user-attachments/assets/80b6d38e-0222-481c-93db-9de60d79247a
Paste into Claude Code or Codex:
```text
-Set up phone-harness for me. Clone https://github.com/ShawnPana/phone-harness into ~/.phone-harness, read `install.md` first, install it so `phone-harness` is a command on my PATH, and register it as an agent skill named phone-harness using `phone-harness skill` as the body. Then read `onboarding.md` and walk me through it.
+Install or upgrade phone-harness to the latest stable version with uv using Python 3.12, register the skill from `phone-harness skill`, then read https://github.com/ShawnPana/phone-harness/blob/main/onboarding.md and walk me through it. Follow https://github.com/ShawnPana/phone-harness/blob/main/install.md if setup or connection fails.
```
The agent asks which phone is your default and walks you through the parts
@@ -63,11 +63,11 @@ phone-harness --version
Helpers are pre-imported. [SKILL.md](SKILL.md) is the agent's day-to-day
guide; [helpers.py](src/phone_harness/helpers.py) is the full list.
-Task-specific helpers live in `agent-workspace/agent_helpers.py` in a
-checkout. A pip or uv install uses `~/.phone-harness/agent-workspace`
-(see [install.md](install.md)), creates it from the packaged defaults
-when it is missing, and never overwrites an existing one. Delete that
-folder for a fresh default; the next run recreates it.
+Task-specific helpers live in `~/.phone-harness/agent-workspace`
+(see [install.md](install.md)). The first run creates that folder from
+the packaged defaults and never overwrites an existing one. Delete the
+folder for a fresh default; the next run recreates it. A checkout uses
+its own `agent-workspace/` instead.
## No phone on your desk? Rent one
diff --git a/SKILL.md b/SKILL.md
index ba69ecb..1007cb8 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -114,11 +114,11 @@ PY
4. When a check fails, isolate: re-run that one action, look at the screen,
form one guess, test it. Do not re-run the batch hoping it lands.
5. Keep what you learn in the agent workspace's `agent_helpers.py`.
- A checkout uses `agent-workspace/`. A pip or uv install uses
- `~/.phone-harness/agent-workspace`, or
+ A pip or uv install uses `~/.phone-harness/agent-workspace`, or
`~/.local/share/phone-harness/agent-workspace` when
`~/.phone-harness` is a git checkout, so an upgrade does not wipe
- it. `PH_AGENT_WORKSPACE` overrides that path. The directory is
+ it. A checkout of this repo uses its own `agent-workspace/`.
+ `PH_AGENT_WORKSPACE` overrides that path. The directory is
created from the defaults only when it is missing. An existing
workspace is never overwritten. To get a fresh default, delete the
workspace folder; it is recreated on the next run.
@@ -352,8 +352,8 @@ Trust `GET /ops` when the host's list is shorter than this table.
button. `shell()` is Unsupported.
- **Confirm `open_app`.** It sends `apps.launch` and can return with the app
still not in front. Check with `screen()` or a screenshot. If it missed,
- `home()` and tap the icon. `tap_icon()` in
- `agent-workspace/agent_helpers.py` aims 35 points above the label for the
+ `home()` and tap the icon. `tap_icon()` in the agent workspace's
+ `agent_helpers.py` aims 35 points above the label for the
mirroring window, so measure this phone's icon yourself.
## Android
@@ -509,13 +509,15 @@ events into it for hands. All coordinates are global macOS screen points.
actually happened on screen rather than assuming the event arrived.
For task-specific edits, use the agent workspace's `agent_helpers.py`:
-`agent-workspace/` in a checkout, `~/.phone-harness/agent-workspace` for
-a pip or uv install (or `~/.local/share/phone-harness/agent-workspace`
-when `~/.phone-harness` is a git checkout). `PH_AGENT_WORKSPACE`
-overrides that. Installs seed that directory from the packaged defaults
-when it does not exist yet; an existing workspace is left as it is.
-To get a fresh default, delete the workspace folder; it is recreated
-on the next run. For setup or permission problems, read `install.md`.
+`~/.phone-harness/agent-workspace` for a pip or uv install (or
+`~/.local/share/phone-harness/agent-workspace` when `~/.phone-harness`
+is a git checkout). A checkout of this repo uses its own
+`agent-workspace/`. `PH_AGENT_WORKSPACE` overrides that. Installs seed
+that directory from the packaged defaults when it does not exist yet;
+an existing workspace is left as it is. To get a fresh default, delete
+the workspace folder; it is recreated on the next run. For setup or
+permission problems, read
+https://github.com/ShawnPana/phone-harness/blob/main/install.md.
## Updates
diff --git a/install.md b/install.md
index 75a06c0..db8a39b 100644
--- a/install.md
+++ b/install.md
@@ -1,63 +1,95 @@
# phone-harness install
-phone-harness drives a real phone (first-run flow for agents: `onboarding.md`;
-day-to-day usage: `SKILL.md`). It works with an **iPhone** through the macOS
-iPhone Mirroring app, an **Android** over adb (USB or Wi‑Fi), or a phone from
-Phone Harness Cloud — an Android over adb, or an iPhone the helpers drive over
-HTTPS (`phone-harness cloud start` with that phone's name from `cloud ls`).
-Same helpers either way; you
-choose a default and can switch per call. Reading on-screen text is
-`screen()`; the helper names and signatures are in `SKILL.md`.
+phone-harness drives a real phone. First-run flow for agents:
+https://github.com/ShawnPana/phone-harness/blob/main/onboarding.md.
+Day-to-day usage is `phone-harness skill`. It works with an **iPhone**
+through the macOS iPhone Mirroring app, an **Android** over adb (USB or
+Wi‑Fi), or a phone from Phone Harness Cloud — an Android over adb, or an
+iPhone the helpers drive over HTTPS (`phone-harness cloud start` with that
+phone's name from `cloud ls`). Same helpers either way; you choose a
+default and can switch per call. Reading on-screen text is `screen()`;
+the helper names and signatures are in the skill (`SKILL.md`, printed by
+`phone-harness skill`).
+
+## Fast Path
-## Common
+```bash
+uv tool install --python 3.12 --upgrade --force phone-harness
+```
+
+Needs [uv](https://docs.astral.sh/uv/) and Python 3.12. The package itself
+accepts Python 3.10 or newer. **iPhone Mirroring needs a Mac.** A cloud
+iPhone (`cloud start` of the iOS catalog entry) is driven over HTTPS from
+any OS. **Android works on macOS, Linux and Windows** and is the default
+off a Mac.
+
+Register the skill so the agent reaches for it:
```bash
-git clone https://github.com/ShawnPana/phone-harness ~/.phone-harness # canonical home
-cd ~/.phone-harness
-pip install -e . # the global `phone-harness` command (pulls pyobjc on macOS only)
+# Codex
+mkdir -p ${CODEX_HOME:-$HOME/.codex}/skills/phone-harness && phone-harness skill > ${CODEX_HOME:-$HOME/.codex}/skills/phone-harness/SKILL.md
+```
+
+Claude Code and other agents: register a skill named phone-harness with
+`phone-harness skill` as the body plus a short trigger sentence (for
+example, "Use this when the task needs the user's phone.").
-# register as an agent skill so Claude Code / Codex reach for it automatically
-mkdir -p ~/.claude/skills/phone-harness
-phone-harness skill > ~/.claude/skills/phone-harness/SKILL.md
-mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills/phone-harness"
-phone-harness skill > "${CODEX_HOME:-$HOME/.codex}/skills/phone-harness/SKILL.md"
+Quick check:
+
+```bash
+phone-harness <<'PY'
+ensure_device()
+PY
```
-- Python 3.10+, any OS. **iPhone Mirroring needs a Mac.** A cloud iPhone
- (`cloud start` of the iOS catalog entry) is driven over HTTPS from any OS.
- **Android works on macOS, Linux and Windows** and is the default off a Mac.
- Only the CLI? `pip install phone-harness` works too. Helpers you add
- live outside the install, so an upgrade does not wipe them. The
- directory is `~/.phone-harness/agent-workspace`, unless
- `~/.phone-harness` is a git checkout (the clone above), in which case
- it is `~/.local/share/phone-harness/agent-workspace` (`XDG_DATA_HOME`
- if that is set). The same paths are used on every OS. A checkout of
- this repo keeps using its own `agent-workspace/`. `PH_AGENT_WORKSPACE`
- overrides all of these. The first run copies the packaged defaults
- when that directory does not exist. An existing workspace is left
- untouched, including a custom `agent_helpers.py`. To get a fresh
- default, delete the workspace folder; it is recreated on the next run.
+That reaches the default phone. If it fails, use the sections below.
+
+- Helpers you add live in `~/.phone-harness/agent-workspace`, outside the
+ install, so an upgrade does not wipe them. When `~/.phone-harness` is a
+ git checkout, they live in
+ `~/.local/share/phone-harness/agent-workspace` (`XDG_DATA_HOME` if that
+ is set). The same paths are used on every OS. `PH_AGENT_WORKSPACE`
+ overrides these. The first run copies the packaged defaults when that
+ directory does not exist. An existing workspace is left untouched,
+ including a custom `agent_helpers.py`. To get a fresh default, delete
+ the workspace folder; it is recreated on the next run.
- The default phone is `phone-harness config set platform ios|android`;
`phone-harness config` shows every setting and where it came from;
`PHONE_HARNESS_PLATFORM=android phone-harness …` overrides for one call.
- `phone-harness --doctor` checks the default phone; `--doctor ios` or
`--doctor android` checks the other.
-
-Re-run the `phone-harness skill > …/SKILL.md` lines after pulling updates so
-the agent's copy matches the code. `phone-harness update` does the upgrade:
-`uv tool upgrade phone-harness` when this is a uv tool, `git pull --ff-only`
-in a checkout, otherwise it prints `pip install -U phone-harness` and does
-not run it. It never updates on its own. A newer PyPI release is one stderr
-line, at most once a day, and only on a terminal;
-`PHONE_HARNESS_NO_UPDATE_CHECK=1` skips the check.
+- Re-run the skill registration after `phone-harness update` so the
+ agent's copy matches the code. `phone-harness update` does the upgrade:
+ `uv tool upgrade phone-harness` when this is a uv tool, `git pull
+ --ff-only` in a checkout, otherwise it prints `pip install -U
+ phone-harness` and does not run it. It never updates on its own. A
+ newer PyPI release is one stderr line, at most once a day, and only on
+ a terminal; `PHONE_HARNESS_NO_UPDATE_CHECK=1` skips the check.
- **No phone on your desk?** `phone-harness cloud login`, then
`phone-harness cloud ls` and `phone-harness cloud start` (the account
default) or `phone-harness cloud start PHONE` for a catalog id, label, or
`ios` / `android` when that names one phone. An Android needs adb, below.
An iPhone needs no adb and no Mac; driving it is **Cloud iPhone** in
- `SKILL.md`. A start lasts 15 minutes unless you pass `--for` (`90s`, `15m`,
+ the skill. A start lasts 15 minutes unless you pass `--for` (`90s`, `15m`,
or a number of minutes). New accounts get $5 of credit (100 minutes).
+No uv? `pip install phone-harness` works too. Upgrade that install with
+`pip install -U phone-harness` (what `phone-harness update` prints for it).
+
+## Working from a checkout (contributors)
+
+```bash
+git clone https://github.com/ShawnPana/phone-harness ~/.phone-harness
+cd ~/.phone-harness
+pip install -e .
+```
+
+`pip install -e .` pulls pyobjc on macOS only. Register the skill the same
+way as the Fast Path. A checkout uses its own `agent-workspace/`. Because
+that clone sits at `~/.phone-harness`, a separate pip or uv install stores
+helpers in `~/.local/share/phone-harness/agent-workspace` instead of
+writing into the checkout.
+
## iPhone
- macOS Sequoia+ with **iPhone Mirroring** paired to the phone (open the app
@@ -103,7 +135,7 @@ line, at most once a day, and only on a terminal;
Set up each as above; `phone-harness config set platform …` picks the default,
`PHONE_HARNESS_PLATFORM=…` picks per call. The desk phones never interfere —
the iPhone is driven through the mirroring window, the Android over adb. A
-cloud iPhone is a third path: HTTPS ops, covered in `SKILL.md`.
+cloud iPhone is a third path: HTTPS ops, covered in the skill.
`phone-harness config set telemetry false` turns off anonymous usage telemetry.
@@ -117,9 +149,10 @@ cloud iPhone is a third path: HTTPS ops, covered in `SKILL.md`.
- **iPhone — taps do nothing**: Accessibility missing, or another window stole
focus (helpers re-activate the window; check for a macOS prompt).
- **iPhone — `--doctor` says pyobjc missing on an install that works**: it is
- running a different Python than the one that has pyobjc; use the interpreter
- `pip install -e .` used, or `pip install pyobjc-framework-Quartz
- pyobjc-framework-Vision pyobjc-framework-Cocoa` for that one.
+ running a different Python than the one that has pyobjc. Re-run the Fast
+ Path command, or use the interpreter `pip install -e .` used in a checkout.
+ Or `pip install pyobjc-framework-Quartz pyobjc-framework-Vision
+ pyobjc-framework-Cocoa` for that interpreter.
- **Android — `unauthorized`**: unlock the phone and tap Allow on the "Allow
USB debugging?" prompt (replug if it does not appear).
- **Android — `no-device`**: USB debugging off, cable/port, or for Wi‑Fi:
diff --git a/onboarding.md b/onboarding.md
index a7980d1..a45e494 100644
--- a/onboarding.md
+++ b/onboarding.md
@@ -84,5 +84,6 @@ in the summary and move on. If yes:
Never type a PIN. Never change a phone setting without asking. Never sign the
user up for anything or spend their cloud credit beyond the proof. Connecting
the phone is the user's job — relay the doctor's message and wait; don't
-retry-loop. After this, day-to-day usage is `SKILL.md`; setup reference and
-troubleshooting are `install.md`.
+retry-loop. After this, day-to-day usage is the phone-harness skill.
+Setup reference and troubleshooting:
+https://github.com/ShawnPana/phone-harness/blob/main/install.md.
diff --git a/src/phone_harness/config.py b/src/phone_harness/config.py
index 4d9bb85..e52ed1f 100644
--- a/src/phone_harness/config.py
+++ b/src/phone_harness/config.py
@@ -24,7 +24,7 @@ PHONE_HARNESS_HOME moves all three roots under one directory (tests, sandboxes).
One rule for every setting: explicit argument, else environment variable,
else config file, else built-in default. A `.env` file at the repo root or
in the agent workspace is read once at import and fills in environment
-variables that are not already set (the same as browser-harness): a place
+variables that are not already set: a place
for per-machine overrides such as PHONE_HARNESS_CLOUD_API, never committed.
Resolving that workspace creates it from the packaged defaults when the
directory does not exist; an existing directory is not modified. An
diff --git a/src/phone_harness/transport.py b/src/phone_harness/transport.py
index db69b67..1cd61db 100644
--- a/src/phone_harness/transport.py
+++ b/src/phone_harness/transport.py
@@ -6,9 +6,7 @@ which is what lets helpers.py carry no platform knowledge at all: `nav.home`
means the same thing to an iPhone and a Pixel, though one is a Cmd+1 keystroke
into a video stream and the other is a KEYCODE_HOME over adb.
-This mirrors browser-harness, where helpers.py has no idea whether the browser
-is local or in the cloud because everything funnels through cdp(). Phones have
-no shared wire protocol to funnel through — SkyLight event records and adb have
+Phones have no shared wire protocol — SkyLight event records and adb have
nothing in common — so the shared layer is this vocabulary instead.
screen.capture path=None -> (png_path, bounds)
diff --git a/src/phone_harness/workspace.py b/src/phone_harness/workspace.py
index bc0de4e..b13031a 100644
--- a/src/phone_harness/workspace.py
+++ b/src/phone_harness/workspace.py
@@ -48,9 +48,9 @@ def _is_git_checkout(path):
def _user_agent_workspace():
"""Per-user workspace, never inside an install prefix.
- ``~/.phone-harness`` is the canonical clone (see install.md). When that
- path is a checkout, its ``agent-workspace/`` belongs to the checkout;
- an install uses the data directory instead of writing into the clone.
+ When ``~/.phone-harness`` is a git checkout, its ``agent-workspace/``
+ belongs to that checkout. An install uses the data directory instead
+ of writing into it.
"""
canonical = Path.home() / ".phone-harness"
if not _is_git_checkout(canonical):