feat(anatomist): add package classifying main-content layout from box geometry - #934
Merged
Merged
Conversation
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
@d-zero/anatomist, a new CLI/library package that renders a URL in a real browser and classifies its main-content child blocks into visual layout patterns (vertical stack, horizontal row, simple/complex grid, table, float-wrap) from measured box geometry (getBoundingClientRect), using CSS properties only as corroborating signal.@d-zero/beholder's main-content selector priority/fallback lists (MAIN_CONTENT_SELECTORS/MAIN_CONTENT_FALLBACK_SELECTORS) as shared constants so anatomist's own main-element resolution reuses the exact same heuristic instead of duplicating it.Details
capture-layout-tree.ts/capture-layout.ts): resolves the main-content element and walks its subtree into raw geometry + style + innerHTML via a singlepage.evaluate. Every helper is nested inside the evaluated function since Puppeteer only serializes that function's own source text into the browser realm.main > div.inner > div.containerchain doesn't end classification immediately after the root.analyze-page-layout.ts/run-batch.ts): one URL across multiple viewports (PC → tablet → mobile, largest first) reusing one page; many URLs concurrently via@d-zero/dealer, each in its own tab of one shared browser.cli.ts): reads a URL list from stdin or--input, writes JSONL to stdout or--out.classify-layout-tree.integration.spec.ts) exercise capture → classify end-to-end against real HTML fixtures for each layout pattern, using@d-zero/beholder's actual selector constants.Test plan
yarn build— all 29 projects build successfullyyarn test— 1854 tests pass across 142 files (including new fixture-driven integration tests)yarn lint— no errors/code-review medium,/qa-engineer,/product-managerreviewed; all findings addressed (see commit history for the fixes: closure-freepage.evaluatebug,Math.max(...spread)RangeError risk,--concurrency 0hang, duplicate row-clustering, dead code removal, bidirectional selector-sync test, missing--input/--outcoverage)