feat(cli): compact workflow help card + version header
Summary
Benchmark evidence (SWM AppControlBench, gpt-5.4-high driving the CLI on 30 Bluesky tasks) showed agent-device help workflow (~41KB) plus a separate agent-device --version handshake were mandated on every task by the shipped skill router, producing 108 boilerplate tool calls across 30 tasks (~3.6 extra model turns/task) and 1266KB of the 1899KB total tool output (67%) being help/version text.
This PR:
- Shrinks
agent-device help workflowfrom 41025 → 8493 bytes (-79.3%). Content that carries correctness (the open→snapshot→settle→verify→close loop, selector/@ref rules,--settleguidance, platform gotchas, error-recovery hints) stays; duplication, long prose, and rarely-needed depth move to sub-topics — nothing is deleted:- New
help scripting: save-script/destination-guard authoring,--record-assecret-safe fills, batch JSON step shape, replay divergence/resume, agent-supervised repair (heal-by-doing), recording/tracing. - New
help gestures: full multi-touch command shapes (pinch/rotate/transform/drag), iOS XCTest-synthesis vs Android geometric-injection quirks, macOS context-menu/wheel-scroll patterns. - Folded into topics that already owned the subject: iOS Allow-Paste / Android Gboard-handwriting quirks →
help debugging; runner/daemon idle-timeout env vars →help physical-device; Apple-runner CI cache-key note →help validate.
- New
- Every
help <topic>first line is nowagent-device <version> — <topic>(e.g.agent-device 0.20.6 — workflow), so the skill reads the CLI version off its mandatory first help read instead of a separateagent-device --versioncall.skills/agent-device/SKILL.mdis updated to do that (with explicit fallback semantics: a first line still reading the oldagent-device help <topic>format, or a failed/unrecognized command, means the CLI predates this header and needs upgrading) and otherwise stays a thin router — no behavioral guidance was added there. - The compact card gains two terse behavioral rules directly in
help workflow:- Chain confident consecutive steps with
&&(falling back to one command at a time when a step is uncertain — ambiguous match, network-backed result, unseen screen). - Before declaring a task done, confirm the requested end state is actually visible on the current screen (scrolling into view if needed) —
get textalone, or stopping one screen early, is not enough.
- Chain confident consecutive steps with
- Ran the repo's help-planning benchmark (
scripts/help-conformance-bench.mjs, 25 cases × 2 non-agentic runners) before and after against the live CLI output (never hand-transcribed). - Live-validated on a simulator I created myself.
Review follow-ups (all three addressed)
- && vs. the plan validator (P1). The card's
&&-chaining guidance conflicted withscripts/help-conformance-plan-validator.mjs, which classified any unquoted&&asshell-projectionand failedvalidPlanCommands— canonical help was teaching a plan shape the conformance contract rejected. Fixed by extending the validator, not by dropping the guidance: it now splits a plan line on unquoted&&and validates each segment independently (&&inside a quoted selector value, e.g.label="A && B", is not a split boundary and stays intact). Added unit tests for the splitter and achains-confident-consecutive-settle-stepsconformance case that exercises a real chained plan end to end.batchstays untouched — it's deliberately stop-only, a settled design decision, not a workaround target. @refplaceholder contradiction (P2). The card said never to target a placeholder like@ref/@eN, then itself wrotesnapshot -s @ref. Replaced with a concrete ref and an explicit label:snapshot -s @e12 (the current concrete ref). Reverted the test that had been changed to require the placeholder shape.- Waivers → real conformance cases (P2).
help scriptingandhelp gesturesnow each have a dedicated conformance case instead of a "we'll add one if regressions show up" waiver:scripting-secret-safe-recorded-login(arm--save-script,--record-asa fill against an env var, publish without closing) andgestures-android-transform-then-verify(plan a combined pan/scale/rotate transform, then verify with the exact confirmation text that only appears in the gestures topic's own example — so a correct plan proves the model actually read it). Both waivers removed. - Empty
&&chain operands (P2, follow-up round). The&&splitter above filtered out empty segments, so a plan with a leading (&& foo), trailing (foo &&), or doubled (a && && b) operator passedvalidPlanCommandseven though a real shell rejects all three as a syntax error — the validator would have blessed a plan that fails at execution. Fixed: an empty (post-trim) segment is now a dedicatedempty-chain-operandissue instead of being silently dropped. Added regression tests for all three shapes plus confirmation the quoted-&&case is unaffected.
Before / After
| Metric | Before | After |
|---|---|---|
agent-device help workflow bytes | 41025 | 8493 (-79.3%) |
| Mandated boilerplate turns/task (router) | version handshake + topic read (2+) | topic read only (1) |
| help-conformance-bench (25 cases × 2 runners, pass/total, repeat=1) | codex 15/22, haiku 14/22 → 29/44 (22-case baseline, pre-review-fixes) | codex 19/25, haiku 14/25 → 33/50 (latest full run, post-review-fixes) |
Read the bench delta with the noise floor this framework actually has at repeat=1, not as a clean signal: one case with zero exposure to any change in this PR (ios-system-ui-widget-flow, docs are --help:first30 + an untouched topic) swung 10/10 → 7/10 → 1/10 across three consecutive runs — the 1/10 was a claude CLI subprocess API error, not a content issue. Across two independent full post-fix runs the combined score was 32/50 and 33/50 — statistically on par with the 29/44 (65.9%) baseline. The two things actually being tested by the new cases behave correctly: scripting-secret-safe-recorded-login passes 8/8 for both runners (after one case-authoring bug of my own — an export line the task didn't need — was found and fixed), and chains-confident-consecutive-settle-steps correctly produces a fully valid plan either way, reporting the model's choice not to chain as a soft, informative signal rather than a validator failure (matching the original benchmark finding that models chained only twice in 30 tasks even when told they could).
One real regression surfaced and was fixed before any of the numbers above: the compact Bootstrap section initially dropped the explicit "install arguments are id then artifact path" rule (kept only the example command), and both runners on workflow-install-artifact-before-open started omitting the package id from install calls. Re-added the explicit rule sentence; the case now passes for both runners consistently.
Live smoke test
Created my own simulator (never touched bench-golden* or the reserved UDID), booted it, and ran the exact sequence the skill prescribes with an isolated AGENT_DEVICE_STATE_DIR:
agent-device help workflow # 8493 bytes, version-headed
agent-device open com.apple.Preferences --platform ios --device claude-helpdiet-test
agent-device snapshot -i --platform ios --device claude-helpdiet-test
agent-device press 'label="General"' --settle --platform ios --device claude-helpdiet-test
agent-device close --platform ios --device claude-helpdiet-test
All five commands worked end-to-end using only the compact card's guidance — no missing command shapes. press --settle returned a full settled diff (+14/-14) showing the General screen's content, matching the "continue from the settled diff" guidance verbatim. Cleaned up: daemon stopped, simulator shut down and deleted.
Tests
src/cli/parser/__tests__/cli-help-topics.test.ts,src/__tests__/cli-help.test.ts,src/cli/parser/__tests__/cli-help-command-usage.test.ts— rewritten to match the new compact content, new topics, and version headers.scripts/__tests__/help-conformance-bench.test.ts— new unit tests for the&&segment splitter (splits a chain, leaves a quoted&&alone, still rejects a lone unquoted&, fails only the offending segment of a chain).scripts/help-conformance-cases.mjs— three new conformance cases (chains-confident-consecutive-settle-steps,scripting-secret-safe-recorded-login,gestures-android-transform-then-verify);scripts/__tests__/help-conformance-topic-coverage.test.ts— both waivers removed now thatscripting/gestureshave real cases.src/commands/management/session.test.ts— a pre-existing production test asserted save-script/--record-ascontent directly againsthelp workflow; updated to follow the pointer tohelp scripting, where that content now lives.- All touched suites pass locally (269+ tests in the help-specific files, 5600/5600 across the full
unit-core+subprocess-stubrun);oxlintandoxfmt --checkare clean repo-wide. CI is green (Coverage, Lint & Format, Typecheck, Layering Guard, Smoke Tests, etc. all pass).
What was left out
- Didn't chase the exact ≤8KB target to the byte — landed at 8493B (vs the 8192B target) after restoring the install-order rule the bench caught as a real regression, plus the
@e12fix from review. Judged that trade worth it: benchmark-verified correctness over an arbitrary few hundred bytes. - Didn't push for a cleaner single bench number by re-running further — repeat=1 noise (documented above) means chasing one more point is not signal. The unit tests are the deterministic proof for the validator fix; the bench numbers are corroborating, not load-bearing.