Skip to content

Commit b398c41

Browse files
committed
refactor: add interactor doubleTap and alias docs
1 parent ee68d36 commit b398c41

5 files changed

Lines changed: 31 additions & 12 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ npx agent-device open SampleApp
3434
## Quick Start
3535

3636
Use refs for agent-driven exploration and normal automation flows.
37+
Use `press` as the canonical tap command; `click` is an equivalent alias.
3738

3839
```bash
3940
agent-device open Contacts --platform ios # creates session on iOS Simulator
@@ -56,7 +57,7 @@ Basic flow:
5657
```bash
5758
agent-device open SampleApp
5859
agent-device snapshot
59-
agent-device click @e7
60+
agent-device press @e7
6061
agent-device fill @e8 "hello"
6162
agent-device close SampleApp
6263
```
@@ -73,7 +74,8 @@ agent-device trace stop ./trace.log
7374
Coordinates:
7475
- All coordinate-based commands (`press`, `long-press`, `swipe`, `focus`, `fill`) use device coordinates with origin at top-left.
7576
- X increases to the right, Y increases downward.
76-
- `click` and `press` both accept `x y`, `@ref`, and selector targets.
77+
- `press` is the canonical tap command.
78+
- `click` is an equivalent alias and accepts the same targets (`x y`, `@ref`, selector) and flags.
7779

7880
Gesture series examples:
7981

@@ -87,7 +89,7 @@ agent-device swipe 540 1500 540 500 120 --count 8 --pause-ms 30 --pattern ping-p
8789
## Command Index
8890
- `boot`, `open`, `close`, `reinstall`, `home`, `back`, `app-switcher`
8991
- `snapshot`, `find`, `get`
90-
- `click`, `focus`, `type`, `fill`, `press`, `long-press`, `swipe`, `scroll`, `scrollintoview`, `pinch`, `is`
92+
- `press` (alias: `click`), `focus`, `type`, `fill`, `long-press`, `swipe`, `scroll`, `scrollintoview`, `pinch`, `is`
9193
- `alert`, `wait`, `screenshot`
9294
- `trace start`, `trace stop`
9395
- `settings wifi|airplane|location on|off`

skills/agent-device/SKILL.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ npx -y agent-device
2929

3030
1. Open app or deep link: `open [app|url] [url]` (`open` handles target selection + boot/activation in the normal flow)
3131
2. Snapshot: `snapshot` to get refs from accessibility tree
32-
3. Interact using refs (`click @ref`, `fill @ref "text"`)
32+
3. Interact using refs (`press @ref`, `fill @ref "text"`; `click` is an alias of `press`)
3333
4. Re-snapshot after navigation/UI changes
3434
5. Close session when done
3535

@@ -109,14 +109,15 @@ agent-device appstate
109109
### Interactions (use @refs from snapshot)
110110

111111
```bash
112-
agent-device click @e1
112+
agent-device press @e1 # Canonical tap command (`click` is an alias)
113113
agent-device focus @e2
114114
agent-device fill @e2 "text" # Clear then type (Android: verifies value and retries once on mismatch)
115115
agent-device type "text" # Type into focused field without clearing
116116
agent-device press 300 500 # Tap by coordinates
117117
agent-device press 300 500 --count 12 --interval-ms 45
118118
agent-device press 300 500 --count 6 --hold-ms 120 --interval-ms 30 --jitter-px 2
119-
agent-device click @e1 --count 5 --interval-ms 1 --double-tap
119+
agent-device press @e1 --count 5 # Repeat taps on the same target
120+
agent-device press @e1 --count 5 --double-tap # Use double-tap gesture per iteration
120121
agent-device swipe 540 1500 540 500 120
121122
agent-device swipe 540 1500 540 500 120 --count 8 --pause-ms 30 --pattern ping-pong
122123
agent-device long-press 300 500 800 # Long press (where supported)
@@ -179,7 +180,8 @@ agent-device apps --platform android --user-installed
179180

180181
## Best practices
181182

182-
- `click` and `press` both accept `x y`, `@ref`, and selector targets.
183+
- `press` is the canonical tap command; `click` is an alias with the same behavior.
184+
- `press` (and `click`) accepts `x y`, `@ref`, and selector targets.
183185
- `press`/`click` support gesture series controls: `--count`, `--interval-ms`, `--hold-ms`, `--jitter-px`, `--double-tap`.
184186
- `--double-tap` cannot be combined with `--hold-ms` or `--jitter-px`.
185187
- `swipe` supports coordinate + timing controls and repeat patterns: `swipe x1 y1 x2 y2 [durationMs] --count --pause-ms --pattern`.

