Skip to content

Export find algorithm and element matching utilities #385

@thymikee

Description

@thymikee

Problem

findBestMatchesByLocator, parseFindArgs, matchText, normalizeText, and matchRole/normalizeRole are internal to the daemon handler layer but are needed by downstream consumers that operate on snapshot nodes independently.

What to export

From a new agent-device/finders entrypoint (or add to agent-device/contracts):

  • findBestMatchesByLocator(nodes, locator, query, requireRect?)
  • parseFindArgs(args) — locator/query/action parser
  • normalizeText(value) — trim + lowercase + collapse whitespace
  • normalizeRole(value) — strip XCUIElementType and android.widget. prefixes

These are pure functions with no platform dependencies. Currently in src/utils/finders.ts and src/daemon/handlers/find.ts.

Why

Consumers that receive snapshot nodes and need to run find/match logic currently have to copy the algorithm. Exporting it keeps scoring consistent across local and remote paths and avoids drift (e.g., missing iOS role normalization in copies).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions