feat: smart default snapshot scoping to main content area#62
Merged
Conversation
Add detectMainContent() helper that tries <main>, then [role="main"], then falls back to <body>. Snapshots now default to the main content area instead of the full page body, reducing noise from nav/footer. Add --snapshot-full flag to bypass auto-detection when full page body is needed.
Update replicated getSnapshot to use detectMainContent for main-area auto-detection. Update existing body-default mocks to handle the new detection flow. Add detectMainContent unit tests (main tag, role attr, body fallback, error fallback) and getSnapshot auto-scoping tests (auto-scope, snapshotFull bypass, snapshotSelector priority).
…nContent Verify --snapshot-full is in BOOLEAN_FLAGS, help text documents the flag, and detectMainContent function exists in web-ctl.js source. Update replicated BOOLEAN_FLAGS to stay in sync with source.
Add auto-scoping behavior explanation to SKILL.md Snapshot Control section. Add --snapshot-full subsection with usage examples. Add --snapshot-full example to command reference quick reference.
… review tests Use Promise.all() for main/role count checks. Add tests for flag priority (selector > full), both-exist priority, and parseOptions.
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
<main>element (then[role="main"], fallback to<body>), reducing output size by excluding navigation, headers, and footers--snapshot-fullflag to bypass auto-detection and capture full page body--snapshot-selectorstill takes priority over auto-detectionPromise.all()to parallelize DOM queries for minimal performance overheadTest Plan
detectMainContentunit tests: main tag, role attr, both present, neither, error fallbackgetSnapshotauto-scoping tests: auto-scope, snapshotFull bypass, snapshotSelector priority, selector+full interaction, full+transforms--snapshot-fullflagRelated Issues
Closes #45