skills/agent-device/references/snapshot-refs.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Purpose
44

55
Refs are useful for discovery/debugging. For deterministic scripts, use selectors.
6+
For tap interactions, `press` is canonical; `click` is an equivalent alias.
67

78
## Snapshot
89

@@ -24,14 +25,14 @@ App: com.apple.Preferences
2425
## Using refs (discovery/debug)
2526

2627
```bash
27-
agent-device click @e2
28+
agent-device press @e2
2829
agent-device fill @e5 "test"
2930
```
3031

3132
## Using selectors (deterministic)
3233

3334
```bash
34-
agent-device click 'id="camera_row" || label="Camera" role=button'
35+
agent-device press 'id="camera_row" || label="Camera" role=button'
3536
agent-device fill 'id="search_input" editable=true' "test"
3637
agent-device is visible 'id="camera_settings_anchor"'
3738
```

src/core/dispatch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ export async function dispatchCommand(
163163
const targetX = x + dx;
164164
const targetY = y + dy;
165165
if (doubleTap) {
166-
await interactor.tap(targetX, targetY);
167-
await interactor.tap(targetX, targetY);
166+
await interactor.doubleTap(targetX, targetY);
168167
return;
169168
}
170169
if (holdMs > 0) await interactor.longPress(targetX, targetY, holdMs);

src/utils/interactors.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export type Interactor = {
3434
openDevice(): Promise<void>;
3535
close(app: string): Promise<void>;
3636
tap(x: number, y: number): Promise<void>;
37+
doubleTap(x: number, y: number): Promise<void>;
3738
swipe(x1: number, y1: number, x2: number, y2: number, durationMs?: number): Promise<void>;
3839
longPress(x: number, y: number, durationMs?: number): Promise<void>;
3940
focus(x: number, y: number): Promise<void>;
@@ -52,6 +53,10 @@ export function getInteractor(device: DeviceInfo, runnerContext: RunnerContext):
5253
openDevice: () => openAndroidDevice(device),
5354
close: (app) => closeAndroidApp(device, app),
5455
tap: (x, y) => pressAndroid(device, x, y),
56+
doubleTap: async (x, y) => {
57+
await pressAndroid(device, x, y);
58+
await pressAndroid(device, x, y);
59+
},
5560
swipe: (x1, y1, x2, y2, durationMs) => swipeAndroid(device, x1, y1, x2, y2, durationMs),
5661
longPress: (x, y, durationMs) => longPressAndroid(device, x, y, durationMs),
5762
focus: (x, y) => focusAndroid(device, x, y),
@@ -74,7 +79,10 @@ export function getInteractor(device: DeviceInfo, runnerContext: RunnerContext):
7479
}
7580
}
7681

77-
type IoRunnerOverrides = Pick<Interactor, 'tap' | 'swipe' | 'longPress' | 'focus' | 'type' | 'fill' | 'scroll' | 'scrollIntoView'>;
82+
type IoRunnerOverrides = Pick<
83+
Interactor,
84+
'tap' | 'doubleTap' | 'swipe' | 'longPress' | 'focus' | 'type' | 'fill' | 'scroll' | 'scrollIntoView'
85+
>;
7886

7987
function iosRunnerOverrides(device: DeviceInfo, ctx: RunnerContext): IoRunnerOverrides {
8088
const runnerOpts = { verbose: ctx.verbose, logPath: ctx.logPath, traceLogPath: ctx.traceLogPath };
@@ -87,6 +95,13 @@ function iosRunnerOverrides(device: DeviceInfo, ctx: RunnerContext): IoRunnerOve
8795
runnerOpts,
8896
);
8997
},
98+
doubleTap: async (x, y) => {
99+
await runIosRunnerCommand(
100+
device,
101+
{ command: 'tapSeries', x, y, count: 1, intervalMs: 0, doubleTap: true, appBundleId: ctx.appBundleId },
102+
runnerOpts,
103+
);
104+
},
90105
swipe: async (x1, y1, x2, y2, durationMs) => {
91106
await runIosRunnerCommand(
92107
device,

0 commit comments

Comments
 (0)