emd-agents 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,24 +1,146 @@
1
1
  # EMD: Everything Mobile Development
2
2
 
3
- EMD is an MCP server and CLI. It lets a coding agent launch an Expo app on the iOS simulator, check it, and collect evidence.
3
+ <!-- Intro rule: one category line, the job in two or three sentences, then the agents it works with. Nothing else. Add a "used by" line only with a public link for each name. Details go in the sections below. -->
4
4
 
5
- Status: early.
5
+ An MCP server, CLI and agent skill for coding agents that change mobile apps.
6
6
 
7
- ## What works today
7
+ Your coding agent shouldn't grade its own mobile work. EMD builds the app, launches it on the iOS simulator, and passes or fails each change from the app's own log lines and screen. It keeps the evidence: checks, log lines and screenshots.
8
8
 
9
- Stack: Expo (React Native). `detect` reports iOS and Android. `launch` runs on the iOS simulator only.
9
+ `setup` registers EMD with Claude Code, Codex and Cursor. Tested end to end in Claude Code.
10
10
 
11
- MCP tools (`emd mcp`):
11
+ Status: early. Expo apps on the iOS simulator only.
12
+
13
+ ## Requirements
14
+
15
+ - A Mac with Xcode 26 or 27 and at least one iPhone simulator.
16
+ - Node 22 or newer.
17
+ - An Expo app with its dependencies installed and an iOS app ID. [Check your app](#check-your-app) shows how to check both.
18
+
19
+ Tested: Expo SDK 58 on Xcode 26 and 27. On Xcode 27, apps below Expo SDK 56 can't build (Expo's bug). Use Xcode 26, or upgrade the app to SDK 56 or newer.
20
+
21
+ More detail: [Requirements in detail](#requirements-in-detail).
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ npx -y emd-agents@latest setup
27
+ ```
28
+
29
+ It finds Claude Code, Codex and Cursor, prints its plan and asks once. On a Mac without AXe, it installs AXe, the tool EMD uses to tap and read the screen. Then it registers EMD with each agent and installs EMD's skill, which tells the agent how to use EMD. It backs up each agent config to `~/.emd/backups/` first.
30
+
31
+ At the end it runs `doctor`. For each check marked `missing`, do what its `fix` says. Then restart your agents.
32
+
33
+ - `--dry-run` prints the plan and changes nothing. `--yes` applies it without asking. `--agent codex` (repeatable) picks agents.
34
+ - It calls two installers, pinned: [add-mcp](https://github.com/neondatabase/add-mcp) for the server and [skills](https://github.com/vercel-labs/skills) for the skill.
35
+
36
+ ## Check your app
37
+
38
+ Run this yourself before you ask your agent:
39
+
40
+ ```sh
41
+ npx -y emd-agents@latest detect /path/to/my-app
42
+ ```
43
+
44
+ It must print `"verdict":"detected"` and an iOS app ID, for example `"appIds":{"ios":"com.example.myapp"}`. Without the ID, `launch` stops. If the ID is missing:
45
+
46
+ - Add one. New Expo apps (from `create-expo-app`) have none. In `app.json`, under `expo.ios`, add `"bundleIdentifier": "com.example.myapp"`.
47
+ - If the app config already has one, install the app's dependencies. EMD reads the config with the app's own Expo CLI.
48
+
49
+ ## First run
50
+
51
+ Ask your agent for a small change, with the full path of your app:
52
+
53
+ > In /path/to/my-app, add a button that shows "Saved" when tapped. Prove it on the iOS simulator with EMD, then tell me the evidence folder.
54
+
55
+ The agent follows EMD's skill. It adds a tagged log line, such as `console.log("[EMD:saved] button tapped")`, and a testID. Then it launches the app, taps, checks the log line and the screen, and gathers the evidence. A first build takes minutes.
56
+
57
+ Each check ends with one verdict:
58
+
59
+ - `passed`: done.
60
+ - `failed`: the agent fixes the cause and checks again.
61
+ - `stopped`: 3 checks failed in this app folder. Only a person can start over, at a terminal: `npx -y emd-agents@latest check reset /path/to/my-app`.
62
+ - `error`: the check could not run. The result says why.
63
+
64
+ A check name keeps its first expectations. A later check with the same name can add expectations, but not drop them. The evidence lists each check name whose last verdict is not `passed`.
65
+
66
+ Output stays on your Mac:
67
+
68
+ - Each launch has a run folder, `$TMPDIR/emd/runs/<time>-<app folder>/`. The launch result gives it as `logDir`. It holds `build.log`, `metro.log`, the app's log (`app.ndjson`), the check screenshots, and `evidence/` (`manifest.json`, `logs.json`, `screenshots/`, `flows/`).
69
+ - Jobs are in `$TMPDIR/emd/jobs/<jobId>.json`.
70
+ - Data that must stay after a restart is in `~/.emd/`: the record of what EMD made (`owned/`), build folders (`derived/`) and failed-check counts (`checks/`).
71
+
72
+ ## Limits today
73
+
74
+ - Expo apps on the iOS simulator only. No native iOS or Android projects, no Android launch, no physical devices.
75
+ - `launch` leaves the dev server running. The next `launch` of the same folder stops it and starts a new one. A dev server that EMD did not start on that port still blocks `launch` ("Port N already serves a dev server").
76
+ - `EMD_RETRY_LIMIT` (1 to 10) changes the limit of 3 failed checks.
77
+ - A build can take 900 seconds by default (`timeoutSeconds`, or `--timeout` in the CLI). Two cold builds at the same time can take longer.
78
+ - The CLI `launch` waits and does not make a job. `logs`, `check` and `evidence` need the `jobId` of a `launch` that the agent started.
79
+
80
+ ## FAQ
81
+
82
+ ### How is EMD different from agent-device, Argent or MobileBuildMCP?
83
+
84
+ Each project's README says what it does. [agent-device](https://github.com/callstack/agent-device) lets agents inspect, control, debug and verify apps. [Argent](https://github.com/software-mansion/argent) gives agents direct control of simulators, emulators and devices, to interact, debug, profile and record e2e tests. [MobileBuildMCP](https://github.com/getsentry/MobileBuildMCP) gives agents tools for iOS and macOS projects, such as build and test. EMD centers on the verdict:
85
+
86
+ - One check reads the app's own tagged log lines and the elements on screen, and passes or fails on both.
87
+ - A check name keeps its first expectations, so the agent can't pass it by dropping one.
88
+ - After 3 failed checks, every later check returns `stopped` until a person resets the count.
89
+
90
+ For taps and screen reads, EMD uses AXe, with Maestro as the fallback.
91
+
92
+ ### How do I upgrade?
93
+
94
+ Run `npx -y emd-agents@latest setup` again, then restart your agents. Setup registers the exact version it ran from, so EMD's server and skill stay at one version.
95
+
96
+ ### How do I remove EMD?
97
+
98
+ Remove the server from each agent, then the skill:
99
+
100
+ ```sh
101
+ claude mcp remove emd -s user
102
+ codex mcp remove emd
103
+ npx -y skills@1.7.6 remove emd -g -y
104
+ ```
105
+
106
+ In Cursor, delete the `emd` entry from `~/.cursor/mcp.json`.
107
+
108
+ To remove what EMD made on your Mac:
109
+
110
+ 1. Delete its simulators. `xcrun simctl list devices | grep emd-` lists them. `xcrun simctl delete <id>` deletes one.
111
+ 2. Delete `~/.emd/`. It holds AXe, build folders, EMD's records and the config backups from setup. Copy a backup first if you want to keep it.
112
+
113
+ ## Report a problem
114
+
115
+ Open an [issue](https://github.com/andrewhenin/emd/issues) with:
116
+
117
+ - What you asked the agent, and the tool or command that failed, with its JSON result.
118
+ - The output of `npx -y emd-agents@latest doctor` and `npx -y emd-agents@latest detect /path/to/my-app`.
119
+ - Versions: EMD's (the `emd-agents@<version>` in your agent's MCP config, or `node dist/bin.js` and `git rev-parse --short HEAD` in a clone), `sw_vers` (macOS), `xcodebuild -version`, `node --version`, and `axe --version` or `maestro --version` if you use them.
120
+ - From the run folder: `build.log` and `metro.log`, or the lines near the error.
121
+ - Before you attach logs or screenshots, remove private details: names, tokens, keys, internal URLs and user data.
122
+
123
+ ## Contributing
124
+
125
+ EMD is open source but does not accept pull requests from outside contributors yet. Bug reports and ideas are welcome as issues. If you want to fix something yourself, say so in the issue. Report vulnerabilities per [SECURITY.md](SECURITY.md).
126
+
127
+ ## Reference
128
+
129
+ ### MCP tools
130
+
131
+ `emd mcp` serves these tools:
12
132
 
13
133
  - `detect`: finds the stack, platforms, app IDs, run commands and package manager of a folder. At a workspace root, it lists the app folders instead (`apps`).
14
134
  - `launch`: builds the app, installs and opens it on an iOS simulator, and keeps its dev server running. Returns a job at once.
15
- - `job_status`: the state of a job (queued, running, succeeded, failed) and, at the end, its result.
135
+ - `job_status`: the state of a job (queued, running, succeeded, failed) and, at the end, its result. It waits up to 50 s (`waitSeconds`) and returns when the job ends.
16
136
  - `logs`: the `[EMD:<tag>]` lines that the app wrote during the run of a launch job.
17
137
  - `tap`, `type`, `swipe`: act on the launched app. `tap` takes a testID, a visible text or a point. Each says which tool did it (AXe or Maestro).
18
138
  - `check`: passes or fails a run from tagged log lines and on-screen elements (by testID or text). Returns a job.
19
139
  - `evidence`: puts the checks, log lines, screenshots and Maestro flows of a run in one folder.
20
140
 
21
- CLI commands (`npx -y emd-agents@latest <command>`, or `node dist/bin.js <command>` in a clone; below, `emd` means either):
141
+ ### CLI commands
142
+
143
+ Run them as `npx -y emd-agents@latest <command>`, or `node dist/bin.js <command>` in a clone. Below, `emd` means either.
22
144
 
23
145
  - `detect [dir]`: same as the tool.
24
146
  - `launch [dir] [--device X] [--timeout N]`: same as the tool, but waits for the result.
@@ -29,36 +151,23 @@ CLI commands (`npx -y emd-agents@latest <command>`, or `node dist/bin.js <comman
29
151
  - `evidence <jobId>`: same as the tool.
30
152
  - `gc [--apply]`: lists, then removes, what EMD made for app folders that no longer exist.
31
153
  - `tap <jobId> --id X|--text Y|--x N --y N`, `type <jobId> <text>`, `swipe <jobId> up|down|left|right`: same as the tools.
32
- - `setup [--dry-run] [--yes] [--agent X]`: registers EMD with your agents and installs the skill (see below).
154
+ - `setup [--dry-run] [--yes] [--agent X]`: registers EMD with your agents and installs the skill.
33
155
  - `doctor`: checks that this Mac has what EMD needs (Node, macOS, Xcode, an iPhone simulator, AXe or Maestro) and says how to add what is missing.
34
156
  - `mcp`: starts the MCP server on stdio.
35
157
 
36
- ## Requirements
158
+ ### Requirements in detail
37
159
 
38
160
  - An Expo app with `expo` in package.json and `ios.bundleIdentifier` in its app config (app.json, app.config.js or app.config.ts). EMD reads it with the app's own `expo config`. Without the ID, `launch` stops: "No iOS app ID found".
39
161
  - The app's dependencies, installed. EMD does not install them.
40
162
  - macOS. On other systems `detect` works, and `launch` returns "iOS simulators need macOS."
41
163
  - Xcode, tested with Xcode 26 and 27. Expo SDK 58 apps need Xcode 26 or newer. Without Xcode, `launch` fails: "Could not set up this worktree's simulator and build folders."
42
164
  - An iOS simulator runtime and at least one shut-down iPhone simulator. EMD clones it once per app folder, as `emd-<key>`. Without one, `launch` fails: "No shut-down iPhone simulator is available to clone."
43
- - Node 22 or newer.
44
165
  - AXe or Maestro, for taps, typing, swipes and element checks. EMD tries AXe first, then Maestro.
45
- - AXe (about 40 times faster for checks, 60 for taps): `setup` installs it (below). With Xcode 27, Device Hub must be running.
166
+ - AXe (about 40 times faster for checks, 60 for taps): `setup` installs it into `~/.emd/tools/`, from AXe's pinned release archive, checked by SHA-256. With Xcode 27, Device Hub must be running.
46
167
  - Maestro: `curl -fsSL "https://get.maestro.mobile.dev" | bash`. It needs Java 17 or newer, with `JAVA_HOME` set.
47
168
  - With neither, taps, typing and swipes fail, and a check with elements returns `error`. `launch`, `logs`, log checks and `evidence` still work.
48
169
 
49
- ## Install
50
-
51
- ```sh
52
- npx -y emd-agents@latest setup
53
- ```
54
-
55
- It finds Claude Code, Codex and Cursor, prints its plan and asks once. On a Mac without AXe, it first installs AXe into `~/.emd/tools/`, from AXe's pinned release archive, checked by SHA-256. Then it registers EMD with each agent and installs EMD's skill, which tells the agent how to use it. It backs up each config to `~/.emd/backups/` first. At the end it runs `doctor` and lists what is still missing. Restart your agents afterwards.
56
-
57
- - `--dry-run` prints the plan and changes nothing. `--yes` applies it without asking. `--agent codex` (repeatable) picks agents.
58
- - It registers this exact version, `npx -y emd-agents@<version> mcp`, so the server matches the skill. To upgrade, run the same command again.
59
- - It calls two installers, pinned: [add-mcp](https://github.com/neondatabase/add-mcp) for the server and [skills](https://github.com/vercel-labs/skills) for the skill.
60
-
61
- ## Install from source
170
+ ### Install from source
62
171
 
63
172
  ```sh
64
173
  git clone https://github.com/andrewhenin/emd.git
@@ -70,22 +179,7 @@ node dist/bin.js detect fixtures/expo
70
179
 
71
180
  The last line must print `"verdict":"detected"` and `"appIds":{"ios":"com.emd.sandbox"}`. Then `node dist/bin.js setup` registers this clone's build with your agents.
72
181
 
73
- ## First run
74
-
75
- 1. In your app, log an event with a tag, for example `console.log("[EMD:ready] home shown")`. Give a testID to each element that you want to check.
76
- 2. Ask your agent, with the full path of your app:
77
-
78
- > Use the emd tools on /path/to/my-app. Launch it on the iOS simulator. Check that the `ready` log event fired and that the element with testID `home` is on screen. Then gather the evidence and tell me the folder.
79
-
80
- The agent follows EMD's skill (`skills/emd/SKILL.md`): `launch`, wait for the job with `job_status`, `tap`, read `logs`, `check`, then `evidence`. A check's verdict is `passed`, `failed` (fix and check again), `stopped` (3 failed checks: stop and report) or `error` (the check could not run).
81
-
82
- Output stays on your Mac:
83
-
84
- - Each launch has a run folder, `$TMPDIR/emd/runs/<time>-<app folder>/`. The launch result gives it as `logDir`. It holds `build.log`, `metro.log`, the app's log (`app.ndjson`), the check screenshots, and `evidence/` (`manifest.json`, `logs.json`, `screenshots/`, `flows/`).
85
- - Jobs are in `$TMPDIR/emd/jobs/<jobId>.json`.
86
- - Data that must stay after a restart is in `~/.emd/`: the record of what EMD made (`owned/`), build folders (`derived/`) and failed-check counts (`checks/`).
87
-
88
- ## Clean up
182
+ ### Clean up
89
183
 
90
184
  `gc` removes what EMD made for app folders that no longer exist, for example a deleted git worktree: the simulator clone and its `~/.emd/` folders. It removes only what EMD recorded as its own. For a folder that still exists, it removes nothing. It is a CLI command only, not an MCP tool.
91
185
 
@@ -97,26 +191,4 @@ emd gc --apply # removes it
97
191
  - It lists `emd-*` simulators that no record names, but it never deletes them.
98
192
  - It does not touch `$TMPDIR/emd` or a dev server that runs.
99
193
 
100
- ## Limits today
101
-
102
- - Expo apps on the iOS simulator only. No native iOS or Android projects, no Android launch, no physical devices.
103
- - `launch` leaves the dev server running. The next `launch` of the same folder stops it and starts a new one. A dev server that EMD did not start on that port still blocks `launch` ("Port N already serves a dev server").
104
- - After 3 failed checks in one app folder, `check` returns `stopped`. Only a person can start over: `emd check reset /path/to/my-app` at a terminal. `EMD_RETRY_LIMIT` (1 to 10) changes the limit.
105
- - A build can take 900 seconds by default (`timeoutSeconds`, or `--timeout` in the CLI). Two cold builds at the same time can take longer.
106
- - The CLI `launch` waits and does not make a job. `logs`, `check` and `evidence` need the `jobId` of a `launch` that the agent started.
107
-
108
- ## Report a problem
109
-
110
- Open an [issue](https://github.com/andrewhenin/emd/issues) with:
111
-
112
- - What you asked the agent, and the tool or command that failed, with its JSON result.
113
- - Versions: EMD's (the `emd-agents@<version>` in your agent's MCP config, or `node dist/bin.js` and `git rev-parse --short HEAD` in a clone), `sw_vers` (macOS), `xcodebuild -version`, `node --version`, and `axe --version` or `maestro --version` if you use them.
114
- - The output of `emd detect /path/to/my-app`.
115
- - From the run folder: `build.log` and `metro.log`, or the lines near the error.
116
- - Before you attach logs or screenshots, remove private details: names, tokens, keys, internal URLs and user data.
117
-
118
- ## Contributing
119
-
120
- EMD is open source but not accepting outside pull requests yet. Bug reports and ideas are welcome as issues; report vulnerabilities per [SECURITY.md](SECURITY.md).
121
-
122
194
  License: [Apache-2.0](LICENSE)
@@ -14,6 +14,15 @@ async function readExpoConfig(dir) {
14
14
  return {};
15
15
  }
16
16
  }
17
+ // Expo's own fingerprint, from the project's installed Expo (never downloaded).
18
+ async function expoFingerprint(dir, platform) {
19
+ const fromExpo = createRequire(createRequire(join(dir, "package.json")).resolve("expo/bin/cli"));
20
+ const { createFingerprintAsync } = fromExpo("@expo/fingerprint");
21
+ const { hash } = await createFingerprintAsync(dir, {
22
+ platforms: [platform],
23
+ });
24
+ return hash;
25
+ }
17
26
  const isPlatform = (value) => value === "ios" || value === "android";
18
27
  const nonEmpty = (value) => typeof value === "string" && value !== "" ? value : undefined;
19
28
  const adapter = {
@@ -51,5 +60,6 @@ const adapter = {
51
60
  build: `${expo} run:ios --device ${deviceId} --no-bundler`,
52
61
  };
53
62
  },
63
+ fingerprint: expoFingerprint,
54
64
  };
55
65
  export default adapter;
@@ -29,4 +29,5 @@ export interface StackAdapter {
29
29
  deviceId: string;
30
30
  port: number;
31
31
  }): LaunchPlan | undefined;
32
+ fingerprint(projectDir: string, platform: Platform): Promise<string>;
32
33
  }
@@ -0,0 +1,7 @@
1
+ export type BuildRecord = {
2
+ fingerprint: string;
3
+ port: number;
4
+ };
5
+ export declare function readBuildRecord(derivedData: string): BuildRecord | undefined;
6
+ export declare function writeBuildRecord(derivedData: string, record: BuildRecord): void;
7
+ export declare function whyBuild(record: BuildRecord | undefined, now: BuildRecord, installed: boolean): string | undefined;
@@ -0,0 +1,31 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ const file = (derivedData) => join(derivedData, "emd-build.json");
4
+ export function readBuildRecord(derivedData) {
5
+ try {
6
+ const record = JSON.parse(readFileSync(file(derivedData), "utf8"));
7
+ return typeof record?.fingerprint === "string" &&
8
+ typeof record?.port === "number"
9
+ ? record
10
+ : undefined;
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ export function writeBuildRecord(derivedData, record) {
17
+ writeFileSync(file(derivedData), JSON.stringify(record));
18
+ }
19
+ // Why the build must run; undefined when the installed build can be reused.
20
+ // A debug build bakes in the dev server port, so a new port needs a new build.
21
+ export function whyBuild(record, now, installed) {
22
+ if (!record)
23
+ return "no earlier build";
24
+ if (record.fingerprint !== now.fingerprint)
25
+ return "fingerprint changed";
26
+ if (record.port !== now.port)
27
+ return "port changed";
28
+ if (!installed)
29
+ return "app not installed";
30
+ return undefined;
31
+ }
@@ -47,12 +47,14 @@ async function readScreen(device, bin) {
47
47
  const run = async (bin, { device }, command, args) => {
48
48
  await runTool(`axe ${command}`, bin, [command, "--udid", device, ...args], 60);
49
49
  };
50
- // By testID (AXUniqueId) or label (AXLabel), AXe waits up to 5 s for the
51
- // element to appear, then taps its activation point.
50
+ // By testID (AXUniqueId) or label (AXLabel), AXe waits up to 10 s for the
51
+ // element to appear (the limit `check` reads again for), then taps its
52
+ // activation point.
53
+ const elementWaitSeconds = 10;
52
54
  const targetArgs = (target) => "id" in target
53
- ? ["--id", target.id, "--wait-timeout", "5"]
55
+ ? ["--id", target.id, "--wait-timeout", String(elementWaitSeconds)]
54
56
  : "text" in target
55
- ? ["--label", target.text, "--wait-timeout", "5"]
57
+ ? ["--label", target.text, "--wait-timeout", String(elementWaitSeconds)]
56
58
  : ["-x", String(target.x), "-y", String(target.y)];
57
59
  export const axeBackend = {
58
60
  id: "axe",
@@ -39,5 +39,12 @@ export type ScreenRead = Omit<Acted<UiNode[]>, "value"> & {
39
39
  nodes: UiNode[];
40
40
  };
41
41
  export declare function readScreen(device: string, env: Environment, backends: Pick<DeviceBackend, "id" | "readScreen">[]): Promise<ScreenRead>;
42
+ export declare function untilReadable(read: () => Promise<UiNode[]>, limitSeconds: number, whenEmpty?: {
43
+ afterSeconds: number;
44
+ act: () => Promise<void>;
45
+ }, pauseMs?: number): Promise<{
46
+ waited: number;
47
+ error?: string;
48
+ }>;
42
49
  export declare function detectEnvironment(): Promise<Environment>;
43
50
  export {};
@@ -47,6 +47,44 @@ export async function readScreen(device, env, backends) {
47
47
  });
48
48
  return { nodes: value, ...rest };
49
49
  }
50
+ // Reads the screen again until a read gives nodes or `limitSeconds` pass.
51
+ // Returns the seconds it took, and the last problem (in one short sentence)
52
+ // when time ran out. When every read so far gave an empty tree, not an error,
53
+ // `whenEmpty.act` runs once after `whenEmpty.afterSeconds` (the first sign of
54
+ // the shape that application accessibility fixes).
55
+ export async function untilReadable(read, limitSeconds, whenEmpty, pauseMs = 1000) {
56
+ const start = Date.now();
57
+ const elapsed = () => Date.now() - start;
58
+ const short = (text) => text
59
+ .replace(/^Error: /, "")
60
+ .split(/[.\n]/)[0]
61
+ ?.slice(0, 80) ?? "";
62
+ let error = "returned an empty tree";
63
+ let onlyEmpty = true;
64
+ let acted = false;
65
+ for (;;) {
66
+ try {
67
+ if ((await read()).length > 0) {
68
+ return { waited: Math.round(elapsed() / 100) / 10 };
69
+ }
70
+ }
71
+ catch (failure) {
72
+ onlyEmpty = false;
73
+ error = short(firstLine(failure));
74
+ }
75
+ if (whenEmpty &&
76
+ !acted &&
77
+ onlyEmpty &&
78
+ elapsed() >= whenEmpty.afterSeconds * 1000) {
79
+ acted = true;
80
+ await whenEmpty.act().catch(() => { });
81
+ }
82
+ if (elapsed() >= limitSeconds * 1000) {
83
+ return { waited: Math.round(elapsed() / 100) / 10, error };
84
+ }
85
+ await new Promise((resolve) => setTimeout(resolve, pauseMs));
86
+ }
87
+ }
50
88
  function findExecutable(name, extraDirs) {
51
89
  const dirs = [
52
90
  ...(process.env.PATH ?? "").split(delimiter),
@@ -7,7 +7,7 @@ export { type DoctorResult, doctor } from "./doctor.js";
7
7
  export { evidence } from "./evidence.js";
8
8
  export { type GcResult, gc } from "./gc.js";
9
9
  export { swipe, tap, typeText } from "./input.js";
10
- export { jobStatus, runJob, startJob } from "./jobs.js";
10
+ export { jobStatus, runJob, startJob, waitForJob } from "./jobs.js";
11
11
  export { launch } from "./launch.js";
12
12
  export { logs } from "./logs.js";
13
13
  export { loadedAdapters } from "./registry.js";
@@ -6,7 +6,7 @@ export { doctor } from "./doctor.js";
6
6
  export { evidence } from "./evidence.js";
7
7
  export { gc } from "./gc.js";
8
8
  export { swipe, tap, typeText } from "./input.js";
9
- export { jobStatus, runJob, startJob } from "./jobs.js";
9
+ export { jobStatus, runJob, startJob, waitForJob } from "./jobs.js";
10
10
  export { launch } from "./launch.js";
11
11
  export { logs } from "./logs.js";
12
12
  export { loadedAdapters } from "./registry.js";
@@ -37,7 +37,15 @@ export function tap(options) {
37
37
  reason: "Give one target: id, text, or both x and y.",
38
38
  });
39
39
  }
40
- return act("tap", options, (b, where, bin) => b.tap(where, bin, target));
40
+ const started = Date.now();
41
+ const done = act("tap", options, (b, where, bin) => b.tap(where, bin, target));
42
+ if ("x" in target)
43
+ return done;
44
+ // The backends wait for an element: AXe up to 10 s, Maestro its own limit.
45
+ return done.then((result) => ({
46
+ ...result,
47
+ seconds: Math.round((Date.now() - started) / 100) / 10,
48
+ }));
41
49
  }
42
50
  export function typeText(options) {
43
51
  const { text } = options;
@@ -19,3 +19,4 @@ export declare function createJob<K extends JobKind>(kind: K, input: Inputs[K]):
19
19
  export declare function startJob<K extends JobKind>(kind: K, input: Inputs[K], worker?: string): JobView;
20
20
  export declare function runJob(id: string, run?: Handlers): Promise<void>;
21
21
  export declare function jobStatus(id: string): JobView | undefined;
22
+ export declare function waitForJob(id: string, waitSeconds: number): Promise<JobView | undefined>;
package/dist/core/jobs.js CHANGED
@@ -112,3 +112,16 @@ export function jobStatus(id) {
112
112
  const current = readJob(id);
113
113
  return current && view(current);
114
114
  }
115
+ // Like jobStatus, but when the job is queued or running, reads it again every
116
+ // half second until it ends or `waitSeconds` pass. A wait of 0 answers at once.
117
+ export async function waitForJob(id, waitSeconds) {
118
+ const deadline = Date.now() + waitSeconds * 1000;
119
+ let job = jobStatus(id);
120
+ while (job &&
121
+ (job.status === "queued" || job.status === "running") &&
122
+ Date.now() < deadline) {
123
+ await new Promise((resolve) => setTimeout(resolve, 500));
124
+ job = jobStatus(id);
125
+ }
126
+ return job;
127
+ }
@@ -1,7 +1,10 @@
1
1
  import { mkdir, readFile } from "node:fs/promises";
2
2
  import { homedir } from "node:os";
3
3
  import { basename, join } from "node:path";
4
+ import { readBuildRecord, whyBuild, writeBuildRecord } from "./buildrecord.js";
4
5
  import { detect } from "./detect.js";
6
+ import { axeBackend } from "./device/axe.js";
7
+ import { detectEnvironment, untilReadable } from "./device/backend.js";
5
8
  import { derivedDataPath, diskMB, pickPort, xcodebuildShim, } from "./isolate.js";
6
9
  import { launchesIn } from "./jobstore.js";
7
10
  import { firstErrors, knownFix, onlyOpenFailed } from "./log.js";
@@ -10,12 +13,18 @@ import { confirm, reserve, worktreeKey } from "./owned.js";
10
13
  import { startLogged } from "./process.js";
11
14
  import { inspectProject } from "./project.js";
12
15
  import { loadAdapter } from "./registry.js";
13
- import { boot, cloneDevice, launchApp, listDevices, newerThan, pickDevice, removeSimulator, simulatorSdk, } from "./simulator.js";
16
+ import { appAccessibilityOn, appInstalled, boot, cloneDevice, enableAppAccessibility, launchApp, listDevices, newerThan, pickDevice, removeSimulator, simulatorSdk, terminateApp, } from "./simulator.js";
14
17
  import { stateDir } from "./state.js";
15
18
  import { runTool } from "./tool.js";
16
19
  const metroStartSeconds = 120;
17
20
  const stopSeconds = 10;
18
21
  const defaultTimeoutSeconds = 900;
22
+ // How long AXe may take to read the screen after the app started, about twice
23
+ // the slowest measurement: first launch 7.8 to 51.4 s on CI iOS 26 and up to
24
+ // 86 s on iOS 27.1; relaunch 5.9 to 31.3 s.
25
+ const screenReadSeconds = 180;
26
+ // An empty tree this long after the app started means accessibility is off.
27
+ const emptyTreeSeconds = 5;
19
28
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
20
29
  async function metroRunning(port) {
21
30
  try {
@@ -90,6 +99,32 @@ async function withTimeout(exited, seconds) {
90
99
  }
91
100
  }
92
101
  const logTail = async (path) => firstErrors(await readFile(path, "utf8").catch(() => ""));
102
+ // Runs the build and install. Returns why it failed; undefined when the app is
103
+ // installed.
104
+ async function runBuild(command, cwd, logPath, env, options) {
105
+ const seconds = options.timeoutSeconds ?? defaultTimeoutSeconds;
106
+ const build = startLogged(command, { cwd, logPath, env });
107
+ const outcome = await withTimeout(build.exited, seconds);
108
+ if (outcome === 0)
109
+ return undefined;
110
+ build.kill();
111
+ const text = await readFile(logPath, "utf8").catch(() => "");
112
+ // Expo's own open step timed out after the install; EMD opens the app next.
113
+ if (outcome !== "timeout" && onlyOpenFailed(text))
114
+ return undefined;
115
+ const fix = knownFix(text);
116
+ let reason = `The build failed (exit ${outcome}).`;
117
+ if (outcome === "timeout") {
118
+ reason = `The build did not finish in ${seconds}s.`;
119
+ }
120
+ else if (fix) {
121
+ reason = fix;
122
+ }
123
+ else if (text.includes("\u203a Build Succeeded")) {
124
+ reason = `The app compiled, but the install or open step failed (exit ${outcome}).`;
125
+ }
126
+ return { reason, errors: firstErrors(text) };
127
+ }
93
128
  export async function launch(options = {}, report = () => { }) {
94
129
  const started = Date.now();
95
130
  const seconds = () => Math.round((Date.now() - started) / 100) / 10;
@@ -213,27 +248,35 @@ export async function launch(options = {}, report = () => { }) {
213
248
  : `The dev server was not ready after ${metroStartSeconds}s.`, { errors: await logTail(metroLog) });
214
249
  }
215
250
  confirm(root, "port");
216
- report("building and installing the app");
217
- const build = startLogged(plan.build, { cwd: root, logPath: buildLog, env });
218
- const outcome = await withTimeout(build.exited, options.timeoutSeconds ?? defaultTimeoutSeconds);
219
- if (outcome !== 0) {
220
- build.kill();
221
- const text = await readFile(buildLog, "utf8").catch(() => "");
222
- // Expo's own open step timed out after the install; EMD opens the app next.
223
- if (outcome === "timeout" || !onlyOpenFailed(text)) {
251
+ // Reuse the installed build when nothing native changed. A fingerprint that
252
+ // cannot be computed means a normal build.
253
+ let fingerprint;
254
+ let why;
255
+ try {
256
+ fingerprint = await (await loadAdapter(detected.stack)).fingerprint(root, "ios");
257
+ }
258
+ catch (error) {
259
+ why = `fingerprint failed: ${String(error).split("\n")[0]}`;
260
+ }
261
+ if (fingerprint !== undefined) {
262
+ why = whyBuild(readBuildRecord(derivedData), { fingerprint, port }, await appInstalled(device, appId));
263
+ }
264
+ const reused = why === undefined;
265
+ if (reused) {
266
+ report("reusing the installed build");
267
+ }
268
+ else {
269
+ report("building and installing the app");
270
+ const failure = await runBuild(plan.build, root, buildLog, env, options);
271
+ if (failure) {
224
272
  metro.kill();
225
- const fix = knownFix(text);
226
- let reason = `The build failed (exit ${outcome}).`;
227
- if (outcome === "timeout") {
228
- reason = `The build did not finish in ${options.timeoutSeconds ?? defaultTimeoutSeconds}s.`;
229
- }
230
- else if (fix) {
231
- reason = fix;
232
- }
233
- else if (text.includes("\u203a Build Succeeded")) {
234
- reason = `The app compiled, but the install or open step failed (exit ${outcome}).`;
273
+ return stuck(failure.reason, { errors: failure.errors });
274
+ }
275
+ if (fingerprint !== undefined) {
276
+ try {
277
+ writeBuildRecord(derivedData, { fingerprint, port });
235
278
  }
236
- return stuck(reason, { errors: firstErrors(text) });
279
+ catch { }
237
280
  }
238
281
  }
239
282
  report("launching the app");
@@ -243,27 +286,50 @@ export async function launch(options = {}, report = () => { }) {
243
286
  }
244
287
  catch (error) {
245
288
  metro.kill();
246
- return stuck("Built, but could not capture the app's log.", {
289
+ return stuck(`${reused ? "Reused the build" : "Built"}, but could not capture the app's log.`, {
247
290
  errors: String(error).split("\n").slice(0, 3),
248
291
  });
249
292
  }
250
293
  let appPid;
251
294
  try {
295
+ // A running app still talks to the dev server it started with; a restart
296
+ // makes it load the new JavaScript from this one.
297
+ if (reused)
298
+ await terminateApp(device, appId);
252
299
  appPid = await launchApp(device, appId);
253
300
  }
254
301
  catch (error) {
255
302
  capture.kill();
256
303
  metro.kill();
257
- return stuck(`Built, but launching ${appId} failed.`, {
304
+ return stuck(`${reused ? "Reused the build" : "Built"}, but launching ${appId} failed.`, {
258
305
  errors: String(error).split("\n").slice(0, 3),
259
306
  });
260
307
  }
308
+ const axe = (await detectEnvironment()).axe;
309
+ report("waiting for the screen");
310
+ // This device is EMD's own clone. On some iOS versions AXe reads an empty
311
+ // tree until application accessibility is on, and only an app that starts
312
+ // after the write sees it. An AXe error never triggers the write.
313
+ const screen = axe
314
+ ? await untilReadable(() => axeBackend.readScreen(device.id, axe), screenReadSeconds, {
315
+ afterSeconds: emptyTreeSeconds,
316
+ act: async () => {
317
+ if (await appAccessibilityOn(device))
318
+ return;
319
+ await enableAppAccessibility(device);
320
+ await terminateApp(device, appId);
321
+ appPid = await launchApp(device, appId);
322
+ },
323
+ })
324
+ : undefined;
261
325
  return {
262
326
  verdict: "launched",
263
327
  root,
264
328
  ...where,
265
329
  appId,
330
+ ...(screen && { screen }),
266
331
  appPid,
332
+ build: reused ? { action: "reused" } : { action: "built", reason: why },
267
333
  metro: { pid: metro.pid, port },
268
334
  logStream: { pid: capture.pid },
269
335
  derivedData,
@@ -57,6 +57,17 @@ export declare const launchResultSchema: z.ZodObject<{
57
57
  logStream: z.ZodOptional<z.ZodObject<{
58
58
  pid: z.ZodNumber;
59
59
  }, z.core.$strip>>;
60
+ build: z.ZodOptional<z.ZodObject<{
61
+ action: z.ZodEnum<{
62
+ built: "built";
63
+ reused: "reused";
64
+ }>;
65
+ reason: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strip>>;
67
+ screen: z.ZodOptional<z.ZodObject<{
68
+ waited: z.ZodNumber;
69
+ error: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>>;
60
71
  derivedData: z.ZodOptional<z.ZodString>;
61
72
  diskMB: z.ZodOptional<z.ZodObject<{
62
73
  derivedData: z.ZodNumber;
@@ -126,6 +137,7 @@ export declare const inputResultSchema: z.ZodObject<{
126
137
  }>;
127
138
  reason: z.ZodString;
128
139
  }, z.core.$strip>>>;
140
+ seconds: z.ZodOptional<z.ZodNumber>;
129
141
  }, z.core.$strip>;
130
142
  export type InputResult = z.infer<typeof inputResultSchema>;
131
143
  export declare const evidenceResultSchema: z.ZodObject<{
@@ -180,6 +192,17 @@ export declare const jobViewSchema: z.ZodObject<{
180
192
  logStream: z.ZodOptional<z.ZodObject<{
181
193
  pid: z.ZodNumber;
182
194
  }, z.core.$strip>>;
195
+ build: z.ZodOptional<z.ZodObject<{
196
+ action: z.ZodEnum<{
197
+ built: "built";
198
+ reused: "reused";
199
+ }>;
200
+ reason: z.ZodOptional<z.ZodString>;
201
+ }, z.core.$strip>>;
202
+ screen: z.ZodOptional<z.ZodObject<{
203
+ waited: z.ZodNumber;
204
+ error: z.ZodOptional<z.ZodString>;
205
+ }, z.core.$strip>>;
183
206
  derivedData: z.ZodOptional<z.ZodString>;
184
207
  diskMB: z.ZodOptional<z.ZodObject<{
185
208
  derivedData: z.ZodNumber;
@@ -38,6 +38,19 @@ export const launchResultSchema = z.object({
38
38
  // The log stream that captures the app's tagged lines; the next launch in
39
39
  // this worktree stops it.
40
40
  logStream: z.object({ pid: z.number() }).optional(),
41
+ // Whether the Xcode build ran or an installed build was reused; why it ran.
42
+ build: z
43
+ .object({
44
+ action: z.enum(["built", "reused"]),
45
+ reason: z.string().optional(),
46
+ })
47
+ .optional(),
48
+ // Set when AXe is installed: seconds `launch` waited until AXe could read the
49
+ // app's screen, and AXe's last error when the time ran out (the verdict stays
50
+ // launched).
51
+ screen: z
52
+ .object({ waited: z.number(), error: z.string().optional() })
53
+ .optional(),
41
54
  // This worktree's own build folder, and what it and its simulator weigh.
42
55
  derivedData: z.string().optional(),
43
56
  diskMB: z
@@ -103,6 +116,9 @@ export const inputResultSchema = z.object({
103
116
  reason: z.string().optional(),
104
117
  backend: z.enum(backendIds).optional(),
105
118
  fellBack: fellBackSchema,
119
+ // A tap by testID or text: seconds from start to finish, which includes
120
+ // the wait for the element.
121
+ seconds: z.number().optional(),
106
122
  });
107
123
  export const evidenceResultSchema = z.object({
108
124
  verdict: z.enum(["written", "failed"]),
@@ -10,7 +10,11 @@ export declare function newerThan(device: Device, sdk: number[]): boolean;
10
10
  export declare function simulatorSdk(): Promise<number[] | undefined>;
11
11
  export declare function parseSdkVersion(output: string): number[] | undefined;
12
12
  export declare function boot(device: Device): Promise<void>;
13
+ export declare function appAccessibilityOn(device: Device): Promise<boolean>;
14
+ export declare function enableAppAccessibility(device: Device): Promise<void>;
15
+ export declare function terminateApp(device: Device, appId: string): Promise<void>;
13
16
  export declare function launchApp(device: Device, appId: string): Promise<number>;
17
+ export declare function appInstalled(device: Device, appId: string): Promise<boolean>;
14
18
  export declare function cloneDevice(base: Device, name: string): Promise<string>;
15
19
  export type Simulator = {
16
20
  id: string;
@@ -70,6 +70,49 @@ export async function boot(device) {
70
70
  }
71
71
  await runTool("simctl bootstatus", "xcrun", ["simctl", "bootstatus", device.id, "-b"], 300);
72
72
  }
73
+ const accessibilityKey = "ApplicationAccessibilityEnabled";
74
+ // Whether application accessibility is on. An app that starts while it is off
75
+ // can show AXe an empty tree on some iOS versions (docs/findings.md).
76
+ export async function appAccessibilityOn(device) {
77
+ try {
78
+ const { stdout } = await runTool("simctl spawn defaults read", "xcrun", [
79
+ "simctl",
80
+ "spawn",
81
+ device.id,
82
+ "defaults",
83
+ "read",
84
+ "com.apple.Accessibility",
85
+ accessibilityKey,
86
+ ], 60);
87
+ return stdout.trim() === "1";
88
+ }
89
+ catch {
90
+ return false;
91
+ }
92
+ }
93
+ // Turns it on, on a simulator EMD made. The setting stays on the device; an
94
+ // app that is already running must restart to see it.
95
+ export async function enableAppAccessibility(device) {
96
+ await runTool("simctl spawn defaults write", "xcrun", [
97
+ "simctl",
98
+ "spawn",
99
+ device.id,
100
+ "defaults",
101
+ "write",
102
+ "com.apple.Accessibility",
103
+ accessibilityKey,
104
+ "-bool",
105
+ "true",
106
+ ], 60);
107
+ }
108
+ // Stops the app if it runs; a later launch then starts it fresh. Not running is
109
+ // not a failure.
110
+ export async function terminateApp(device, appId) {
111
+ try {
112
+ await runTool("simctl terminate", "xcrun", ["simctl", "terminate", device.id, appId], 60);
113
+ }
114
+ catch { }
115
+ }
73
116
  // Returns the app's pid. Brings the app forward if it is already running.
74
117
  export async function launchApp(device, appId) {
75
118
  const { stdout } = await runTool("simctl launch", "xcrun", ["simctl", "launch", device.id, appId], 120);
@@ -78,6 +121,16 @@ export async function launchApp(device, appId) {
78
121
  throw new Error(`unexpected output: ${stdout}`);
79
122
  return pid;
80
123
  }
124
+ // True when the app is installed on the device.
125
+ export async function appInstalled(device, appId) {
126
+ try {
127
+ await runTool("simctl get_app_container", "xcrun", ["simctl", "get_app_container", device.id, appId], 60);
128
+ return true;
129
+ }
130
+ catch {
131
+ return false;
132
+ }
133
+ }
81
134
  // A new simulator with the same type and runtime as `base`; returns its UDID.
82
135
  // The base must be shut down.
83
136
  export async function cloneDevice(base, name) {
@@ -1,7 +1,7 @@
1
1
  import { McpServer } from "@modelcontextprotocol/server";
2
2
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
3
3
  import { z } from "zod";
4
- import { detect, detectResultSchema, directions, evidence, evidenceResultSchema, inputResultSchema, jobStatus, jobViewSchema, logs, logsResultSchema, startJob, swipe, tap, typeText, version, } from "../core/index.js";
4
+ import { detect, detectResultSchema, directions, evidence, evidenceResultSchema, inputResultSchema, jobViewSchema, logs, logsResultSchema, startJob, swipe, tap, typeText, version, waitForJob, } from "../core/index.js";
5
5
  const reply = (result) => ({
6
6
  content: [{ type: "text", text: JSON.stringify(result) }],
7
7
  structuredContent: result,
@@ -25,7 +25,7 @@ function buildServer() {
25
25
  };
26
26
  });
27
27
  server.registerTool("launch", {
28
- description: "Start building the app, installing it on an iOS simulator and launching it, leaving its dev server running. Returns a job within seconds; the work takes up to minutes. Call job_status with the jobId every 5 to 10 seconds until status is succeeded or failed.",
28
+ description: "Start building the app, installing it on an iOS simulator and launching it, leaving its dev server running. Returns a job within seconds; the work takes up to minutes. Then call job_status with the jobId until status is succeeded or failed.",
29
29
  inputSchema: z.object({
30
30
  dir: z
31
31
  .string()
@@ -50,13 +50,14 @@ function buildServer() {
50
50
  };
51
51
  });
52
52
  server.registerTool("job_status", {
53
- description: "Where a job is: queued, running (with the current step and seconds), succeeded or failed. When finished, includes the result. For launch: the device, app ID and log directory, or on failure the reason and the first relevant error lines, not the log. For check: the verdict, which expectations were found, and a screenshot path.",
53
+ description: "Where a job is: queued, running (with the current step and seconds), succeeded or failed. Waits up to waitSeconds (default 50) and returns as soon as the job ends, so call it again right away if it is still running; do not sleep or poll in between. When finished, includes the result. For launch: the device, app ID and log directory, or on failure the reason and the first relevant error lines, not the log. For check: the verdict, which expectations were found, and a screenshot path.",
54
54
  inputSchema: z.object({
55
55
  jobId: z.string().describe("The jobId a tool such as launch returned."),
56
+ waitSeconds: z.number().min(0).max(110).optional(),
56
57
  }),
57
58
  outputSchema: jobViewSchema,
58
- }, async ({ jobId }) => {
59
- const job = jobStatus(jobId);
59
+ }, async ({ jobId, waitSeconds }) => {
60
+ const job = await waitForJob(jobId, waitSeconds ?? 50);
60
61
  if (!job) {
61
62
  return {
62
63
  isError: true,
@@ -93,7 +94,7 @@ function buildServer() {
93
94
  };
94
95
  });
95
96
  server.registerTool("check", {
96
- description: "Check a run against what you expect, from signals a machine can read, not your own judgment: tagged log events the app wrote ([EMD:<tag>] lines) and elements on the simulator's screen (by testID or by text). After a tap, type or swipe, check right away; a check reads again for up to 10 s what is still missing. Starts a job and returns it within seconds; poll job_status until it finishes, which can take a minute. The result's verdict is passed, failed (fix the cause and check again), stopped (the retry limit is reached: stop and report what is missing) or error (the check could not run; not counted). Your reading of the returned screenshot may be passed as agentReading; it is recorded as a second opinion and never changes the verdict.",
97
+ description: "Check a run against what you expect, from signals a machine can read, not your own judgment: tagged log events the app wrote ([EMD:<tag>] lines) and elements on the simulator's screen (by testID or by text). After a tap, type or swipe, check right away; a check reads again for up to 10 s what is still missing. Starts a job and returns it within seconds; call job_status until it finishes, which can take a minute. The result's verdict is passed, failed (fix the cause and check again), stopped (the retry limit is reached: stop and report what is missing) or error (the check could not run; not counted). Your reading of the returned screenshot may be passed as agentReading; it is recorded as a second opinion and never changes the verdict.",
97
98
  inputSchema: z.object({
98
99
  jobId: z.string().describe("The launch job whose run to check."),
99
100
  logs: z
@@ -137,7 +138,7 @@ function buildServer() {
137
138
  });
138
139
  const jobId = z.string().describe("The launch job whose app to act on.");
139
140
  server.registerTool("tap", {
140
- description: "Tap the launched app: an element by testID or by visible text, or a point. Give one target. Waits up to 5 s for the element. A result of ok means the tap was sent; call check to see what the app did.",
141
+ description: "Tap the launched app: an element by testID or by visible text, or a point. Give one target. Waits up to 10 s for the element, and the result's seconds says how long the tap took. If it never appears, nothing is tapped. A result of ok means the tap was sent; call check to see what the app did.",
141
142
  inputSchema: z.object({
142
143
  jobId,
143
144
  id: z.string().optional().describe("The element's testID."),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emd-agents",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Build, run, check and prove mobile changes from any coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,6 +42,8 @@
42
42
  "@biomejs/biome": "^2.6.4",
43
43
  "@commitlint/cli": "^21.2.4",
44
44
  "@commitlint/config-conventional": "^21.2.4",
45
+ "@commitlint/lint": "^21.2.4",
46
+ "@commitlint/load": "^21.2.4",
45
47
  "@modelcontextprotocol/client": "^2.4.0",
46
48
  "@types/node": "^22.0.0",
47
49
  "@types/proper-lockfile": "^4.1.4",
@@ -18,8 +18,10 @@ Run `npx -y emd-agents@latest setup --dry-run` and show the user its plan. Run i
18
18
 
19
19
  ## The loop
20
20
 
21
+ After you change code, call `launch` again before you `check` or `tap`. The dev server does not reload edits, and a relaunch takes seconds when nothing native changed.
22
+
21
23
  1. `launch` with `dir` set to the app folder. It returns a `jobId` at once.
22
- 2. `job_status` every 5 to 10 seconds, until `succeeded` or `failed`. A first build takes minutes. A failed launch gives the reason and the first error lines: fix the cause and launch again.
24
+ 2. `job_status` with the `jobId`, until `succeeded` or `failed`. A first build takes minutes. A failed launch gives the reason and the first error lines: fix the cause and launch again.
23
25
  3. `tap` with the `jobId`, and a testID (`id`) or a visible `text`. Use a point only when the element has neither. `type` types into the field that has focus, so tap the field first. `swipe` scrolls. A result of `ok` means the gesture was sent; the next `check` shows what the app did.
24
26
  4. `logs`, to read the tagged lines of this run.
25
27
  5. `check` with the expected log events and elements and a `name` for the moment, e.g. `after-save`. A later check under that name must keep the first expectations unchanged; it can add more. Then `job_status` until it ends: