Skip to content

--text flag: inline visible text previews for ls and find #27

@apireno

Description

@apireno

Summary

Add a --text flag to ls and find that shows inline visible text previews per element using .innerText (rendered text only, respects CSS display:none and visibility:hidden).

Problem

When agents scan a page, they must cat each element individually to see what text it contains. For a page with 50 links, that's 50 tool calls just to read link labels.

Solution

ls --text and find --text

Shows a truncated, dimmed text preview inline with each element:

[x] link    read_more     "Read more about our product..." (142)  href=https://...
[x] button  submit_btn    "Submit Application"

cat — VisibleText property

cat now shows both:

  • Text:.textContent (all descendant text, including hidden)
  • VisibleText:.innerText (only rendered text, respects CSS visibility)

VisibleText is only shown when it differs from Text, to avoid redundancy.

Configurable preview length

--textlen N (default 80 chars). Truncated output shows ... and total char count.

Combinable with existing flags

ls --text --meta          # text + DOM properties
find --type link --text --meta  # URLs + link text
ls --text --textlen 30    # shorter previews

Implementation

  • New getInnerText() CDP method using .innerText
  • --text / --textlen flags on ls and find
  • VisibleText section in cat output
  • Updated MCP tool definitions for domshell_ls, domshell_find, domshell_cat

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-ergonomicsBetter agent/automation experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions