Skip to content

feat(cli): add @uid and URL shorthands - #2897

Open
OrKoN wants to merge 3 commits into
mainfrom
cli-uid-url-shorthands
Open

OrKoN wants to merge 3 commits into
mainfrom
cli-uid-url-shorthands

Conversation

@OrKoN

@OrKoN OrKoN commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Adds CLI-only shorthands for element uids and URLs. The MCP server, tool schemas, pageId handling, and snapshot output are unchanged.

  • @<uid> is accepted for uid params:
    • In a required uid slot, the @ is stripped: click 1 @1_5 is the same as click 1 1_5.
    • An extra @<uid> fills the first optional uid param that is not set yet: take_screenshot 1 @1_5 becomes take_screenshot 1 --uid 1_5.
    • For evaluate_script, extra @<uid> args are appended to the element --args.
    • --uid @1_5 also works.
  • URLs passed as an extra positional fill an optional url param: navigate_page 1 https://web.dev becomes navigate_page 1 --url https://web.dev. Only absolute URLs with http, https, file, chrome, chrome-extension, about, or data schemes count; example.com does not.

Implementation: expandShorthandArgs() in src/config/cli-commands.ts rewrites argv before yargs parses it, so yargs config and strict mode are unchanged. It:

  • Skips flag values, using arg types to tell booleans and arrays apart.
  • Never overrides an explicit flag: take_screenshot 1 --uid 1_4 @1_5 still fails with "Unknown argument".
  • Only strips @ in uid slots, so fill 1 @1_5 @handle keeps the value @handle.

Usage lines show the shorthands (e.g. take_screenshot <pageId> ... [@uid], navigate_page <pageId> ... [url]), and docs/cli.md has a new "Shorthands" section.

The agent tip printed on argument errors now asks for exact command names from --help, uses click 1 @1_2 as the correct example, and lists the @<uid> and URL shorthands for optional parameters. Unknown commands are not rerouted or auto-corrected.

The chrome-devtools-cli skill (skills/chrome-devtools-cli/SKILL.md) now uses the shorthands in its workflow, usage notes, and examples (e.g. click 1 @1_4, take_screenshot 1 @1_4, navigate_page 1 "https://example.com"). I ran each changed example through expandShorthandArgs to check it expands to the expected flags.

Manually verified with the built CLI on wikipedia.org: navigate_page 1 <url>, take_screenshot 1 @uid, evaluate_script ... @uid, fill 1 @uid "@devtools", and click 1 @uid.

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