Summary
Adds passive extraction of :root CSS custom properties (variables and design tokens) to web page inspection across domain schemas, the Chrome DevTools Protocol (CDP) provider, and the CLI/MCP tool boundaries under --include-css-variables.
Problem and expected behavior
When reverse-engineering and reconstructing web applications and user interfaces from captured browser sessions, agents and analysts need access to design system tokens (color schemes, spacing, typography scales, z-indexes, and design system variables). Previously, inspectWebPage only captured DOM snapshots, scripts, network requests, and storage, leaving CSS custom properties unobserved unless manually queried via console evaluations.
With this change:
inspectWebPageaccepts an optionalinclude_css_variablesflag (defaults tofalse).- When enabled, it queries
:rootcomputed styles via CDP (CSS.enable,CSS.getComputedStyleForNode, andCSS.disablecleanup). - It extracts and strictly validates
--[a-zA-Z0-9_-]+variables, stripping non-printable/control characters, enforcing size limits (maximum 250 variables, 512 bytes per value, max 5 nestedvar()references, bounded 2,000 raw intake buffer). - Returns structured facts with deterministic sorting,
origin_scopeattribution, and diagnostic limitation reporting.
Change and scope
- Added
browserCssVariablesSummarySchemaand input schema options insrc/domain/browserObservationSchemas.tsandsrc/domain/browserObservation.ts. - Implemented
captureCssVariablesinsrc/browser/CdpCaptureCssVariables.tsand integrated intosrc/browser/CdpPageCapture.ts. - Exposed
--include-css-variablesflag insrc/cliObservationOptions.ts,src/cli/browserCommands.ts, and tool schemas insrc/contracts/browserToolContracts.ts. - Implemented unit tests for schema parsing/validation, CDP mock connection extraction & error handling, and CLI boundary execution.
Follow the contribution scope. Ordinary enhancement within existing read-only browser inspection boundaries; maintainer scope decision is not applicable.
Contract and boundary impact
- Semantic owner and earliest changed stage:
src/domain/browserObservationSchemas.ts(domain contract), thensrc/browser/(CDP provider extraction), thensrc/cli/(CLI adapter). - Contribution scope fit and linked maintainer decision: Read-only passive observation of browser styling, not applicable.
- CLI and MCP/tool-catalog contract: Added
--include-css-variablesboolean option to CLIrea browser inspectand MCPinspectWebPage. - Provider, bridge, target-format, or platform compatibility: Chrome DevTools Protocol (CDP)
CSSandDOMdomains. Handled protocol-level rejection gracefully with limitation reporting. - Evidence, artifact, provenance, or reconstruction contract: Returns
css_variablesobject withstatus,origin_scope,total,retained_count, and sorteditems. - Target selection, authority, upstream behavior, and cleanup details: Read-only query; guarantees
CSS.disablecleanup infinallyblock. - Generated metadata, package, or installation impact: Verified via
npm run mcp-catalog:checkandnpm run docs:check.
Expected effects:
- Read existing files or captured data.
- Launch or attach to a process.
- Inject instrumentation or run scripts/code.
- Change process memory, registers, files, or configuration.
- Contact network services.
- Recover protected code or work around protections.
- Documentation or usability only; no target interaction.
- Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
- Tests added or updated:
src/domain/browserObservation.test.ts(domain validation, max items, BiDi/control character filtering, nesting depth bounds)src/browser/CdpCaptureCssVariables.test.ts(CDP protocol command sequence, error handling, truncation, detached DOM nodes)tests/boundary/cli/browserCssVariablesCli.test.ts(CLI argument parsing and tool dispatch)
- User-visible CLI/MCP output:
"css_variables": { "status": "extracted", "origin_scope": "same_origin", "total": 2, "retained_count": 2, "items": [ { "name": "--primary-color", "value": "#007acc" }, { "name": "--spacing-unit", "value": "8px" } ] }
For evidence-bearing changes:
- Observed, derived, and inferred claims remain distinguishable.
- Artifact identity, source provenance, and failed attempts remain preserved.
- Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
node scripts/run-typescript.mjs --noEmit— 0 errors across all 5,275 files.npx.cmd vitest run src/domain/browserObservation.test.ts src/browser/CdpCaptureCssVariables.test.ts tests/boundary/cli/browserCssVariablesCli.test.ts— 23/23 tests passed.npm.cmd run check:fast— turbo typecheck + lint 2/2 tasks successful.npm.cmd run format:check— 0 formatting issues across 5,766 files.npm.cmd run docs:check— 6/6 tasks successful, 9/9 readme conformance tests passed.npm.cmd run mcp-catalog:check— 4/4 tasks successful.npm.cmd run build:cached— 3/3 tasks successful.
Compatibility, safety, and release
- Breaking changes or migration steps: None.
include_css_variablesis optional and defaults tofalse. - Real Hopper/Ghidra, browser, or OS coverage: Validated against CDP protocol contract specifications on Windows.
- Security, privacy, process, or containment review: Fully bounded: 250 items max, 512 bytes per value max, 5-level nested
var()limit, non-printable & control characters stripped, 2000-variable intake cap to prevent memory exhaustion, detached DOM node resilience (-32000), guaranteedCSS.disablecleanup.
Author readiness
Human owner: @Humaam-04-06
- I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
- I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
- I declare this PR ready for initial maintainer review.
Before merge
- This PR addresses a concrete problem or an agreed enhancement.
- Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
- The PR has one focused outcome and the title follows
type(scope): outcome. - Related issue is linked, or the reason for not linking one is stated above.
- Tests cover changed observable behavior and meaningful failure paths.
- Owning docs, contracts, and generated metadata are updated where needed.
- User-visible CLI/MCP changes include representative output.
- I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Activity
17Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
|---|---|---|---|
| 📝 Code Review | ✅ Completed 2026-10-25T14:42:37.824361Z | 834becb | New commits |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
5ae76461f7bd9cWant your agent to iterate on Greptile's feedback? Try greploops.
5d2b355
[Medium impact] The PR appears safe to merge based on the reviewed changes.
Summary
Adds optional root CSS variable capture to browser inspection, with bounded results, credential redaction, and coverage reporting.
Diagram
Reviews (13) · Last reviewed commit: "fix(browser): recognize escaped url func..." · Reviewed by Greptile