π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
docs: update AGENTS.md with current architecture
Luis Ortiz5167247ac937
diff --git a/AGENTS.md b/AGENTS.mdindex b9f9b9d..6d9f330 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -12,37 +12,170 @@ You click "Record," perform a workflow in your browser, and Mimik automatically**Everything runs in the Chrome extension. No backend.**-- Storage: IndexedDB (browser-local)+- Storage: IndexedDB via Dexie.js (browser-local)- AI descriptions: optional, user provides their own API key in settings- Export: generated client-side (no server rendering)- No auth, no database, no hosting, no Docker-## Features+### Directory Structure-| Feature | Description |-| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| **Record** | Click the extension, perform your workflow. Every click/input auto-captures a screenshot with the element highlighted and a description generated. rrweb DOM recording runs alongside for video-like playback. |-| **Edit** | Side panel UI to reorder steps, rename titles, edit descriptions, blur sensitive areas on screenshots, delete steps. |-| **Replay** | Open a saved guide and hit replay. The extension walks through each step on the live page β finds elements, clicks/types for you, advances automatically. |-| **Export** | Download as self-contained HTML (offline), Markdown (for docs/wikis/repos), or PDF. All generated client-side. |-| **Settings** | Optional AI API key (OpenAI/Anthropic) for auto-generated step descriptions. Tool works without it. |-| **Storage** | All guides saved locally in IndexedDB. No account, no server, no data leaves the browser. |+```+src/+βββ core/ # Business logic (no UI dependencies)+β βββ capture/ # Recording pipeline, event detection, screenshots+β βββ export/ # HTML, PDF, Markdown export generators+β βββ guides/ # Data layer: types, Dexie DB, CRUD service+βββ entrypoints/ # Chrome extension entry points (WXT)+β βββ background/ # Service worker: state machine, message handlers, tab management+β βββ content.ts # Content script: event capture, overlay, rrweb recording+β βββ sidepanel/ # Side panel React mount+β βββ fullview/ # Full-page view React mount+β βββ options/ # Settings page React mount+βββ lib/ # Shared utilities+β βββ messaging.ts # Extension messaging protocol (webext-core)+β βββ port.ts # Long-lived port: background β sidepanel+β βββ browser-api.ts # Chrome API wrappers+β βββ tab-messages.ts # Content script message types+β βββ logger.ts # Logging utility+β βββ utils.ts # Shared helpers (dates, URLs, cn)+βββ stores/ # Zustand state stores+β βββ fullview.ts # Fullview UI state (search, counts, guide data)+βββ ui/ # React components+ βββ components/ui/ # shadcn/ui primitives (button, input, dialog, badge)+ βββ fullview/ # Full-page dashboard+ β βββ components/ # Extracted sub-components (grid, list, search, etc.)+ β βββ App.tsx+ β βββ TopNav.tsx+ β βββ SearchModal.tsx+ β βββ GuideContent.tsx+ β βββ LibraryContent.tsx+ β βββ router.ts+ βββ sidepanel/ # Side panel UI+ β βββ App.tsx+ β βββ LibraryView.tsx+ β βββ GuideEditor.tsx+ β βββ RecordingView.tsx+ β βββ StepCard.tsx+ β βββ ExportMenu.tsx+ β βββ BlurCanvas.tsx+ β βββ ZoomScreenshot.tsx+ βββ options/ # Settings page+ βββ App.tsx+```++## State Management++| Layer | Tool | Purpose |+|-------|------|---------|+| Capture lifecycle | xstate | State machine (IDLE β RECORDING) in background service worker |+| Fullview UI | Zustand | Search modal, guide counts, active guide data |+| Persistence | Dexie (IndexedDB) | Guides, steps, screenshots, rrweb chunks |+| Service worker recovery | sessionStorage | xstate machine snapshot persistence |+| Background β Sidepanel | Port messaging | Real-time state broadcast |++## Extension Entry Points++| Entry Point | File | Purpose |+|-------------|------|---------|+| Background | `entrypoints/background/` | Service worker: xstate actor, message handlers, tab management, navigation tracking |+| Content Script | `entrypoints/content.ts` | Injected into all tabs: CaptureSession, event listeners, rrweb, highlight overlay |+| Side Panel | `entrypoints/sidepanel/` | Recording controls, library, guide editor |+| Full View | `entrypoints/fullview/` | Dashboard: library browse, guide viewer, Ctrl+K search |+| Options | `entrypoints/options/` | AI API key settings (OpenAI / Anthropic) |++## Messaging++```+Content Script ββ Background Service Worker ββ Sidepanel / Fullview+```++**Extension messages** (webext-core, `lib/messaging.ts`):+- `getState` β current capture state, step count, guide ID+- `startRecording({url})` β creates guide, returns guideId+- `stopRecording()` β finalizes guide+- `userAction({guideId, action, elementMeta})` β processes captured step+- `rrwebChunk({guideId, events, timestamp})` β stores DOM recording chunk++**Tab messages** (content script β background, `lib/tab-messages.ts`):+- `PING` / `START_CAPTURE` / `STOP_CAPTURE` β lifecycle+- `HIDE_OVERLAY` / `SHOW_OVERLAY` β overlay toggle before/after screenshot+- `SHOW_NOTIFICATION` β "Recording started" overlay+- `URL_CHANGED` / `GET_ROUTE` β SPA navigation tracking++## Capture Pipeline++**Start recording:**+1. User clicks "Start Capture" in sidepanel+2. Background transitions xstate machine IDLE β RECORDING+3. Creates Guide in IndexedDB, broadcasts `START_CAPTURE` to all tabs+4. Content scripts initialize CaptureSession (event listeners + rrweb)+5. Shows recording notification overlay on active tab++**Capture a step:**+1. Content script detects user action (click, input, drag)+2. Extracts ElementMeta (selector, text, aria labels, position)+3. Sends `userAction` to background+4. Background hides overlay β `captureVisibleTab` β shows overlay+5. Optionally sends screenshot to AI for description (OpenAI/Anthropic)+6. Saves Step + Screenshot to IndexedDB++**Stop recording:**+1. Background transitions RECORDING β IDLE+2. Broadcasts `STOP_CAPTURE`, content scripts flush rrweb events+3. Opens fullview dashboard with the guide++## Export Formats++| Format | Generator | Details |+|--------|-----------|---------|+| HTML | `core/export/html-export.ts` | Self-contained, base64 images, inline CSS |+| PDF | `core/export/pdf-export.ts` | jsPDF, A4 portrait, auto page breaks |+| Markdown | `core/export/markdown-export.ts` | Standard MD with base64 image data URLs |## Tech Stack-- **Extension:** Chrome Manifest V3, TypeScript-- **UI:** React (side panel)-- **State management:** XState (workflow/capture state machine)-- **Session recording:** rrweb-- **Storage:** IndexedDB via Dexie.js-- **Export:** jsPDF (PDF), client-side HTML/Markdown generation-- **AI (optional):** Direct API calls to OpenAI/Anthropic from the extension+| Layer | Technology |+|-------|-----------|+| Extension framework | WXT (Manifest V3) |+| Language | TypeScript |+| UI | React 19 |+| Styling | Tailwind CSS v4 |+| Components | shadcn/ui |+| State (capture) | xstate |+| State (UI) | Zustand |+| Storage | Dexie.js (IndexedDB) |+| Messaging | webext-core |+| Session recording | rrweb |+| Export | jsPDF, client-side HTML/Markdown |+| AI (optional) | OpenAI SDK, Anthropic SDK |+| Icons | Lucide React |+| Dates | dayjs |+| DOM utils | css-selector-generator |++## Design System++All colors are defined as CSS variables in `src/ui/sidepanel/index.css` and used via Tailwind classes:++| Token | Color | Usage |+|-------|-------|-------|+| `--color-foreground` | `#451a03` | Primary text |+| `--color-muted-foreground` | `#92400E` | Secondary text |+| `--color-warm` | `#B45309` | Tertiary text |+| `--color-border` | `#E8E2DA` | Borders, dividers |+| `--color-secondary` | `#FEF3C7` | Light wash backgrounds |+| `--color-gold` | `#FDE68A` | Accent highlights |+| `--color-amber` | `#F59E0B` | Primary amber |+| `--color-primary` | `#451a03` | Dark backgrounds, badges |+| `--color-primary-foreground` | `#FDE68A` | Text on dark backgrounds |++Font: Poppins (loaded via `@fontsource/poppins`).## Key Technical Details-- **Screenshot capture** uses `chrome.tabs.captureVisibleTab` (Chrome API)-- **Step detection** tracks DOM elements via selectors and scoring, classifies actions (click/input/scroll)-- **Auto-titles** read element text, aria labels, and alt attributes-- **Workflow engine** is an XState state machine managing capture lifecycle, guidance, and replay-- **Replay** finds elements on live pages, executes click/type/scroll actions, advances through steps-- **rrweb** records DOM mutations for video-like session playback+- **Screenshot capture** uses `chrome.tabs.captureVisibleTab` with overlay hidden to avoid capturing the highlight+- **Event deduplication** merges fast clicks within 300ms on same element; max 4 clicks per 800ms window+- **Highlight overlay** uses a custom web component (`<mimik-highlight>`) with closed Shadow DOM at max z-index+- **Content script injection** pings first, falls back to `chrome.scripting.executeScript()` for tabs without the script+- **xstate snapshot** persisted to sessionStorage so the state machine survives service worker restarts+- **Recording notification** uses `animationend` event (not hardcoded delays) for timing+- **Font loading** uses `@fontsource/poppins` (CSP-safe, no CDN dependency)