feat(dom): add scroll command for agent-friendly page navigation #135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add a new
bdg dom scrollcommand that provides three distinct scrolling modes for AI agents and automation workflows:bdg dom scroll "footer"- scrolls element into viewbdg dom scroll --down 500- scrolls by pixel amountbdg dom scroll --bottom- scrolls to page boundariesMotivation
The Problem
When an AI agent using bdg is instructed to "scroll down the page" or "scroll to the footer", there was no discoverable way to accomplish this. The agent would need to:
Runtime.evaluatewith JavaScript is the answerRuntimeorevaluate(notscroll)window.scrollBy(0, 500)bdg cdp --search scrollreturned CDP methods likeDOM.scrollIntoViewIfNeededbut didn't surfaceRuntime.evaluate- the most practical approach for arbitrary scrolling.The Solution
A dedicated
bdg dom scrollcommand that:bdg dom --helpandbdg dom scroll --helpfill,click,pressKey)Implementation Details
Files Changed
src/commands/shared/optionTypes.tsScrollCommandOptionsinterfacesrc/commands/dom/formFillHelpers.tsscrollPage()helper with 3 scroll modessrc/commands/dom/formInteraction.tsbdg dom scrollcommand registrationsrc/commands/optionBehaviors.tsCLAUDE.mddocs/CLI_REFERENCE.md.claude/skills/bdg/SKILL.mdDesign Decisions
--scrolloptionscrolledTo,scrolledBy,viewportSize,pageSizefor agent decision-making--indexfor nth element - consistent with other DOM commandsJSON Output Example
{ "success": true, "scrollType": "element", "selector": "footer", "scrolledTo": { "x": 0, "y": 4108 }, "viewportSize": { "width": 756, "height": 469 }, "pageSize": { "width": 756, "height": 4577 } }Benefits
bdg dom --helpclick,fill,pressKeyUsage Examples
Test Plan
bdg dom scroll --helpshows all optionsbdg dom scroll "footer"scrolls element into viewbdg dom scroll --down 500scrolls by pixel amountbdg dom scroll --bottomscrolls to page bottombdg dom scroll --topscrolls to page topbdg dom scroll(no args) returns helpful error with suggestion