Skip to content

feat(playwright): page perception for AI agents — human.outline() + human_outline MCP tool#47

Merged
totigm merged 2 commits into
mainfrom
feat/page-snapshot
Jun 2, 2026
Merged

feat(playwright): page perception for AI agents — human.outline() + human_outline MCP tool#47
totigm merged 2 commits into
mainfrom
feat/page-snapshot

Conversation

@totigm

@totigm totigm commented Jun 2, 2026

Copy link
Copy Markdown
Owner

What & why

We've got the action half of the agent loop solid (click/type/form/etc.). This adds the perception half: a compact, structured view of what's on the page so an agent can decide what to act on and how to select it — without dumping raw HTML or spending tokens reasoning over a screenshot.

human.outline() returns the page's accessibility-tree outline (Playwright's ariaSnapshot): every interactive element and landmark by ARIA role + accessible name, as compact YAML —

- heading "Welcome back" [level=1]
- textbox "Email"
- textbox "Password"
- button "Sign in"
- link "Forgot password?"

Those names map directly to the getByRole / accessible-name selectors HumanJS already favors, so it doubles as a selector finder. Pass a target to scope it to a region.

Surface

  • @humanjs/playwright: human.outline(target?) — inspection getter (no plugin events; sibling to pageText() / content()).
  • @humanjs/mcp: human_outline inspection tool, alongside human_page_text / human_get_html. Description steers agents to prefer it over HTML for "what can I click/fill".
  • @humanjs/skill: added to the selector-strategy guide.

Naming

Called it outline (not snapshot) deliberately — human.snapshot() / human_snapshot sits one letter from the existing screenshot and would be easy for an agent to confuse.

Compatibility

ariaSnapshot landed in Playwright 1.49, so @humanjs/playwright's playwright peer floor moves >=1.40.0>=1.49.0. Dev/CI already run 1.60.

Tests

3 colocated tests: default body outline, region scoping, and "no plugin events fire" (inspection-only). Gate green: lint · typecheck 9/9 · tests 8/8 · check:exports (publint) 11/11.

Changeset

minor for @humanjs/playwright + @humanjs/mcp, patch for @humanjs/skill.

… MCP tool

Gives AI agents a compact accessibility-tree outline of the page (ARIA
role + accessible name, as YAML — Playwright's ariaSnapshot) so they can
see what's actionable and pick role/accessible-name selectors without
parsing HTML or burning tokens on a screenshot.

- human.outline(target?) on @humanjs/playwright (inspection getter, no
  plugin events; scopes to a region when given a target).
- human_outline MCP inspection tool mirroring it.
- Documented in the skill's selector-strategy guide.
- Bumps the playwright peer floor 1.40 -> 1.49 (ariaSnapshot's minimum).
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
humanjs Ready Ready Preview, Comment Jun 2, 2026 8:13am

@totigm totigm merged commit 4757040 into main Jun 2, 2026
6 checks passed
@totigm totigm deleted the feat/page-snapshot branch June 2, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant