Repository navigation
fix(opencode): strip webfetch page boilerplate and document API endpoints - #219
Merged
Merged
Conversation
…ints Co-authored-by: arena-agent <[email protected]>
Code Review SummaryThis review did not finish. The model reached its output limit before it Previous Review SummaryCurrent summary above is authoritative. Previous snapshots are kept for context only. Previous reviewThis review did not finish. The model reached its output limit before it |
dev is already an ancestor of this branch (behind_by 0), so there is nothing to rebase or merge and the diff is unchanged; this empty commit re-runs the PR checks so a review is produced on the current head. Co-authored-by: arena-agent <[email protected]>
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.
Issue for this PR
Closes #190
Type of change
What does this PR do?
Rendered HTML fetches returned page chrome instead of content: fetching a GitHub PR/checks page produced roughly 10 KB of nav menus, sign-in prompts, cookie text and footer links with only a few lines of real content, and the follow-up call to an unauthenticated
api.github.comendpoint 404'd. This PR implements both halves of the issue.Code (
packages/opencode/src/tool/webfetch.ts): HTML is parsed before conversion and boilerplate elements are removed —nav,header,footer,aside,[role='navigation'],[role='banner'],[role='contentinfo'], and class names containingcookieorfooter. One deviation from the issue's snippet:doc.querySelectorAllis not usable here.querySelectorAllis provided bycss-select, which is not in this package's tree — htmlparser2 only shipsparseDocumentand thedomutilstraversal helpers (including through itsDomUtilsre-export). Adding css-select would have broken the "no new dependency" criterion, so the same selector list is matched structurally against the parsed tree and re-serialized for conversion. No dependency, no per-domain rule. The strip runs on themarkdownandtextHTML paths;format: "html"still returns the page verbatim.Prompt (
packages/opencode/src/tool/webfetch.txt): added the requested note about page chrome, preferring API endpoints / raw URLs, and not retrying unauthenticated requests that 404.One honest caveat on the acceptance criteria: on today's GitHub markup the nav, footer, cookie and marketing blocks are gone, but GitHub's "Skip to content" anchor sits in a plain
header-wrapperdiv that is a sibling of<header>, so the selector list from the issue does not match it. I kept the list exactly as specified instead of adding a GitHub-specific rule or a broad[class*='header']rule that would risk dropping real article headers.How did you verify your code works?
cd packages/opencode && bun test test/tool/webfetch.test.ts— 25 pass / 0 fail, including 4 new tests: boilerplate stripping for markdown (tag, role and class selectors), stripping intextoutput,format: "html"left untouched, and the new tool-description text being wired through to the model-facing description.tsc --noEmitoversrc/tool/webfetch.ts+ its test file with the package tsconfig: clean apart from a pre-existing, unrelatedphoton_rs_bg.wasmresolution error caused by installing with--ignore-scriptsin this sandbox. The fullbun run typecheckcannot complete here — tsc/tsgo are OOM-killed at ~2–3 GB heap on this 4 GB box.prettier --checkon both changed TS files: clean.oxlint: only a pre-existing warning in the test file's layer helper.Terms,Privacy,cookieandFootertext gone and the conversation content still present.bun test test/tool/(whole directory): 529 pass, 3 fail —tool parameters > JSON Schema (wire shape) > taskandtool.registry > hides task background parameter unless experimental background subagents are enabledfail identically on a cleandevcheckout (confirmed by stashing this change), andtool.shell abort > streams metadata updates progressivelypasses in isolation, i.e. a flake under full-suite load.packages/core/test/tool-webfetch.test.ts: 12 pass (untouched, checked for regressions).Screenshots / recordings
Not a UI change.
Checklist