diff options
| author | amankumarsingh77 <amankumarsingh7702@gmail.com> | 2026-07-28 20:30:49 +0530 |
|---|---|---|
| committer | Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> | 2026-08-02 19:12:46 +0530 |
| commit | b67faca60b21b0cf74d5c967f0f8d215ad601e93 (patch) | |
| tree | 12e8580e1b88c3ce6a2d9157cfa678cb7a55a73c /src/domains/search | |
| parent | a6ec1d0915106b127affbd6b5fcc9efec48ef712 (diff) | |
refactor(domains): strip comment noise
Removes module banners, step markers, and comments restating the code.
Keeps one-line notes for safeJs's trust boundary, the select-match null
sentinels, the TUI width clamp, the single-window tab rule, the input
synthesis quirks (char events, keyCode, mousemove, focus, compositor),
the stale AX value, ignored-wrapper recursion, and isolated-tab routing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/domains/search')
| -rw-r--r-- | src/domains/search/extract.ts | 15 | ||||
| -rw-r--r-- | src/domains/search/google-serp.ts | 28 |
2 files changed, 0 insertions, 43 deletions
diff --git a/src/domains/search/extract.ts b/src/domains/search/extract.ts index 52f7f86..05ee182 100644 --- a/src/domains/search/extract.ts +++ b/src/domains/search/extract.ts @@ -1,21 +1,6 @@ -/** - * The JavaScript source evaluated inside the Google SERP page to capture raw - * anchors + page text. This string crosses the CDP boundary via - * Runtime.evaluate (returnByValue) and returns a JSON string that - * `parseGoogleSerp` / `classifySerp` consume on the harness side. - * - * ADR-0001: anchors are selected structurally (a link carrying an <h3>), not by - * Google CSS class names, so cosmetic markup churn does not break extraction. - */ -/** Max bytes of page text captured for CAPTCHA / no-results classification. */ const PAGE_TEXT_LIMIT = 4000; -/** - * Build the extraction expression. Takes no interpolated values, so it is a - * fixed source string (no injection surface). Returns - * `JSON.stringify({ anchors, pageText })`. - */ export const buildSerpExtractionExpr = (): string => ` (() => { const main = document.querySelector('#search, #rso, #main') || document.body; diff --git a/src/domains/search/google-serp.ts b/src/domains/search/google-serp.ts index 7e49bea..4b8a319 100644 --- a/src/domains/search/google-serp.ts +++ b/src/domains/search/google-serp.ts @@ -1,27 +1,15 @@ -/** - * Pure Google SERP parsing — no CDP, no browser. Everything here is a pure - * function over data captured from the page, so it is unit-testable against - * saved fixtures (see test/deep-research/serp-parser-test.ts). - * - * ADR-0001: results are extracted by structure/semantics (anchors carrying an - * <h3> heading in the main results column), never by brittle Google CSS class - * names, and Google redirect wrappers are unwound to the real target URL. - */ -/** One raw anchor captured in-page: a link with a heading and nearby snippet. */ export type SerpAnchor = { readonly href: string; readonly heading: string; readonly snippet: string; }; -/** The JSON payload the in-page extraction expression returns. */ export type SerpExtraction = { readonly anchors: ReadonlyArray<SerpAnchor>; readonly pageText: string; }; -/** A parsed, ranked search result — the tool's public output shape. */ export type SearchResult = { readonly title: string; readonly url: string; @@ -29,7 +17,6 @@ export type SearchResult = { readonly rank: number; }; -/** Why a SERP yielded no usable results, or that it did. */ export type SerpVerdict = "ok" | "captcha" | "no_results"; const CAPTCHA_MARKERS: ReadonlyArray<string> = [ @@ -42,10 +29,6 @@ const CAPTCHA_MARKERS: ReadonlyArray<string> = [ "our systems have detected unusual traffic", ]; -/** - * Decode a Google redirect wrapper (`/url?q=<real>&sa=...`) to its target. - * Returns the input unchanged when it is not a wrapper. - */ const unwrapRedirect = (href: string): string => { const wrapper = href.match(/^(?:https?:\/\/[^/]*google\.[^/]*)?\/url\?/i); if (!wrapper) return href; @@ -66,7 +49,6 @@ const isExternalResult = (url: string): boolean => { } }; -/** Normalized key for dedupe: origin + pathname, trailing slash and hash removed. */ const dedupeKey = (url: string): string => { try { const u = new URL(url); @@ -76,11 +58,6 @@ const dedupeKey = (url: string): string => { } }; -/** - * Parse captured anchors into ranked results: unwrap redirects, keep only - * external http(s) links, dedupe by normalized url (first wins), rank by input - * order, cap to `limit`. - */ export const parseGoogleSerp = (anchors: ReadonlyArray<SerpAnchor>, limit: number): ReadonlyArray<SearchResult> => { const seen = new Set<string>(); const results: SearchResult[] = []; @@ -101,11 +78,6 @@ export const parseGoogleSerp = (anchors: ReadonlyArray<SerpAnchor>, limit: numbe return results; }; -/** - * Decide whether the SERP is usable, blocked by a CAPTCHA, or genuinely empty. - * `resultCount` is the number of parsed results; `pageText` is a bounded slice - * of the page's visible text. - */ export const classifySerp = (pageText: string, resultCount: number): SerpVerdict => { if (resultCount > 0) return "ok"; const lower = pageText.toLowerCase(); |
