Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Use the task-bound Harness for compact tool discovery in Recipe Cook. Verify the adapter and checkout at setup, then look up only the recipe or action needed. For a dev or fix-bug debrief requested directly in chat, identify the instruction or tool output that would have saved the most time. ([#311](https://github.com/MetaMask/skills/pull/311))
- Record Recipe Cook's final PR proof from the clean commit proposed for publication. Preserve the selected attempt's screenshot paths when Pretty PR packages evidence. ([#311](https://github.com/MetaMask/skills/pull/311))
- Update `testing/mobile-visual-testing` for `@metamask/client-mcp-core` 0.16.1 and `@metamask/device-mcp` 0.10.0. Refs of unnamed or `ambiguous` nodes only work with `mm click`, which taps them at their bounds (`target` ends in ` (bounds)`); other target commands refuse them with `MM_TARGET_NOT_FOUND` and a `hint`. An unknown command or a bad `launch` value exits 2 before any daemon starts, and a non-integer numeric flag such as `--timeout abc` exits 2 instead of being dropped. iOS `mm type <field> ""` exits 0, `mm cdp` and `mm hermes-targets` keep the Metro port the launch resolved from `MM_METRO_PORT`, and daemon log lines name the call's target. ([#329](https://github.com/MetaMask/skills/pull/329))
- Update `testing/visual-testing` for `@metamask/client-mcp-core` 0.16.1. `mm screenshot --selector` or `--frame` with `--timeout` waits that long for a missing element (without it, the command still fails after 2 s with `MM_TARGET_NOT_FOUND`), and the TradingView chart notes say that its canvas is in a nested iframe that `--frame` does not enter. ([#328](https://github.com/MetaMask/skills/pull/328))
- Update `testing/visual-testing` for `@metamask/client-mcp-core` 0.16.0. An unknown command or a bad `launch` value exits 2 with `MM_INVALID_INPUT`, a target that matches several elements fails with `MM_TARGET_NOT_FOUND`, `mm screenshot --selector` takes `--timeout` and fails after 2 s with `MM_TARGET_NOT_FOUND` when nothing matches, a `--frame` wrapper with one iframe resolves to that iframe, `mm mock-network requests` redacts URLs, and daemon log lines name the call's target. ([#316](https://github.com/MetaMask/skills/pull/316))
- Update `testing/visual-testing` for `@metamask/client-mcp-core` 0.15.0. Add `mm events mark`, `mm logs` and `mm network` with a per-flow recipe in place of `console.error` hooks and CDP network capture, `mm cdp --target sw` and `--fresh`, iframe refs and `--frame`, `mm screenshot --selector`, mock-network request bodies and service-worker, offscreen and snap matching, the hidden-checkbox `clickedLabel` click, the `ref` shorthand in `run-steps`, and the one timeout budget with `MM_QUEUE_TIMEOUT`. ([#297](https://github.com/MetaMask/skills/pull/297))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ These flags work with every command and can appear anywhere in the command line.

Observations contain `testIds` and `a11y` only, no app state. The mobile a11y tree is flat: layout-only nodes, the status bar, the navigation bar and the Expo dev-launcher "Tools" button are filtered out (the button is still drawn, and can cover a target). The Android soft keyboard is not: while it is open, its `com.google.android.inputmethod.latin:id/*` IDs appear.

A mobile ref is resolved again at tap time, by the node's test ID or, without one, by its label and type, and the first matching element in the tree is tapped. A node with `"ambiguous": true` shares that identity with other nodes, so its ref can tap another one; a label-only ref can also match an element that has a test ID and the same text. Prefer a unique `--testid`.
A mobile ref of a node with a test ID, label or text that no other node shares is resolved again at action time by that identity. Two kinds of ref only work with `mm click`: refs of nodes with no test ID, label or text, and refs marked `"ambiguous": true` (another node has the same test ID, or the same label or text and type). `mm click` taps the listed element at its `bounds`, and the result's `target` ends in ` (bounds)`. If the element is no longer at those bounds, the click fails with `MM_TARGET_NOT_FOUND` and taps nothing: run `describe-screen` again. `type`, `wait-for`, `get-text`, `scroll-to-element` and `long-press` refuse such a ref with `MM_TARGET_NOT_FOUND` (exit 4) and send nothing to the device; the `hint` says what to use instead (a unique `--testid`, `mm click <ref>`, or `mm tap-coordinates <x> <y>`).

After a mutating call, an observation that takes longer than 8 s does not fail the call: it is `{"timedOut": true}` with no tree and does not replace the diff baseline. Run `describe-screen` before you use refs.

Expand All @@ -104,7 +104,7 @@ Branch on `error.code` or the exit code, never on the message text. `error.retry
| 5 | timeout (click, type, queue and request timeouts: state unknown) |
| 6 | platform, device, Metro or Hermes not available |

Exit 0 is success. Exit 7 is reserved for a daemon version mismatch. Without a daemon, any command that needs one, including an unknown command, exits 3 (`MM_DAEMON_NOT_RUNNING`) before it is validated.
Exit 0 is success. Exit 7 is reserved for a daemon version mismatch. An unknown command, or a bad `launch` value such as `--platform foo`, exits 2 with `MM_INVALID_INPUT` before any daemon starts. A numeric flag whose value is not an integer also exits 2 (`--timeout expects an integer, got "abc"`), but only once a daemon runs; with no daemon, that command exits 3 (`MM_DAEMON_NOT_RUNNING`).

`mm stop` is the exception: it prints plain text, not JSON (`Daemon stopped (was PID <pid> on port <port>).`). With no daemon it prints `No daemon is running.` on stderr and exits 0. See [error-recovery.md](error-recovery.md#reading-a-failure) for recovery per code.

Expand Down Expand Up @@ -179,7 +179,7 @@ The generic core package may display environment-selection and test-state comman
| Command | Description |
| --- | --- |
| `mm click <ref>` | Click by accessibility reference or test ID |
| `mm type <ref> <text>` | Clear and type into an editable element. `""` clears it (Android: exit 0; iOS: the field is cleared, but the call exits 4 with `MM_TYPE_FAILED`) |
| `mm type <ref> <text>` | Clear and type into an editable element. `""` clears it and exits 0 with `textLength: 0` |
| `mm get-text <ref>` | Read an element's text |
| `mm wait-for <ref>` | Wait for an element to become visible |
| `mm scroll-to-element <ref>` | Swipe until the element is inside the viewport |
Expand Down Expand Up @@ -290,7 +290,7 @@ mm cdp Runtime.evaluate '{"expression":"1+1","returnByValue":true}' --timeout 30
| `--app-id <id>` | Use this app identity for this call only (`io.metamask.MetaMask` on iOS, `io.metamask` on Android) |
| `--target hermes\|android-webview` | `hermes` (default): the React Native runtime. `android-webview`: a debuggable in-app WebView (Android only, not validated) |

`cdp` uses the Metro port of the session: the launch `--metro-port <port>` or `MM_METRO_PORT`, else `HERMES_METRO_PORT`, else 8081. The session keeps one Hermes connection: the first call connects, so it can take a bit longer, and later calls reuse it. A call with `--metro-port` or `--app-id` uses a one-shot connection and leaves the session's connection alone. A failure names the port: `MM_CDP_FAILED` (exit 1), `[HERMES_CONNECTION_FAILED] Hermes CDP connection failed: fetch failed (Metro port 8099)`.
`cdp` uses the Metro port of the session: the launch `--metro-port <port>`, else the port the launch resolved from `MM_METRO_PORT`, else `HERMES_METRO_PORT`, else 8081. The session keeps one Hermes connection: the first call connects, so it can take a bit longer, and later calls reuse it. A call with `--metro-port` or `--app-id` uses a one-shot connection and leaves the session's connection alone. A failure names the port: `MM_CDP_FAILED` (exit 1), `[HERMES_CONNECTION_FAILED] Hermes CDP connection failed: fetch failed (Metro port 8099)`.

### `mm hermes-targets [flags]`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ A failed command prints **one JSON line on stdout** and exits non-zero:
- `error.hint` is optional. `error.retryable` is always present and is `true` only when running the same command again, unchanged, is safe (reads and waits). It is `false` for click, type, queue and request timeouts, because the action state is unknown.
- `meta` is present when the daemon answered. A usage error the CLI rejects before sending (exit 2) and a missing daemon (exit 3) have none; a daemon-side schema `VALIDATION_ERROR` does.
- A successful result has **no** `ok` field. `mm stop` still prints plain text (`Daemon stopped (was PID <pid> on port <port>).`, or `No daemon is running.` on stderr with exit 0).
- Without a daemon, an unknown command exits 3 (`MM_DAEMON_NOT_RUNNING`), not 2: the daemon check runs first.
- An unknown command, or a bad `launch` value, exits 2 (`MM_INVALID_INPUT`) before any daemon starts. A non-integer numeric flag (`--timeout abc`) exits 2 once a daemon runs, and 3 (`MM_DAEMON_NOT_RUNNING`) with no daemon.

| Exit | Meaning | Codes (examples) |
| --- | --- | --- |
Expand All @@ -64,13 +64,13 @@ Launch errors use the core `ErrorCode` set. `launch` preserves any consumer-thro

| Code | Exit | Meaning and recovery |
| --- | --- | --- |
| `MM_TARGET_NOT_FOUND` | 4 | The element is not in the UI tree, or the reference is stale or not targetable (`Unknown a11yRef`; for `scroll-to-element`: never found). Run `mm describe-screen` and target again; a conditionally rendered section can unmount a test ID that an earlier snapshot had. A message that says `Use device_snapshot` names an MCP tool; the CLI equivalent is `mm describe-screen`. |
| `MM_TARGET_NOT_FOUND` | 4 | The element is not in the UI tree, or the reference is stale (`Unknown a11yRef`; for `scroll-to-element`: never found). A ref of a node with no test ID, label or text, or marked `ambiguous`, works only with `mm click`: other commands refuse it at once and send nothing (follow the `hint`), and a click fails when the element is no longer at its `bounds` (`not found at its snapshot bounds`; nothing was tapped). Run `mm describe-screen` and target again; a conditionally rendered section can unmount a test ID that an earlier snapshot had. A message that says `Use device_snapshot` names an MCP tool; the CLI equivalent is `mm describe-screen`. |
| `MM_TARGET_NOT_VISIBLE` | 4 | The element was found but is outside the viewport: a tap on an off-screen element, or `scroll-to-element` that could not bring it into view. Run `mm scroll-to-element`, then tap. When the failing command **is** `scroll-to-element`, its hint is not useful: run `describe-screen`, check the element still exists and its `bounds`, try the other `--direction`, or tap the center of `bounds` with `mm tap-coordinates`. |
| `MM_WAIT_TIMEOUT` | 5 | The element did not appear before the deadline. `retryable: true`. Verify the screen and increase `--timeout` if the app is still transitioning. |
| `MM_TARGET_OBSCURED` | 4 | iOS and Android: another element (keyboard, sheet, overlay, the Expo "Tools" button of dev builds) covers the tap point, so nothing was tapped. The message names the cover. Close the keyboard with `mm click … --dismiss-keyboard`, or close or move the overlay first. |
| `MM_CLICK_FAILED` | 4 | The click failed for another reason. On mobile a `--testid` that never appeared usually ends here (the driver's wait timed out) rather than in `MM_TARGET_NOT_FOUND` / `MM_CLICK_TIMEOUT`. Check the test ID with `list-testids`, then re-describe. |
| `MM_CLICK_TIMEOUT` | 5 | The click hung after the element was found; the state is unknown. Describe the screen before retrying. |
| `MM_TYPE_FAILED` | 4 | The target may not be editable. Verify the selected element and keyboard state. On iOS, `mm type <field> ""` ends here (`idb ui text` rejects empty text) after the field was cleared. |
| `MM_TYPE_FAILED` | 4 | The target may not be editable. Verify the selected element and keyboard state. |
| `MM_TYPE_TIMEOUT` | 5 | Input stalled; the state is unknown. Describe the screen, obtain a fresh target, and retry. |
| `MM_GETTEXT_FAILED` | 4 | The target detached or does not expose text. Re-describe and re-target. |
| `MM_GETTEXT_TIMEOUT` | 5 | Text retrieval exceeded the deadline. Retry with a fresh target or larger `--timeout`. |
Expand Down Expand Up @@ -135,10 +135,10 @@ On mobile the screenshot is written to device-mcp's own temporary directory (`
| `MM_TARGET_NOT_VISIBLE` from `scroll-to-element` (exit 4) | The element is in the tree but never came into the viewport | `describe-screen`, check its `bounds`, try the other `--direction`, raise `--maxAttempts`, or tap the center of `bounds` with `mm tap-coordinates` |
| `MM_TARGET_NOT_FOUND` from `scroll-to-element` (exit 4) | The element left the tree (conditionally rendered section) or the ID is wrong | `describe-screen` to confirm it still exists; re-open the screen that renders it |
| `MM_TARGET_OBSCURED` (exit 4) | The keyboard, a sheet or an overlay covers the tap point; nothing was tapped | `mm click … --dismiss-keyboard`, or close the overlay first. In a dev build, the cover can be the Expo "Tools" button; see the overlay's Gotchas |
| The tap opened another screen than expected | A ref that is `ambiguous` or has no test ID matched another element with the same identity | Go back without acting on the new screen; tap by a unique `--testid` |
| The tap opened another screen than expected | A `--testid` with no exact match matched a longer test ID by substring, or a stale ref | Go back without acting on the new screen; check `list-testids` and tap by a unique `--testid` |
| `observations: {"timedOut": true}` | The observation took longer than 8 s; the action itself succeeded | `mm describe-screen` before you use refs |
| `MM_TOOL_NOT_SUPPORTED_ON_PLATFORM` (exit 6) | A browser-only command on a mobile session | Use visible mobile UI interactions; see [cli-reference.md](cli-reference.md#browser-only) |
| Interaction timeout | Animation, overlay, or stale/ambiguous target | Re-`describe-screen`, target by a unique test ID or fresh a11y ref (no `--within` on mobile), and increase `--timeout` only when appropriate |
| Interaction timeout | Animation, overlay, or stale target | Re-`describe-screen`, target by a unique test ID or fresh a11y ref (no `--within` on mobile), and increase `--timeout` only when appropriate |
| `--testId` times out | Incorrect capitalization | Use `--testid` in lowercase |
| Daemon address already in use | Stale daemon state (`MM_PORT_IN_USE`) | Run `mm stop --force`, then `mm launch` |

Expand All @@ -159,7 +159,7 @@ If the CLI hangs or returns connection errors:

1. Check status: `mm status`.
2. Stop stale state: `mm stop --force`.
3. Inspect `.mm-daemon.log`. Every request line ends with the outcome, for example `POST /tool/scroll_to_element 200 ok=false code=MM_TARGET_NOT_VISIBLE 15957ms`; `grep ok=false .mm-daemon.log` lists the failed calls of a run.
3. Inspect `.mm-daemon.log`. Every request line has the outcome and what the call acted on (`testid=`, `ref=`, `direction=`, …), for example `POST /tool/scroll_to_element 200 ok=false code=MM_TARGET_NOT_VISIBLE testid=import-token-button 15957ms`; `grep ok=false .mm-daemon.log` lists the failed calls of a run.
4. Restart with `mm launch`.

The daemon shuts down after 30 minutes of inactivity. Its state is stored in `.mm-server` at the project root, isolated per worktree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Two additional log sources complement the JS interceptors:

### Daemon log

Records CLI events, session lifecycle, and tool execution timing.
Records CLI events, session lifecycle, and tool execution timing. Each request line has the outcome and what the call acted on (`testid=`, `ref=`, `method=`, …); typed text is never logged.

```bash
# Read last 50 lines
Expand Down
Loading