Skip to content

Commit a40167b

Browse files
committed
test: cover restored agent guidance gaps
1 parent d77d96f commit a40167b

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

src/utils/__tests__/args.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,13 @@ test('usageForCommand resolves workflow help topic', () => {
836836
assert.match(help, /Do not use CSS selectors/);
837837
assert.match(help, /Truncated text\/input previews: do not use get text first/);
838838
assert.match(help, /snapshot -s @e7/);
839+
assert.match(help, /Read-only visible\/state question: use snapshot\/get\/is\/find/);
840+
assert.match(help, /Use snapshot -i only when refs are needed/);
841+
assert.match(help, /install-from-source --github-actions-artifact org\/repo:app-debug/);
842+
assert.match(help, /Do not open artifact paths or invent package ids/);
843+
assert.match(help, /agent-device get attrs @e4/);
844+
assert.match(help, /Ambiguous find: add --first or --last/);
845+
assert.match(help, /report that gap instead of typing\/searching\/navigating/);
839846
assert.match(help, /If snapshot -i shows one, dismiss\/close its visible control/);
840847
assert.match(help, /agent-device open exp:\/\/127\.0\.0\.1:8081 --platform ios/);
841848
assert.match(help, /agent-device open "Expo Go" exp:\/\/127\.0\.0\.1:8081 --platform ios/);
@@ -856,6 +863,24 @@ test('workflow help keeps common copyable command forms', () => {
856863
assert.match(help, /snapshot -s @ref/);
857864
});
858865

866+
test('usageForCommand resolves remote help topic', () => {
867+
const help = usageForCommand('remote');
868+
if (help === null) throw new Error('Expected remote help text');
869+
assert.match(help, /agent-device open com\.example\.app --remote-config \.\/remote-config\.json/);
870+
assert.match(help, /disconnect --remote-config \.\/remote-config\.json/);
871+
assert.match(help, /Script flow, per-command config/);
872+
assert.match(help, /same --remote-config to every operational command/);
873+
assert.match(help, /install-from-source --github-actions-artifact org\/repo:artifact/);
874+
});
875+
876+
test('usageForCommand resolves macos help topic', () => {
877+
const help = usageForCommand('macos');
878+
if (help === null) throw new Error('Expected macos help text');
879+
assert.match(help, /agent-device click @e66 --button secondary --platform macos/);
880+
assert.match(help, /Context menus are not ambient UI/);
881+
assert.match(help, /menu-item refs/);
882+
});
883+
859884
test('usageForCommand resolves dogfood help topic', () => {
860885
const help = usageForCommand('dogfood');
861886
if (help === null) throw new Error('Expected dogfood help text');

src/utils/command-schema.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ const AGENT_QUICKSTART_LINES = [
177177
'Default loop: devices/apps -> open -> snapshot -i -> press/fill/get/is/wait/find -> verify -> close.',
178178
'Use selectors or refs as positional targets: id="submit", label="Allow", or @ref after snapshot -i.',
179179
'Plain snapshot reads state; snapshot -i is required to refresh interactive refs.',
180+
'Read-only visible/state question: use snapshot/get/is/find; use snapshot -i only when refs are needed.',
180181
'Truncated text/input preview: expand first with snapshot -s @ref, not get text.',
181182
'RN warning/error overlays can block taps: snapshot -i, dismiss/close, then diff snapshot -i.',
182183
'Expo Go/dev clients need their provided exp:// or dev-client URL; do not invent app ids.',
@@ -247,7 +248,9 @@ Bootstrap:
247248
agent-device open <discovered-app-id> --session checkout --platform android
248249
agent-device install com.example.app ./dist/app.apk --platform android
249250
agent-device reinstall com.example.app ./build/MyApp.app --platform ios
251+
agent-device install-from-source --github-actions-artifact org/repo:app-debug --platform android
250252
If app id is unknown, plan devices, apps, then open <discovered-app-id>. Install arguments are app/package id then artifact path. Fresh install state: open with --relaunch.
253+
Do not open artifact paths or invent package ids. If apps lookup misses the target and no URL/artifact is provided, ask or stop.
251254
252255
Snapshots and refs:
253256
snapshot reads visible state. snapshot -i gets current interactive refs.
@@ -272,11 +275,15 @@ Text entry:
272275
Debounced field with no result selector: agent-device wait 1000. Keyboard read-only: keyboard status/get. Blocked control: keyboard dismiss.
273276
274277
Read-only and waits:
278+
Read-only visible/state question: use snapshot/get/is/find.
275279
agent-device snapshot
276280
agent-device get text 'id="product-title"'
281+
agent-device get attrs @e4
277282
agent-device is visible 'label="Online"'
278283
agent-device wait visible 'label="Refreshing metrics..."' 3000
279284
agent-device find "Increment" press --json
285+
Use snapshot -i only when refs are needed for an action or targeted query.
286+
Ambiguous find: add --first or --last. If info is not visible/exposed, report that gap instead of typing/searching/navigating to reveal it.
280287
281288
Navigation and gestures:
282289
Use scroll for lists; swipe for coordinate gestures/carousels.
@@ -445,9 +452,16 @@ Normal flow:
445452
agent-device snapshot
446453
agent-device disconnect
447454
455+
Script flow, per-command config:
456+
agent-device open com.example.app --remote-config ./remote-config.json
457+
agent-device snapshot --remote-config ./remote-config.json
458+
agent-device disconnect --remote-config ./remote-config.json
459+
448460
Rules:
449461
connect and disconnect are top-level commands. Do not write agent-device remote connect or agent-device remote disconnect.
450462
Prefer --remote-config over --daemon-base-url, --tenant, --run-id, and --lease-id in ordinary remote flows.
463+
For self-contained scripts, pass the same --remote-config to every operational command, including disconnect; a preceding connect is optional but not required.
464+
For remote artifact installs, use install-from-source <url> or install-from-source --github-actions-artifact org/repo:artifact; do not download CI artifacts locally first.
451465
After connect, let the active remote connection supply runtime hints.
452466
For remote Android React DevTools, run agent-device react-devtools normally. The CLI opens the needed local service tunnel for the DevTools daemon and cleans it up when the command exits.
453467
Use --debug when remote connection or transport errors need diagnostic ids and remote log hints.`,
@@ -472,8 +486,13 @@ Menu bar app example:
472486
agent-device open "Agent Device Tester Menu" --platform macos --surface menubar
473487
agent-device snapshot -i --platform macos --surface menubar
474488
489+
Context menu example:
490+
agent-device click @e66 --button secondary --platform macos
491+
agent-device snapshot -i --platform macos
492+
475493
Rules:
476494
Use open and snapshot -i for menu bar inspection. Do not output inspect as a command.
495+
Context menus are not ambient UI: secondary-click a visible target, then re-snapshot and use the new menu-item refs.
477496
Do not let iOS simulator-set scoping hide macOS desktop targets.
478497
Prefer refs/selectors over raw coordinates.
479498
macOS snapshot rects are window-space; use current refs or overlay refs instead of guessing coordinates.`,

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,48 @@ const SKILL_GUIDANCE_CASES: TestCase[] = [
551551
],
552552
forbiddenOutputs: [/open\s+\.\/dist\/agent-device-tester\.apk/i],
553553
}),
554+
makeCase({
555+
id: 'install-from-github-artifact-before-open',
556+
contract: [
557+
'Platform: Android',
558+
'Install source: GitHub Actions artifact callstackincubator/agent-device:agent-device-tester-apk',
559+
'Known package after install: com.callstack.agentdevicetester',
560+
'Remote daemon can resolve the artifact server-side',
561+
],
562+
task: 'Plan commands to install from the GitHub Actions artifact, then open the installed package in fresh runtime state.',
563+
outputs: [
564+
commandPattern('install-from-source'),
565+
/--github-actions-artifact\s+callstackincubator\/agent-device:agent-device-tester-apk/i,
566+
commandPattern('open'),
567+
/com\.callstack\.agentdevicetester/i,
568+
/--relaunch/i,
569+
],
570+
forbiddenOutputs: [
571+
/curl\b/i,
572+
/gh\s+(?:run|artifact|download)/i,
573+
/open\s+.*agent-device-tester-apk/i,
574+
],
575+
}),
576+
makeCase({
577+
id: 'hidden-info-do-not-force-ui',
578+
contract: [
579+
'App name: Agent Device Tester',
580+
'Current screen: Home tab',
581+
'Question: what is the hidden promo code?',
582+
'The current screen does not expose any promo code text or selector',
583+
'No interaction was requested',
584+
],
585+
task: 'Plan the minimal read-only command to inspect exposed UI without typing, navigating, or mutating the app to reveal hidden information.',
586+
outputs: [commandPattern('snapshot')],
587+
forbiddenOutputs: [
588+
/snapshot -i/i,
589+
commandPattern('press'),
590+
commandPattern('click'),
591+
commandPattern('fill'),
592+
commandPattern('type'),
593+
commandPattern('open'),
594+
],
595+
}),
554596
makeCase({
555597
id: 'metro-reload-dev-loop',
556598
contract: [
@@ -878,6 +920,22 @@ const SKILL_GUIDANCE_CASES: TestCase[] = [
878920
commandPattern('screenshot'),
879921
],
880922
}),
923+
makeCase({
924+
id: 'remote-config-script-flow',
925+
contract: [
926+
'Remote config path: ./remote-config.json',
927+
'App package: com.callstack.agentdevicetester',
928+
'This is a self-contained script where every command must be explicit',
929+
'The remote profile owns tenant, run, lease, and Metro hints',
930+
],
931+
task: 'Plan a self-contained remote script that opens the app, captures a snapshot, and disconnects using the remote config on every command.',
932+
outputs: [
933+
/open\b[^\n]*--remote-config\s+\.\/remote-config\.json/i,
934+
/snapshot\b[^\n]*--remote-config\s+\.\/remote-config\.json/i,
935+
/disconnect\b[^\n]*--remote-config\s+\.\/remote-config\.json/i,
936+
],
937+
forbiddenOutputs: [/--daemon-base-url/i, /--tenant/i, /--run-id/i],
938+
}),
881939
makeCase({
882940
id: 'macos-menubar-surface',
883941
contract: [
@@ -890,6 +948,24 @@ const SKILL_GUIDANCE_CASES: TestCase[] = [
890948
outputs: [/--platform macos/i, /--surface menubar/i, /snapshot\b.*(?:-i\b|\s-i\b)/i],
891949
forbiddenOutputs: [/--surface app/i, /snapshot --raw/i],
892950
}),
951+
makeCase({
952+
id: 'macos-context-menu-secondary-click',
953+
contract: [
954+
'Platform: macOS',
955+
'Current surface: app',
956+
'Target row current ref: @e66',
957+
'Need to open its native context menu and inspect menu item refs',
958+
],
959+
task: 'Plan commands to open the context menu for @e66 and then refresh interactive refs for the menu items.',
960+
outputs: [
961+
commandPattern('click'),
962+
/@e66/i,
963+
/--button\s+secondary/i,
964+
/--platform\s+macos/i,
965+
/snapshot\b.*-i/i,
966+
],
967+
forbiddenOutputs: [commandPattern('longpress'), RAW_COORDINATE_TARGET, /--surface menubar/i],
968+
}),
893969
makeCase({
894970
id: 'replay-maintenance-update',
895971
contract: [

0 commit comments

Comments
 (0)