How withgraphite/graphite-chrome-extension works
File structure
• Top-level config: .eslintrc, tsconfig.json, Yarn v3, esbuild script
• public/manifest.json – Chrome extension manifest and static assets
• src/background.ts – long-running background script handling API communication, authentication, storage
• src/pr-content-script.ts – content script injected into GitHub PR pages to render overlays and capture DOM events
• scripts/esbuild.js – custom build pipeline for bundling TS to browser-compatible JS
README for additional insights
• Confirms this is a closed-beta code review tool
• Mentions syncing changes and reviews via Graphite’s API (so the extension must authenticate and relay pull request data)
Main components
a. Browser & Extension Host
• Content Script (pr-content-script.ts)
• Background Script (background.ts)
• Browser Storage (LocalStorage or Extension storage)
b. GitHub Pull Request Page (DOM target for content script)
c. Graphite Backend API (external service)
d. Build Pipeline (esbuild script, Yarn)
Relationships and interactions
• Content Script ↔ Background Script via Chrome Runtime Messaging
• Content Script reads/writes to the GitHub PR DOM, captures review events (clicks, comments)
• Background Script handles authentication tokens, caches data in extension storage, and makes HTTP/HTTPS calls to Graphite API
• Graphite Backend responds with review threads, code snippets, and syncs PR state
• Build Pipeline (esbuild) processes src/*.ts → public/*.js and packages manifest
Architectural patterns & design principles
• Event-driven message passing between content and background scripts
• Single responsibility: content script for UI injection, background for networking and storage
• Separation of concerns via manifest declaring permissions and script roles
Technologies & frameworks
• TypeScript (strict typing)
• esbuild (fast, JS bundler)
• Yarn v3 (package management, PnP)
• Chrome Extension APIs (runtime messaging, storage, contentScripts)
Detail
• Manifest’s role in declaring permissions (e.g., host permissions for api.graphite.dev, content_scripts targeting github.com)
• Build script outside of the browser boundary, feeding into the extension package