feat(browser): Advanced DOM Snapshot Engine — 13-layer pruning pipeline#210
Merged
feat(browser): Advanced DOM Snapshot Engine — 13-layer pruning pipeline#210
Conversation
…eline Core Changes: - New dom-snapshot.ts: 13-layer LLM-optimized DOM pruning engine - Tag filtering, SVG collapse, ad/noise detection - CSS visibility, viewport threshold, paint-order occlusion - Shadow DOM traversal, same-origin iframe extraction - BBox parent-child dedup, attribute whitelist + synthetic attrs - Table → markdown serialization - Incremental diff (mark new elements with *) - data-opencli-ref annotation for precise click/type targeting - Hidden interactive element hints (scroll-to-reveal) New APIs: - IPage.scrollTo(ref) — scroll to snapshot-identified elements - IPage.getFormState() — extract all form fields as structured JSON - scrollToRefJs(), getFormStateJs() — standalone JS generators Integration: - Page (daemon) + CDPPage (direct CDP): use new engine as primary - dom-helpers click/type: 4-layer fallback (data-opencli-ref → data-ref → CSS → index) - Exports from browser/index.ts barrel Testing: - 21 new tests for dom-snapshot engine - All 283 tests pass (29 files, 1.07s) - Split test scripts: npm test (unit only), npm run test:all (full)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds an advanced DOM snapshot engine inspired by browser-use's multi-layer pruning, adapted for opencli's Chrome Extension + CDP architecture.
New Features
scrollTo(ref)data-opencli-refelements found in snapshotgetFormState()*prefix across snapshots<table>elements serialized as markdown tablesdata-opencli-ref→data-ref→ CSS selector → index fallbackFiles Changed (11)
src/browser/dom-snapshot.ts(core engine + utilities)src/browser/dom-snapshot.test.ts(21 tests)page.ts,cdp.ts,dom-helpers.ts,index.ts,types.tsTesting