graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(ios): simulator runs clean up what they start (#407)
Rach Pradhanc0725e973710
diff --git a/apps/ios/autotest.sh b/apps/ios/autotest.shindex 4b34fac2..88105036 100755--- a/apps/ios/autotest.sh+++ b/apps/ios/autotest.sh@@ -3,10 +3,10 @@# wait for the stream, and screenshot. Run ./build-sim.sh first to install.set -euo pipefailcd "$(dirname "$0")"-SIM="${SIM:-iPhone 17 Pro}"-BUNDLE=com.codegraff.graff-xcrun simctl terminate "$SIM" "$BUNDLE" 2>/dev/null || true-xcrun simctl launch "$SIM" "$BUNDLE" --autotest+. ./sim-lib.sh # #407: UDID + boot-state aware cleanup trap (KEEP=1 / SIM_GUI=1)+sim_boot+xcrun simctl terminate "$sim_udid" "$BUNDLE" 2>/dev/null || true+xcrun simctl launch "$sim_udid" "$BUNDLE" --autotestsleep 16-xcrun simctl io "$SIM" screenshot build/autotest.png >/dev/null 2>&1 || true+xcrun simctl io "$sim_udid" screenshot build/autotest.png >/dev/null 2>&1 || trueecho "shot: $(pwd)/build/autotest.png"diff --git a/apps/ios/build-sim.sh b/apps/ios/build-sim.shindex 61909d9d..8a9cd4ae 100755--- a/apps/ios/build-sim.sh+++ b/apps/ios/build-sim.sh@@ -6,8 +6,7 @@ set -euo pipefailcd "$(dirname "$0")"APP=Graff-BUNDLE=com.codegraff.graff-SIM="${SIM:-iPhone 17 Pro}"+. ./sim-lib.sh # #407: UDID + boot-state aware cleanup trap (KEEP=1 / SIM_GUI=1)SDK="$(xcrun --sdk iphonesimulator --show-sdk-path)"TARGET=arm64-apple-ios26.0-simulatorOUT="build/${APP}.app"@@ -43,12 +42,11 @@ xcrun -sdk iphonesimulator swiftc \cp Graff/Info.plist "$OUT/Info.plist"echo "==> booting $SIM"-xcrun simctl boot "$SIM" 2>/dev/null || true-open -a Simulator >/dev/null 2>&1 || true+sim_bootecho "==> installing + launching"-xcrun simctl install "$SIM" "$OUT"-xcrun simctl launch "$SIM" "$BUNDLE" || true+xcrun simctl install "$sim_udid" "$OUT"+xcrun simctl launch "$sim_udid" "$BUNDLE" || truesleep 4-xcrun simctl io "$SIM" screenshot build/launch.png >/dev/null 2>&1 || true+xcrun simctl io "$sim_udid" screenshot build/launch.png >/dev/null 2>&1 || trueecho "==> done — screenshot: $(pwd)/build/launch.png"diff --git a/apps/ios/recap.sh b/apps/ios/recap.shindex e7970824..77f6fc93 100755--- a/apps/ios/recap.sh+++ b/apps/ios/recap.sh@@ -2,11 +2,11 @@# Relaunch --autotest and capture the in-flight typing indicator + the reply.set -euo pipefailcd "$(dirname "$0")"-SIM="${SIM:-iPhone 17 Pro}"-BUNDLE=com.codegraff.graff-xcrun simctl terminate "$SIM" "$BUNDLE" 2>/dev/null || true-xcrun simctl launch "$SIM" "$BUNDLE" --autotest-sleep 5; xcrun simctl io "$SIM" screenshot build/cap_typing.png >/dev/null 2>&1 || true-sleep 3; xcrun simctl io "$SIM" screenshot build/cap_mid.png >/dev/null 2>&1 || true-sleep 8; xcrun simctl io "$SIM" screenshot build/cap_reply.png >/dev/null 2>&1 || true+. ./sim-lib.sh # #407: UDID + boot-state aware cleanup trap (KEEP=1 / SIM_GUI=1)+sim_boot+xcrun simctl terminate "$sim_udid" "$BUNDLE" 2>/dev/null || true+xcrun simctl launch "$sim_udid" "$BUNDLE" --autotest+sleep 5; xcrun simctl io "$sim_udid" screenshot build/cap_typing.png >/dev/null 2>&1 || true+sleep 3; xcrun simctl io "$sim_udid" screenshot build/cap_mid.png >/dev/null 2>&1 || true+sleep 8; xcrun simctl io "$sim_udid" screenshot build/cap_reply.png >/dev/null 2>&1 || trueecho "captured: cap_typing.png cap_mid.png cap_reply.png"diff --git a/apps/ios/sim-lib.sh b/apps/ios/sim-lib.shnew file mode 100755index 00000000..b1c6e0bc--- /dev/null+++ b/apps/ios/sim-lib.sh@@ -0,0 +1,29 @@+#!/bin/bash+# Shared simulator lifecycle (#407). Source this after (optionally) setting+# SIM/BUNDLE. It resolves $SIM to a UDID once, boots only when needed, and+# a trap tears down what this run started: the launched app always, the+# device only if this run booted it. A pre-booted device is left alone.+# KEEP=1 keep app + device running on exit (interactive debugging)+# SIM_GUI=1 open the Simulator window — headless is the default; simctl+# install/launch/io screenshot all work without the GUI.++SIM="${SIM:-iPhone 17 Pro}"+BUNDLE="${BUNDLE:-com.codegraff.graff}"++sim_udid="$(xcrun simctl list devices available | awk -v n="$SIM" -F '[()]' 'index($0, n" (") {print $2; exit}')"+[ -n "$sim_udid" ] || { echo "no available simulator named '$SIM'" >&2; exit 1; }++sim_booted_by_us=0+sim_cleanup() {+ [ "${KEEP:-0}" = 1 ] && return 0+ xcrun simctl terminate "$sim_udid" "$BUNDLE" 2>/dev/null || true+ [ "$sim_booted_by_us" = 1 ] && xcrun simctl shutdown "$sim_udid" 2>/dev/null || true+}+trap sim_cleanup EXIT INT TERM++sim_boot() {+ xcrun simctl list devices | grep "$sim_udid" | grep -q '(Booted)' && return 0+ xcrun simctl boot "$sim_udid"+ sim_booted_by_us=1+ [ "${SIM_GUI:-0}" = 1 ] && open -a Simulator >/dev/null 2>&1 || true+}diff --git a/src/skills.zig b/src/skills.zigindex 40f733da..4407be0f 100644--- a/src/skills.zig+++ b/src/skills.zig@@ -52,7 +52,7 @@ pub const skills_registry = [_]SkillDef{.desc = "browser automation, web crawling, iOS/Android device control (github.com/justrach/kuri)",.bins = &.{"kuri"},.install = "curl -fsSL https://raw.githubusercontent.com/justrach/kuri/main/install.sh | sh",- .note = "The `kuri` CLI is installed (browser automation, HAR capture, iOS/Android device control) — prefer it via bash for browser and device tasks; run `kuri --help` once to see subcommands before using it. Plain page fetching is already covered: the webfetch tool uses kuri-fetch under the hood. WARNING: iOS/Android simulator input (`kuri ios tap`/`swipe`/`scroll`/`type`) synthesizes host-level GUI events and grabs the user's real mouse cursor and keyboard focus — never use these during background work without explicit user consent (recent kuri gates them behind `--host-input`/`KURI_ALLOW_HOST_INPUT=1`). For background/non-interactive device tasks prefer `xcrun simctl` (boot/install/launch and `io ... screenshot`) and app-level deterministic/autotest hooks.",+ .note = "The `kuri` CLI is installed (browser automation, HAR capture, iOS/Android device control) — prefer it via bash for browser and device tasks; run `kuri --help` once to see subcommands before using it. Plain page fetching is already covered: the webfetch tool uses kuri-fetch under the hood. WARNING: iOS/Android simulator input (`kuri ios tap`/`swipe`/`scroll`/`type`) synthesizes host-level GUI events and grabs the user's real mouse cursor and keyboard focus — never use these during background work without explicit user consent (recent kuri gates them behind `--host-input`/`KURI_ALLOW_HOST_INPUT=1`). For background/non-interactive device tasks prefer `xcrun simctl` (boot/install/launch and `io ... screenshot`) and app-level deterministic/autotest hooks — and clean up after yourself (#407): shut down any device you booted (`xcrun simctl shutdown <udid>`) and never `open -a Simulator` for background work; screenshots work headless.",},};