Skip to content

Commit 7f1ce40

Browse files
committed
test: cover agent-cdp guidance
1 parent e4da259 commit 7f1ce40

5 files changed

Lines changed: 95 additions & 1 deletion

File tree

skills/agent-device/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Escalate only when relevant:
2727
agent-device help debugging
2828
agent-device help react-native
2929
agent-device help react-devtools
30+
agent-device help agent-cdp
3031
agent-device help remote
3132
agent-device help macos
3233
agent-device help dogfood

test/skillgym/suites/agent-device-smoke-suite.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ const BOUNDED_PROFILE_TIMELINE =
430430
/react-devtools\s+profile\s+timeline\b[^\n]*--limit\s+(?:10|20)\b/i;
431431
const BROAD_PROFILE_SLOW_LIMIT =
432432
/react-devtools\s+profile\s+slow\b[^\n]*--limit\s+(?:[5-9]\d|[1-9]\d{2,})\b/i;
433+
const AGENT_CDP_MEMORY_USAGE_SAMPLE = /agent-cdp\s+memory\s+usage\s+sample\b/i;
434+
const AGENT_CDP_MEMORY_SNAPSHOT_CAPTURE = /agent-cdp\s+memory\s+snapshot\s+capture\b/i;
433435
const IOS_EXPO_GO_OPEN =
434436
/(?:^|\n)(?:agent-device\s+)?open\s+["']Expo Go["']\s+["']?exp:\/\/127\.0\.0\.1:8081["']?/i;
435437

@@ -1646,6 +1648,93 @@ const SKILL_GUIDANCE_CASES: Case[] = [
16461648
plannedCommand('perf frames'),
16471649
],
16481650
}),
1651+
makeCase({
1652+
id: 'react-native-js-heap-leak-cdp-triplet',
1653+
contract: [
1654+
'App name: Agent Device Tester',
1655+
'Platform: iOS simulator',
1656+
'Metro is running at http://127.0.0.1:8081',
1657+
'The app exposes a React Native CDP target through Metro',
1658+
'Symptom: JavaScript heap grows after opening and closing the Cart screen',
1659+
'Need proof that retained JS objects survive cleanup, plus shortest useful retaining paths',
1660+
'This is not a native/process memory investigation',
1661+
],
1662+
task: 'Plan a bounded React Native JS heap leak workflow using agent-cdp: select the Metro CDP target, sample heap usage, capture baseline/action/cleanup snapshots, diff them, run leak-triplet, and inspect retainers for a leaked node.',
1663+
outputs: [
1664+
plannedCommand('agent-cdp target list'),
1665+
/--url\s+http:\/\/127\.0\.0\.1:8081/i,
1666+
plannedCommand('agent-cdp target select'),
1667+
AGENT_CDP_MEMORY_SNAPSHOT_CAPTURE,
1668+
/--name\s+baseline/i,
1669+
/--name\s+(?:after-action|action)/i,
1670+
/--name\s+cleanup/i,
1671+
plannedCommand('agent-cdp memory snapshot diff'),
1672+
plannedCommand('agent-cdp memory snapshot leak-triplet'),
1673+
plannedCommand('agent-cdp memory snapshot retainers'),
1674+
],
1675+
forbiddenOutputs: [
1676+
plannedCommand('perf memory sample'),
1677+
plannedCommand('perf memory snapshot'),
1678+
plannedCommand('react-devtools'),
1679+
plannedCommand('agent-cdp profile cpu'),
1680+
plannedCommand('agent-cdp trace'),
1681+
plannedCommand('agent-cdp network'),
1682+
plannedCommand('agent-cdp console'),
1683+
],
1684+
}),
1685+
makeCase({
1686+
id: 'react-native-js-heap-quick-signal-cdp',
1687+
contract: [
1688+
'App name: Agent Device Tester',
1689+
'Platform: Android emulator',
1690+
'Metro is running at http://127.0.0.1:8081',
1691+
'The app exposes a React Native CDP target through Metro',
1692+
'Symptom: JavaScript heap may grow after filtering the product list',
1693+
'Need only a compact first-pass JS heap growth signal before deciding whether to capture heap snapshots',
1694+
'This is not a native/process memory investigation',
1695+
],
1696+
task: 'Plan the CDP commands to select the Metro target and collect compact before/after JavaScript heap usage samples with GC, then diff the usage samples.',
1697+
outputs: [
1698+
plannedCommand('agent-cdp target list'),
1699+
/--url\s+http:\/\/127\.0\.0\.1:8081/i,
1700+
plannedCommand('agent-cdp target select'),
1701+
AGENT_CDP_MEMORY_USAGE_SAMPLE,
1702+
/--label\s+baseline/i,
1703+
/--label\s+after-action/i,
1704+
plannedCommand('agent-cdp memory usage diff'),
1705+
],
1706+
forbiddenOutputs: [
1707+
plannedCommand('perf memory sample'),
1708+
plannedCommand('perf memory snapshot'),
1709+
AGENT_CDP_MEMORY_SNAPSHOT_CAPTURE,
1710+
plannedCommand('react-devtools'),
1711+
],
1712+
}),
1713+
makeCase({
1714+
id: 'react-native-native-memory-uses-perf-not-cdp',
1715+
contract: [
1716+
'App name: Agent Device Tester',
1717+
'Platform: Android emulator',
1718+
'The app is already open',
1719+
'Symptom: total process RSS/PSS grows while scrolling a native image gallery',
1720+
'Need native/process memory evidence and an Android heap artifact if escalation is needed',
1721+
'This is not a JavaScript heap or retained JS object investigation',
1722+
],
1723+
task: 'Plan the memory diagnostics commands for this native/process memory issue without using CDP heap snapshots.',
1724+
outputs: [
1725+
plannedCommand('perf memory sample'),
1726+
/--json/i,
1727+
plannedCommand('perf memory snapshot'),
1728+
/--kind\s+android-hprof/i,
1729+
/--out\s+\S+\.hprof/i,
1730+
],
1731+
forbiddenOutputs: [
1732+
/agent-cdp/i,
1733+
AGENT_CDP_MEMORY_USAGE_SAMPLE,
1734+
AGENT_CDP_MEMORY_SNAPSHOT_CAPTURE,
1735+
plannedCommand('react-devtools'),
1736+
],
1737+
}),
16491738
makeCase({
16501739
id: 'perf-apple-xctrace-profile',
16511740
contract: [

website/docs/docs/agent-setup.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The bundled [agent-device skill](https://github.com/callstack/agent-device/blob/
4747
Add this as a project rule, custom instruction, or skill equivalent when your agent client supports it:
4848

4949
```text
50-
Use agent-device only for app/device automation tasks. Before planning commands, run `agent-device --version` and read `agent-device help workflow`. For exploratory QA, read `agent-device help dogfood`. For logs, network, traces, or runtime failures, read `agent-device help debugging`. For React Native component trees, props/state/hooks, slow renders, or rerenders, read `agent-device help react-devtools`. For React Native apps, overlays, Metro/Fast Refresh blockers, and routing to React DevTools or debugging evidence, read `agent-device help react-native`.
50+
Use agent-device only for app/device automation tasks. Before planning commands, run `agent-device --version` and read `agent-device help workflow`. For exploratory QA, read `agent-device help dogfood`. For logs, network, traces, or runtime failures, read `agent-device help debugging`. For React Native component trees, props/state/hooks, slow renders, or rerenders, read `agent-device help react-devtools`. For React Native JavaScript heap growth, heap snapshots, or retained-object leaks, read `agent-device help agent-cdp`. For React Native apps, overlays, Metro/Fast Refresh blockers, and routing to React DevTools or debugging evidence, read `agent-device help react-native`.
5151
5252
Use MCP tools or the CLI in the integrated terminal. If `agent-device` is not on PATH but the user installed it globally in another shell, resolve the command the same way the user would from a normal terminal session and run that absolute path instead. This may require inspecting shell startup behavior or package-manager/global bin locations; do not assume the agent process `PATH` is the user's `PATH`. Do not silently fall back to `npx -y agent-device@latest`; ask or use an exact version. MCP exposes structured tools backed by the agent-device client; it does not expose generic shell execution. Prefer `open -> snapshot -i -> act -> re-snapshot -> verify -> close`. Use current refs such as `@e3` for exploration and selectors for durable replay. Keep mutating commands against one session serial. Capture screenshots, logs, network, perf, traces, recordings, and `.ad` replay scripts only when they add evidence.
5353
```
@@ -111,6 +111,7 @@ Before planning device work, run `agent-device --version` and read `agent-device
111111
For exploratory QA, read `agent-device help dogfood`.
112112
For logs, network, traces, or runtime failures, read `agent-device help debugging`.
113113
For React Native component trees, props/state/hooks, slow renders, or rerenders, read `agent-device help react-devtools`.
114+
For React Native JavaScript heap growth, heap snapshots, or retained-object leaks, read `agent-device help agent-cdp`.
114115
For React Native apps, overlays, Metro/Fast Refresh blockers, and routing to React DevTools or debugging evidence, read `agent-device help react-native`.
115116
116117
Use the CLI in Cursor's integrated terminal.
@@ -199,6 +200,7 @@ Before planning device work, run `agent-device --version` and read `agent-device
199200
For exploratory QA, read `agent-device help dogfood`.
200201
For logs, network, traces, or runtime failures, read `agent-device help debugging`.
201202
For React Native component trees, props/state/hooks, slow renders, or rerenders, read `agent-device help react-devtools`.
203+
For React Native JavaScript heap growth, heap snapshots, or retained-object leaks, read `agent-device help agent-cdp`.
202204
For React Native apps, overlays, Metro/Fast Refresh blockers, and routing to React DevTools or debugging evidence, read `agent-device help react-native`.
203205
204206
Use the CLI in the integrated terminal.

website/docs/docs/installation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Use global install for normal agent workflows. It gives agents a stable `agent-d
2121
agent-device help workflow
2222
agent-device help debugging
2323
agent-device help react-devtools
24+
agent-device help agent-cdp
2425
```
2526

2627
Some agent clients run commands in an environment that differs from the user's normal install shell. If `agent-device` is missing in the agent terminal but was installed globally elsewhere, resolve the command the same way the user would from a normal terminal session, then use the absolute binary path for agent commands. This may require inspecting shell startup behavior or package-manager/global bin locations; do not assume the agent process `PATH` is the user's `PATH`.

website/docs/docs/introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Installed CLI help is the version-matched operating guide. Start there before pl
4545
agent-device help workflow
4646
agent-device help debugging
4747
agent-device help react-devtools
48+
agent-device help agent-cdp
4849
agent-device help dogfood
4950
```
5051

0 commit comments

Comments
 (0)