@swmansion/argent 0.7.1 → 0.8.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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "MCP server for iOS Simulator and Android Emulator control",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,6 +20,7 @@
20
20
  "prepack": "node scripts/sync-readme.cjs",
21
21
  "test": "vitest run",
22
22
  "test:watch": "vitest",
23
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json",
23
24
  "observe": "node scripts/observe.cjs",
24
25
  "benchmark": "node scripts/benchmark.cjs",
25
26
  "postinstall": "node scripts/postinstall.cjs"
@@ -47,14 +48,14 @@
47
48
  "@argent/mcp": "file:../argent-mcp",
48
49
  "@argent/tools-client": "file:../argent-tools-client",
49
50
  "@clack/prompts": "^1.1.0",
50
- "@types/node": "^22.0.0",
51
+ "@types/node": "^25.9.0",
51
52
  "@types/semver": "^7.7.1",
52
- "esbuild": "^0.27.3",
53
+ "esbuild": "^0.28.0",
53
54
  "picocolors": "^1.1.1",
54
55
  "semver": "^7.7.4",
55
56
  "smol-toml": "^1.6.1",
56
- "typescript": "^5.5.0",
57
- "vitest": "^4.0.18",
57
+ "typescript": "^6.0.3",
58
+ "vitest": "^4.1.6",
58
59
  "yaml": "^2.8.3"
59
60
  }
60
61
  }
package/rules/argent.md CHANGED
@@ -36,6 +36,16 @@ If `describe` fails, **read the exact error before reacting**, follow the recove
36
36
  Before starting to interact with the app, read the `argent-device-interact` skill first.
37
37
  </tapping_rule>
38
38
 
39
+ <device_selection_rule>
40
+ Before booting, running, or interacting with any app, call `list-devices` first - prefer running devices.
41
+
42
+ Decision order:
43
+
44
+ 1. **Explicit user intent** - choose the user named platform or device. Look for words "simulator" and "emulator".
45
+ 2. **Prefer a running device.** iOS simulators - state `Booted` and Android devices - `state: "device"` come first in `list-devices`.
46
+ 3. **Single-platform project:** (per `argent-environment-inspector` flags `is_native_ios`/`is_native_android`, or RN with only one platform configured) → boot that platform.
47
+ </device_selection_rule>
48
+
39
49
  <skill_reading_rule>
40
50
  <important>Always read relevant skills for guidance before executing argent-mcp tool - read skill_routing reference</important>
41
51
  </skill_reading_rule>
@@ -48,10 +58,10 @@ Before starting to interact with the app, read the `argent-device-interact` skil
48
58
  - Interaction tools (`gesture-tap`, `gesture-swipe`, `gesture-pinch`, `gesture-rotate`, `gesture-custom`, `launch-app`, etc.) return a screenshot automatically.
49
59
  Call `screenshot` separately only for a baseline before any action or after a delay.
50
60
  - Always open apps with `launch-app` or `open-url` — never tap home screen icons.
51
- - Always use `run-sequence` when performing multiple sequential simulator actions where you don't need to observe the screen between steps. More in `argent-device-interact` skill.
61
+ - Always use `run-sequence` when performing multiple sequential device actions where you don't need to observe the screen between steps. More in `argent-device-interact` skill.
52
62
  - When the session ends or the user says they are done: call `stop-all-simulator-servers`.
53
63
  If the user started Metro separately, ask whether to call `stop-metro` (specify the port if not 8081).
54
- - If tools provided by mcp-server are not sufficient and action can be done using `xcrun` or other commands, use the command. Examples: changing simulator options, performing simulator action such as lock, shake, etc.
64
+ - If tools provided by mcp-server are not sufficient and action can be done using `xcrun`, `adb`, or other commands, use the command. Examples: changing device options, performing a device action such as lock, shake, etc.
55
65
  - When waiting for an action, do not call `screenshot` repeatedly without a proper wait mechanism. For example, six consecutive `screenshot` calls with no adequate delay between them will cause context bloat.
56
66
  </general_rules>
57
67
 
@@ -69,6 +79,9 @@ When `is_react_native` is true: load `argent-react-native-app-workflow` skill. U
69
79
  Load the matching skill before starting work and executing tools from argent-mcp — skills contain the full step-by-step
70
80
  procedure and edge-case handling for each workflow.
71
81
 
82
+ PLATFORM DETECTION
83
+ If the user did not specify a platform, call `list-devices` first and pick the booted target — do not default to iOS.
84
+
72
85
  iOS SIMULATOR SETUP
73
86
  Skill: `argent-ios-simulator-setup`
74
87
  When: Beginning a task that involves the iOS simulator, no simulator booted yet, need UDID or simulator-server.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // @ts-check
3
2
  "use strict";
4
3
 
5
4
  // Runs automatically after `npm install @swmansion/argent`.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: argent-create-flow
3
- description: Record a reusable flow (scripted sequence of MCP tool calls) that can be replayed later with a single command. Use when the user asks to create, record, or build a flow, or to script a sequence of simulator actions.
3
+ description: Record a reusable flow (scripted sequence of MCP tool calls) that can be replayed later with a single command. Use when the user asks to create, record, or build a flow, or to script a sequence of device actions.
4
4
  ---
5
5
 
6
6
  ## 1. Overview
@@ -24,7 +24,7 @@ Use `list-devices` to get a target id. Results are tagged with `platform` (`ios`
24
24
  3. **Use `gesture-swipe` for lists/scrolling**, not `gesture-custom`, unless you need non-linear movement. Consider whether you need multiple swipes, if yes - use `run-sequence`.
25
25
  4. **Tap a text field before typing** — on iOS try `paste` first then fall back to `keyboard`; on Android use `keyboard` directly (`paste` is iOS-only).
26
26
  5. **Coordinates are normalized** — always 0.0–1.0, not pixels.
27
- 6. **For native iOS app navigation, prefer `describe` first.** It works on any screen without app restart. Do not navigate from screenshots on regular in-app screens unless `describe` failed to expose a reliable target. Use `native-describe-screen` only when you need app-scoped UIKit properties.
27
+ 6. **For app navigation, prefer `describe` first.** It works on any screen without app restart. Do not navigate from screenshots on regular in-app screens unless `describe` failed to expose a reliable target. Use `native-describe-screen` only when you need app-scoped UIKit properties.
28
28
 
29
29
  ## 3. Opening Apps
30
30
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: argent-ios-simulator-setup
3
- description: Set up and connect to an iOS simulator using argent MCP tools. Use when starting a new session, booting a simulator, getting a simulator UDID, or before any simulator interaction task.
3
+ description: Set up and connect to an iOS simulator using argent MCP tools. Use when starting a new session, booting an iOS simulator, getting an iOS UDID, or before any iOS simulator interaction task.
4
4
  ---
5
5
 
6
6
  ## 1. Setup Steps
@@ -32,10 +32,10 @@ One Metro port can serve multiple connected devices (e.g. two simulators on `loc
32
32
 
33
33
  ### Reload & recovery
34
34
 
35
- | Tool | Purpose |
36
- | ----------------------- | ---------------------------------------------------------------------------------------- |
37
- | `debugger-reload-metro` | Reload all connected apps (like pressing "r" in Metro terminal). Needs a CDP target. |
38
- | `restart-app` | Terminate and relaunch the app by UDID and bundleId. Use when app lost Metro connection. |
35
+ | Tool | Purpose |
36
+ | ----------------------- | --------------------------------------------------------------------------------------------- |
37
+ | `debugger-reload-metro` | Reload all connected apps (like pressing "r" in Metro terminal). Needs a CDP target. |
38
+ | `restart-app` | Terminate and relaunch the app by device id and bundleId. Use when app lost Metro connection. |
39
39
 
40
40
  ### Inspection & console
41
41
 
@@ -70,7 +70,7 @@ Applies to both `debugger-component-tree` and `debugger-inspect-element`. Set to
70
70
  ## 4. Golden Rules
71
71
 
72
72
  1. **`debugger-status` first when something fails** — it runs discovery, connection, and returns diagnostics.
73
- 2. **"No CDP targets" → get the app to connect to Metro** — use `restart-app` on simulator, then retry `debugger-status`.
73
+ 2. **"No CDP targets" → get the app to connect to Metro** — use `restart-app` on the device, then retry `debugger-status`.
74
74
  3. **Never assume one failure is permanent** — follow recovery steps before asking the user. For starting Metro and full failure recovery, see `argent-react-native-app-workflow` and `references/failure-scenarios.md`.
75
75
 
76
76
  ---
@@ -120,7 +120,7 @@ When reading from the log file:
120
120
  | Diagnose / check connection | `debugger-status` |
121
121
  | Connect to Metro CDP | `debugger-connect` |
122
122
  | Reload JS (already connected) | `debugger-reload-metro` |
123
- | Relaunch app on simulator | `restart-app` |
123
+ | Relaunch app on device | `restart-app` |
124
124
  | Inspect component at point | `debugger-inspect-element` |
125
125
  | Full component tree | `debugger-component-tree` |
126
126
  | Console log overview | `debugger-log-registry` (summary + log file path for `Grep`/`Read`) |
@@ -6,5 +6,5 @@ When a debugger tool fails, use **`debugger-status`** first to diagnose. Then ma
6
6
  | ---------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
7
  | **Metro not running** | Error contains: `Metro at port 8081 is not running (got: ...)` | **Start Metro yourself** unless the user asked you not to: scan the workspace configuration and run the appropriate command to start Metro in the background (by default `npx react-native start` or `npx expo start`). Wait for Metro to be ready, then retry `debugger-connect` or `debugger-status`. If you cannot determine the project root, ask the user. |
8
8
  | **Metro not standard** | Error contains: `Metro at port 8081 did not return X-React-Native-Project-Root header` | Something on that port is not the standard React Native Metro server. Try starting Metro yourself from the app's project root using the command resolution above. If you cannot determine the correct root or the problem persists, inform the user what you found and what you tried. |
9
- | **App not connected** | Error contains: `Metro at port 8081 has no CDP targets — is a React Native app connected?` | 1) Confirm the app is running on simulator or device. 2) If simulator: use `restart-app` with the app's UDID and bundleId to relaunch so it connects to Metro. 3) Wait a few seconds for the bundle to load. 4) Retry `debugger-status`. Do **not** use `debugger-reload-metro` to fix this — it also requires at least one target. |
10
- | **Was connected, then tool fails** | Any debugger tool fails with a connection or disconnect error after it was working | The app may have crashed or been closed. Use `restart-app` (simulator) to relaunch the app, then call `debugger-connect` again to pick up the fresh `logicalDeviceId` (UDID may change for booted-fresh simulators), and use that new `device_id` on all subsequent calls. |
9
+ | **App not connected** | Error contains: `Metro at port 8081 has no CDP targets — is a React Native app connected?` | 1) Confirm the app is running on the device. 2) Use `restart-app` with the app's device id and bundleId to relaunch so it connects to Metro. 3) Wait a few seconds for the bundle to load. 4) Retry `debugger-status`. Do **not** use `debugger-reload-metro` to fix this — it also requires at least one target. |
10
+ | **Was connected, then tool fails** | Any debugger tool fails with a connection or disconnect error after it was working | The app may have crashed or been closed. Use `restart-app` to relaunch the app, then call `debugger-connect` again to pick up the fresh `logicalDeviceId` (may change for booted-fresh simulators), and use that new `device_id` on all subsequent calls. |
@@ -43,22 +43,22 @@ Do NOT default to `npx react-native start` or `npx react-native run-ios` without
43
43
 
44
44
  In a **separate** terminal (Metro keeps running in the first):
45
45
 
46
- **Use the project's custom build/run script if one exists** (e.g. `npm run ios`, `npm run android`, `yarn ios:debug`). Only fall back to the default if no custom scripts are defined:
46
+ **Use the project's custom build/run script if one exists** (e.g. `npm run ios`, `npm run android`, `yarn ios:debug`). Only fall back to the defaults below if no custom scripts are defined.
47
+
48
+ **Pass the target device explicitly** — derive it from `list-devices` (see `<device_selection_rule>`):
47
49
 
48
50
  ```bash
49
- npx react-native run-ios # iOS
50
- npx react-native run-android # Android
51
+ npx react-native run-ios --simulator="<name>" # iOS (or --udid <UDID>)
52
+ npx react-native run-android --deviceId=<adb-serial> # Android
51
53
  ```
52
54
 
53
- Optional: specify the target device, e.g. `npx react-native run-ios --simulator="iPhone 16"` or `npx react-native run-android --deviceId=<serial>`.
54
-
55
55
  **Android only**: after install, run `adb -s <serial> reverse tcp:8081 tcp:8081` so the emulator/device can reach Metro on your host. Repeat if the device restarts or adb drops.
56
56
 
57
57
  **Agent checklist:**
58
58
 
59
59
  - [ ] Metro is already running and shows "ready"
60
60
  - [ ] Command run from project root
61
- - [ ] If the device isn't booted: use `boot-device` with the iOS `udid` or Android `avdName`. Refer to the `argent-ios-simulator-setup` / `argent-android-emulator-setup` skill.
61
+ - [ ] If the device isn't booted yet: use `boot-device` with the iOS `udid` or Android `avdName`. Refer to the `argent-ios-simulator-setup` / `argent-android-emulator-setup` skill.
62
62
  - [ ] Android: `adb -s <serial> reverse tcp:8081 tcp:8081` done.
63
63
 
64
64
  ---
@@ -233,12 +233,13 @@ If the user's intent is ambiguous (run existing tests, write new tests, or find
233
233
 
234
234
  ## Related Skills
235
235
 
236
- | Skill | When to use |
237
- | ------------------------------ | ------------------------------------------------------------------------------- |
238
- | `argent-ios-simulator-setup` | Initial simulator boot and connection setup |
239
- | `argent-device-interact` | Tapping, swiping, typing, hardware buttons, gestures on the simulator/emulator |
240
- | `argent-metro-debugger` | Full Metro CDP debugging: component inspection, console logs, JS evaluation |
241
- | `argent-react-native-profiler` | Profiling performance, finding re-render issues, CPU hotspots |
242
- | `argent-test-ui-flow` | Interactive UI testing with automatic screenshot verification after each action |
236
+ | Skill | When to use |
237
+ | ------------------------------- | ------------------------------------------------------------------------------- |
238
+ | `argent-ios-simulator-setup` | Initial iOS simulator boot and connection setup |
239
+ | `argent-android-emulator-setup` | Initial Android emulator boot and connection setup |
240
+ | `argent-device-interact` | Tapping, swiping, typing, hardware buttons, gestures on the simulator/emulator |
241
+ | `argent-metro-debugger` | Full Metro CDP debugging: component inspection, console logs, JS evaluation |
242
+ | `argent-react-native-profiler` | Profiling performance, finding re-render issues, CPU hotspots |
243
+ | `argent-test-ui-flow` | Interactive UI testing with automatic screenshot verification after each action |
243
244
 
244
245
  Ask the user before running tests: confirm which test suite (unit, E2E, or both), whether to use existing CI commands, and whether they want you to run existing tests, write new ones, or explore test cases yourself.
@@ -13,9 +13,9 @@ description: Optimizes a React Native app by profiling first to find real bottle
13
13
  - **Fix** — apply one fix. Validate with `debugger-evaluate` before committing.
14
14
  - **Re-measure** — report whether the target metric improved, regressed, or stayed flat. Check for regressions in other areas. If no net benefit or unacceptable tradeoffs, revert.
15
15
  - **Profile for discovery, not only verification.** Use the profiler to find issues static analysis missed, not only to confirm fixes.
16
- - **One fix per cycle for architectural changes.** Mechanical batch fixes (inline styles, index keys) can be grouped — re-profile once after the batch. When the measurement involves simulator interaction, record it as a flow (`argent-create-flow` skill) before the first run so all subsequent cycles replay identical steps.
16
+ - **One fix per cycle for architectural changes.** Mechanical batch fixes (inline styles, index keys) can be grouped — re-profile once after the batch. When the measurement involves device interaction, record it as a flow (`argent-create-flow` skill) before the first run so all subsequent cycles replay identical steps.
17
17
  - **React Compiler**: if `react-profiler-analyze` reports `reactCompilerEnabled: true`, do NOT propose `useCallback`/`useMemo`/`React.memo` unless you confirmed compiler bail-out via `react-profiler-fiber-tree` (absent `useMemoCache`).
18
- - **Sub-agents**: Phases 1–2 dispatch sub-agents — one per file for lint results, one per checklist item for semantic. Sub-agents CANNOT touch the simulator - all profiling and E2E verification must happen in the main agent.
18
+ - **Sub-agents**: Phases 1–2 dispatch sub-agents — one per file for lint results, one per checklist item for semantic. Sub-agents CANNOT touch the device - all profiling and E2E verification must happen in the main agent.
19
19
 
20
20
  ## Pipeline
21
21
 
@@ -7,7 +7,9 @@ description: Autonomously test an app UI (iOS or Android) by running interact-sc
7
7
 
8
8
  The interaction tool names are identical on iOS and Android — `gesture-tap`, `gesture-swipe`, `describe`, `screenshot`, `launch-app`, etc. — and the tool-server auto-dispatches based on the `udid` you pass (UUID-shape → iOS, adb serial → Android).
9
9
 
10
- Get a `udid` via:
10
+ **Before testing, resolve which device to test on.** Call `list-devices` and follow `<device_selection_rule>`: prefer a running device on any platform;
11
+
12
+ Once a platform is chosen, the per-platform setup skill takes over:
11
13
 
12
14
  | Platform | Setup skill | Find devices with |
13
15
  | -------- | ------------------------------- | ----------------------------------------------------------- |