Repository navigation
fix(core): strip boilerplate from webfetch conversions - #234
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
|
||
| const BOILERPLATE_TAGS = ["nav", "header", "footer", "aside"] | ||
| const BOILERPLATE_ROLES = ["navigation", "banner", "contentinfo"] | ||
| const BOILERPLATE_CLASSES = ["cookie", "footer"] |
There was a problem hiding this comment.
WARNING: Substring class matching in BOILERPLATE_CLASSES is overly aggressive
"footer".includes("footer") matches legitimate content classes like page-footer, copyright-footer, footer-note, main-footer-content. Consider using word-boundary matching (split class string by whitespace and check exact token matches) instead of substring .includes().
| mime === "application/javascript" || | ||
| mime === "application/x-javascript" | ||
|
|
||
| const BOILERPLATE_TAGS = ["nav", "header", "footer", "aside"] |
There was a problem hiding this comment.
SUGGESTION: "aside" in BOILERPLATE_TAGS may remove legitimate sidebar content
The <aside> element is semantically meant for tangentially related content (sidebars, callouts, author bios, related links) which is often valuable to users. Consider removing "aside" from the default boilerplate list or making it configurable.
| doc.children, | ||
| ) | ||
| for (const element of boilerplate) DomUtils.removeElement(element) | ||
| return DomUtils.getOuterHTML(doc.children) |
There was a problem hiding this comment.
SUGGESTION: stripBoilerplate return value may drop document wrapper for full HTML documents
DomUtils.getOuterHTML(doc.children) returns outer HTML of document's direct children. For a full HTML document (<html><head>...</head><body>...</body></html>), doc.children is [htmlElement], so this returns the <html> wrapper. For fragments, it returns fragment elements. Behavior is inconsistent but likely acceptable since output feeds markdown/text converters. Consider documenting the expected input format.
| const BOILERPLATE_CLASSES = ["cookie", "footer"] | ||
|
|
||
| function stripBoilerplate(html: string) { | ||
| const doc = parseDocument(html) |
There was a problem hiding this comment.
SUGGESTION: stripBoilerplate should handle empty/invalid HTML input gracefully
parseDocument("") returns a document with empty children. DomUtils.getOuterHTML([]) returns "". This works but consider adding an early return for empty/whitespace-only input to avoid unnecessary parsing.
|
|
||
| expect(yield* executeTool(registry, call({ url: "https://1.1.1.1/page", format: "text" }))).toEqual({ | ||
| type: "text", | ||
| value: "TitleBody", |
There was a problem hiding this comment.
SUGGESTION: Text output "TitleBody" lacks space between heading and paragraph
This matches existing extractTextFromHTML behavior (see line 79: "Helloworld wide"), but concatenating without spaces may surprise users. Consider whether a space separator between block elements would improve readability.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summary (commit f14df8f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit f14df8f)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files)
Reviewed by free · Input: 409.7K · Output: 91K · Cached: 312.8K |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #190
Type of change
What does this PR do?
Ports boilerplate removal to the migrated core webfetch path. Removes navigation/header/footer/aside elements, navigation/banner/contentinfo roles, and cookie/footer classes before markdown or text conversion. Raw HTML stays unchanged. Adds API/raw URL guidance, cautious 404 handling, and three pipeline regressions.
Produced by OpenCode v2.0.26. The pilot separately corrected the 404 wording so credentials are not blamed as the only cause. Kilo found an overly aggressive substring class match; that finding is pending a worker fix. Not merge-ready.
How did you verify your code works?
Pilot validation on dev-vibecoded a71ab99: 15 core webfetch tests passed; prettier passed; oxlint had 0 errors and 1 pre-existing Cloudflare type-assertion warning; git diff --check passed. Dependencies were installed with frozen-lockfile and ignore-scripts.
Core typecheck timed out without diagnostics and is still pending. Linux and Windows unit checks passed on f14df8f. Independent review is not clean: Kilo reported 1 warning and 4 suggestions. Further validation and the worker correction are pending.
Screenshots / recordings
Not applicable; no UI change.
Checklist