let your agent control your phone
feat: `phone-harness use android` — a saved default platform, no environment involved
ShawnPana9db09191d702
diff --git a/SKILL.md b/SKILL.mdindex 58907cf..a5cb384 100644--- a/SKILL.md+++ b/SKILL.md@@ -60,10 +60,11 @@ PY## Android-Same helpers, different phone: prefix every invocation with-`PHONE_HARNESS_PLATFORM=android` (or export it once). The harness finds the-phone itself — a USB phone if plugged in, else the paired Wi-Fi phone — so-there is nothing to select.+Same helpers, different phone. `phone-harness use android` makes Android the+default (`phone-harness use` shows the current one); until then, or to+override per call, prefix with `PHONE_HARNESS_PLATFORM=android`. The harness+finds the phone itself — a USB phone if plugged in, else the paired Wi-Fi+phone — so there is nothing to select.```bashPHONE_HARNESS_PLATFORM=android phone-harness <<'PY'diff --git a/src/phone_harness/android.py b/src/phone_harness/android.pyindex 5de13ee..d677d38 100644--- a/src/phone_harness/android.py+++ b/src/phone_harness/android.py@@ -765,6 +765,10 @@ def cli(args):cfg = _load()print(f"paired and connected: {model} as '{key}' ({adb_id})"+ (" — now the primary" if cfg.get("primary") == key else ""))+ from . import transport+ if transport.default_platform() != "android":+ print("tip: `phone-harness use android` makes Android the default, "+ "so nothing needs PHONE_HARNESS_PLATFORM=android")return 0if cmd == "connect":diff --git a/src/phone_harness/run.py b/src/phone_harness/run.pyindex 64f6543..75a8bcc 100644--- a/src/phone_harness/run.py+++ b/src/phone_harness/run.py@@ -11,6 +11,7 @@ Commands:phone-harness --doctor diagnose permissions, app, and session statephone-harness skill print the phone-harness skill textphone-harness android ... pair/connect/choose an Android phone+ phone-harness use ios|android which phone helpers drive by default"""@@ -25,6 +26,15 @@ def main():if args and args[0] == "android":from .android import clisys.exit(cli(args[1:]))+ if args and args[0] == "use":+ from . import transport+ if len(args) < 2 or args[1] not in ("ios", "android"):+ print(f"default platform: {transport.default_platform()}\n"+ "usage: phone-harness use ios|android")+ sys.exit(0 if len(args) < 2 else 2)+ transport.set_default_platform(args[1])+ print(f"default platform: {args[1]}")+ returnif args and args[0] == "skill":repo_root = Path(__file__).resolve().parent.parent.parentprint((repo_root / "SKILL.md").read_text(encoding="utf-8"), end="")diff --git a/src/phone_harness/transport.py b/src/phone_harness/transport.pyindex 9e34d29..e92a9fb 100644--- a/src/phone_harness/transport.py+++ b/src/phone_harness/transport.py@@ -67,7 +67,9 @@ Anything a backend genuinely cannot do raises Unsupported. Callers gate onsupports(op) rather than guessing."""import importlib+import jsonimport os+from pathlib import Pathclass Unsupported(RuntimeError):@@ -119,15 +121,42 @@ class Backend:return [op for op in OP_NAMES if self.supports(op)]+CONFIG_DIR = Path(os.environ.get("PHONE_HARNESS_CONFIG_DIR",+ Path.home() / ".config" / "phone-harness"))+++def default_platform():+ """The platform to use when nothing says otherwise: the one saved by+ `phone-harness use <platform>`, else ios."""+ try:+ return json.loads((CONFIG_DIR / "config.json").read_text()).get(+ "platform") or "ios"+ except (OSError, ValueError):+ return "ios"+++def set_default_platform(platform):+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)+ path = CONFIG_DIR / "config.json"+ try:+ cfg = json.loads(path.read_text())+ except (OSError, ValueError):+ cfg = {}+ cfg["platform"] = platform+ path.write_text(json.dumps(cfg, indent=2) + "\n")++def connect(platform=None, **kw):- """Build a backend. PHONE_HARNESS_PLATFORM selects one; default is ios.+ """Build a backend. Explicit argument, else PHONE_HARNESS_PLATFORM, else+ the default saved by `phone-harness use <platform>`, else ios.Returns an object rather than installing a module global, so a script canhold two devices at once instead of being limited to one per process.helpers.py binds one of these as its default."""platform = (platform- or os.environ.get("PHONE_HARNESS_PLATFORM", "ios")).lower()+ or os.environ.get("PHONE_HARNESS_PLATFORM")+ or default_platform()).lower()if platform in ("ios", "iphone", "ipad"):return importlib.import_module(".ios", __package__).IPhone(**kw)if platform == "android":