All work
Browser extension · 2026

Context Lens

A browser extension that reads the page you're on and explains posts and threads in context — multi-provider AI, visible pipeline, tested.

Type
Browser extension
Year
2026
Stack
TypeScript · Vite · Vitest
TypeScriptViteVitestChrome Extension APIsMulti-provider AI (BYOK)
Context Lens
The problem

Understanding a post or a thread on X, Reddit, or YouTube means copy-pasting into a chat window and losing all the context. The information that makes a post make sense — who is replying to whom, what the parent said — never makes the trip.

Constraints
  • 01

    Every platform structures its DOM differently, and redesigns break selectors.

  • 02

    AI calls cost money and fail — the extension must show its work and degrade honestly.

  • 03

    API keys belong to the user, not the extension.

What was built
  1. 01

    Platform adapters (X / Reddit / YouTube / generic fallback) parse each site into one canonical node model — the rest of the system never knows which site it's on.

  2. 02

    A context engine builds a graph and resolves task-specific depth under a token budget: caption tasks pay for minimal context, understanding tasks get the full package.

  3. 03

    A model router with automatic provider fallback (Gemini → Groq → NVIDIA → OpenRouter), BYOK — keys stay local, no accounts, no telemetry.

  4. 04

    A visible pipeline: every run shows reading page → found target → built context → asking provider → done/failed with reason. Results render as observed / inference / speculation.

Engineering decisions

Canonical model over per-site logic

Each platform is parsed once into {id, type, text, author, parentId, children} nodes. Tasks and the AI layer consume only the canonical graph — adding a platform means writing one adapter, not rewriting features.

Cost scales with the task

The context engine packages different context for different tasks, so a lightweight caption request doesn't pay for deep-thread context it never uses.

Result
  • ✓

    Vitest test suite covering the adapters, the context engine, and the AI layer.

  • ✓

    TypeScript throughout, typechecked build (tsc --noEmit) as part of the workflow.