[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKM8EJ2AATVHZBNB916WT0":3,"skill-same:01M6KKM8EJ2AATVHZBNB916WT0":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":13,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference",null,"Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"worldmonitor reference","worldmonitor","reference","hierarchy","css","source","for","layer","extracting","panel","patterns","edge functions","integrations","open","api","data","scheduler","architecture","dashboard","typescript","2026-11-10 10:12:30",false,"---\nname: worldmonitor-reference\ndescription: Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.\n---\n\n# WorldMonitor Architecture Reference\n\nWorldMonitor is a real-time global intelligence dashboard built with vanilla TypeScript (no framework). This skill provides a curated index of its architecture, organized by the patterns most relevant to building a personal daily monitor.\n\n## When to Use\n\n- You are creating a new dashboard panel and need to follow WorldMonitor conventions\n- You need to understand how a specific pattern works before adapting it\n- You are deciding which WorldMonitor patterns to adopt vs. simplify for a personal project\n\n## Project Overview\n\n| Aspect | Detail |\n|--------|--------|\n| **Language** | TypeScript (strict), vanilla DOM — no React\u002FVue\u002FAngular |\n| **Bundler** | Vite |\n| **Deployment** | Vercel (60+ Edge Functions) + Railway (WebSocket relay) |\n| **Desktop** | Tauri 2 (Rust) with Node.js sidecar |\n| **Map engines** | globe.gl + Three.js (3D), deck.gl + MapLibre GL (2D) |\n| **CSS** | Custom properties, dark\u002Flight themes, responsive grid |\n| **API contracts** | Protocol Buffers (92 proto files, 22 services) |\n| **Data sources** | 435+ RSS feeds, 45 data layers, 30+ live video streams |\n\n## Directory Structure\n\n```\nworldmonitor\u002F\n├── src\u002F\n│   ├── main.ts                    # Entry point: Sentry, analytics, App bootstrap\n│   ├── App.ts                     # Root application class\n│   ├── components\u002F                # All UI panel classes (80+ files)\n│   │   ├── Panel.ts               # *** BASE CLASS — most important file ***\n│   │   ├── VirtualList.ts         # Virtual scrolling for large lists\n│   │   ├── NewsPanel.ts           # News with clustering, NER, summaries\n│   │   ├── MarketPanel.ts         # Stock market with sparklines\n│   │   ├── SearchModal.ts         # Cmd+K command palette\n│   │   ├── InsightsPanel.ts       # AI briefing + metrics\n│   │   ├── WorldClockPanel.ts     # Multi-timezone clock\n│   │   └── ...                    # 70+ more panels\n│   ├── services\u002F                  # Data layer (117 files)\n│   │   ├── runtime.ts             # SmartPollLoop, desktop detection, fetch routing\n│   │   ├── bootstrap.ts           # Initial data hydration from Redis\n│   │   ├── rss.ts                 # RSS feed aggregation\n│   │   ├── news\u002Findex.ts          # News fetching + processing\n│   │   ├── market\u002Findex.ts        # Market data (Yahoo Finance, Finnhub)\n│   │   ├── i18n.ts                # 21-language internationalization\n│   │   ├── threat-classifier.ts   # 3-stage threat classification\n│   │   ├── clustering.ts          # News headline clustering\n│   │   └── ...                    # 100+ more services\n│   ├── config\u002F                    # Static configuration\n│   │   ├── variant.ts             # Multi-variant (world\u002Ftech\u002Ffinance\u002Fcommodity\u002Fhappy)\n│   │   ├── feeds.ts               # 435+ RSS feed definitions\n│   │   ├── panels.ts              # Panel enable\u002Fdisable config\n│   │   ├── markets.ts             # Stock symbol lists\n│   │   └── ...\n│   ├── app\u002F                       # Application-level modules\n│   │   ├── app-context.ts         # Shared state (inFlight, isDestroyed)\n│   │   ├── refresh-scheduler.ts   # *** REFRESH PATTERN ***\n│   │   ├── panel-layout.ts        # Grid layout management\n│   │   ├── search-manager.ts      # Command palette logic\n│   │   └── event-handlers.ts      # Global keyboard\u002Fvisibility events\n│   ├── utils\u002F                     # Utilities (22 files)\n│   │   ├── dom-utils.ts           # h(), fragment(), replaceChildren() — JSX-free helpers\n│   │   ├── sanitize.ts            # escapeHtml(), sanitizeUrl() — XSS prevention\n│   │   ├── index.ts               # formatTime, formatNumber, etc.\n│   │   └── ...\n│   ├── styles\u002F                    # CSS\n│   │   ├── main.css               # *** THEME VARIABLES + GRID LAYOUT ***\n│   │   ├── panels.css             # Panel-specific styles (tabs, rows, badges)\n│   │   ├── base-layer.css         # Foundation layer\n│   │   └── ...\n│   └── generated\u002F                 # Auto-generated from .proto files\n│       ├── client\u002F                # TypeScript API clients\n│       └── server\u002F                # TypeScript API handlers\n├── api\u002F                           # Vercel Edge Functions (60+)\n│   ├── _cors.js                   # CORS origin allowlist\n│   ├── _rate-limit.js             # Upstash Redis rate limiting\n│   ├── _api-key.js                # API key injection\n│   ├── bootstrap.js               # Pre-fetch 15 Redis keys for first render\n│   ├── rss-proxy.js               # RSS feed proxy with domain allowlist\n│   ├── market\u002Fv1\u002F[rpc].ts         # Market data endpoints (proto-first)\n│   ├── news\u002Fv1\u002F[rpc].ts           # News endpoints\n│   └── ...                        # 22 service domains\n├── server\u002F                        # Railway relay server\n├── proto\u002F                         # Protocol Buffer definitions\n└── tests\u002F                         # 30 test files, 554 test cases\n```\n\n## Core Pattern: Panel Base Class\n\n**File**: `src\u002Fcomponents\u002FPanel.ts` (~1000 lines)\n\nThe Panel class is the foundation for ALL UI components (80+ panels inherit from it).\n\n### Constructor Options\n\n```typescript\ninterface PanelOptions {\n  id: string;          \u002F\u002F Unique panel identifier (used in DOM data-panel attr)\n  title: string;       \u002F\u002F Display title in header\n  showCount?: boolean; \u002F\u002F Show item count badge\n  className?: string;  \u002F\u002F Additional CSS class (e.g., 'panel-wide')\n  trackActivity?: boolean; \u002F\u002F Enable activity tracking\n  infoTooltip?: string;    \u002F\u002F Hover tooltip text\n  premium?: 'locked' | 'enhanced'; \u002F\u002F Pro feature gating\n}\n```\n\n### DOM Structure\n\n```\ndiv.panel[data-panel=\"{id}\"]\n├── div.panel-header\n│   ├── div.panel-header-left\n│   │   ├── span.panel-title\n│   │   └── span.panel-new-badge (optional)\n│   ├── span.panel-data-badge (optional, \"LIVE\"\u002F\"CACHED\")\n│   └── span.panel-count (optional)\n├── div.panel-content\n│   └── (loading spinner | error state | rendered content)\n└── div.panel-resize-handle\n```\n\n### Key Methods\n\n| Method | Purpose |\n|--------|---------|\n| `getElement()` | Returns the outer `div.panel` |\n| `showLoading(msg?)` | Display spinner + message |\n| `showError(msg, onRetry?)` | Display error with optional retry button |\n| `setContent(html)` | Set content innerHTML (debounced 150ms) |\n| `setContentDirect(html)` | Set content immediately (no debounce) |\n| `setCount(n)` | Update the count badge |\n| `setStatusBadge(label, type)` | Show \"LIVE\"\u002F\"CACHED\" badge |\n| `show() \u002F hide()` | Toggle visibility |\n| `destroy()` | Remove element, abort controller, cleanup listeners |\n\n### Resize System\n\nPanels support both row span (1-4 rows) and column span (1-3 cols) resizing via drag handles. Sizes are persisted in `localStorage` with keys `worldmonitor-panel-spans` and `worldmonitor-panel-col-spans`.\n\n## Core Pattern: Data Service Layer\n\n**Directory**: `src\u002Fservices\u002F` (117 files)\n\n### SmartPollLoop\n\n**File**: `src\u002Fservices\u002Fruntime.ts`\n\nInstead of raw `setInterval`, WorldMonitor uses `startSmartPollLoop()`:\n\n```typescript\nconst loop = startSmartPollLoop(async () => {\n  \u002F\u002F fetch data, return boolean for success\u002Ffailure\n}, intervalMs);\nloop.stop(); \u002F\u002F cleanup\n```\n\nFeatures:\n- Exponential backoff on failure (1x → 2x → 4x, capped at 8x)\n- Hidden-tab throttle (pauses when `document.hidden`)\n- Circuit breaker integration (stops after N consecutive failures)\n- Adaptive refresh (can adjust interval based on data freshness)\n\n### Service Module Convention\n\nEach service is a module (not a class) exporting async functions:\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fmarket\u002Findex.ts\nexport async function fetchMarketQuotes(symbols: string[]): Promise\u003CMarketQuote[]> { ... }\nexport async function fetchMarketNews(): Promise\u003CMarketNews[]> { ... }\n```\n\nServices call `\u002Fapi\u002F...` proxy endpoints, never external APIs directly.\n\n## Core Pattern: CSS Theme System\n\n**File**: `src\u002Fstyles\u002Fmain.css` (~17,000 lines)\n\n### CSS Custom Properties (Dark Theme)\n\n```css\n:root {\n  \u002F* Backgrounds *\u002F\n  --bg: #0a0a0a;\n  --bg-secondary: #111;\n  --surface: #141414;\n  --surface-hover: #1e1e1e;\n\n  \u002F* Borders *\u002F\n  --border: #2a2a2a;\n  --border-strong: #444;\n  --border-subtle: #1a1a1a;\n\n  \u002F* Text *\u002F\n  --text: #e8e8e8;\n  --text-secondary: #ccc;\n  --text-dim: #888;\n  --text-muted: #666;\n  --accent: #fff;\n\n  \u002F* Semantic Colors *\u002F\n  --semantic-critical: #ff4444;\n  --semantic-high: #ff8800;\n  --semantic-elevated: #ffaa00;\n  --semantic-normal: #44aa44;\n  --semantic-info: #3b82f6;\n\n  \u002F* Status *\u002F\n  --green: #44ff88;\n  --red: #ff4444;\n  --yellow: #ffaa00;\n\n  \u002F* Font Stack *\u002F\n  --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Fira Code', monospace;\n  --font-body: var(--font-mono);\n}\n```\n\n### Grid Layout\n\n```css\n.panels-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));\n  grid-auto-flow: row dense;\n  grid-auto-rows: minmax(200px, 380px);\n  gap: 4px;\n  padding: 4px;\n}\n```\n\n### Panel Base Styles\n\n```css\n.panel {\n  background: var(--surface);\n  border: 1px solid var(--border);\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.panel-header {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 6px 10px;\n  background: var(--overlay-subtle);\n  border-bottom: 1px solid var(--border);\n}\n\n.panel-title {\n  font-size: 11px;\n  font-weight: 700;\n  color: var(--accent);\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n}\n\n.panel-content {\n  flex: 1;\n  overflow-y: auto;\n  padding: 8px;\n  font-size: 12px;\n}\n```\n\n## Core Pattern: API Proxy Layer\n\n**Directory**: `api\u002F` (60+ Vercel Edge Functions)\n\n### CORS Helper (`api\u002F_cors.js`)\n\nOrigin allowlist pattern — only approved origins can call API endpoints:\n\n```javascript\nconst ALLOWED_ORIGIN_PATTERNS = [\n  \u002F^https:\\\u002F\\\u002F(.*\\.)?worldmonitor\\.app$\u002F,\n  \u002F^https?:\\\u002F\\\u002Flocalhost(:\\d+)?$\u002F,\n];\n\nexport function getCorsHeaders(req, methods = 'GET, OPTIONS') {\n  const origin = req.headers.get('origin') || '';\n  const allowOrigin = isAllowedOrigin(origin) ? origin : 'https:\u002F\u002Fworldmonitor.app';\n  return {\n    'Access-Control-Allow-Origin': allowOrigin,\n    'Access-Control-Allow-Methods': methods,\n    'Access-Control-Allow-Headers': 'Content-Type',\n  };\n}\n```\n\n### Edge Function Pattern\n\nEach endpoint file follows this structure:\n1. CORS preflight handling\n2. Input validation\n3. API key from `process.env`\n4. Upstream fetch with error wrapping\n5. `Cache-Control` headers for CDN caching\n6. Structured JSON response\n\n## Core Pattern: Refresh Scheduler\n\n**File**: `src\u002Fapp\u002Frefresh-scheduler.ts`\n\n```typescript\ninterface RefreshRegistration {\n  name: string;\n  fn: () => Promise\u003Cboolean | void>;\n  intervalMs: number;\n  condition?: () => boolean;   \u002F\u002F Skip refresh if false\n}\n\nclass RefreshScheduler {\n  scheduleRefresh(name, fn, intervalMs, condition?): void\n  flushStaleRefreshes(hiddenMs): void   \u002F\u002F Staggered 150ms between each\n  destroy(): void\n}\n```\n\nKey behaviors:\n- Each panel registers with a unique name and interval\n- Visibility-aware: pauses when tab hidden, flushes stale on return\n- In-flight guard: `ctx.inFlight` set prevents duplicate refreshes\n- Stagger on resume: 150ms gap between each stale refresh to avoid API burst\n\n## Core Pattern: DOM Utilities\n\n**File**: `src\u002Futils\u002Fdom-utils.ts`\n\nWorldMonitor uses a lightweight JSX-free helper `h()`:\n\n```typescript\nfunction h(tag: string, propsOrChild?, ...children): HTMLElement\nfunction fragment(...children): DocumentFragment\nfunction replaceChildren(el: Element, ...children): void\nfunction rawHtml(html: string): DocumentFragment\nfunction safeHtml(html: string): string  \u002F\u002F XSS-safe innerHTML\n```\n\nExample usage:\n```typescript\nconst row = h('div', { className: 'stock-row' },\n  h('span', { className: 'symbol' }, 'AAPL'),\n  h('span', { className: 'price' }, '$178.72'),\n);\n```\n\n## Adaptation Notes for Personal Monitor\n\nWhen adapting WorldMonitor patterns for my-daily-monitor:\n\n| WorldMonitor Feature | Personal Monitor Adaptation |\n|---------------------|----------------------------|\n| 80+ panel classes | 15-20 panels (email, feishu, office, social, etc.) |\n| Proto-first API | Simple REST endpoints (no proto needed) |\n| Vercel Edge Functions | Vite dev server plugin or simple Express routes |\n| SmartPollLoop | Simplified RefreshScheduler with setInterval |\n| VirtualList | Not needed until panel has 100+ items |\n| Multi-variant (5 sites) | Single variant only |\n| 21 languages (i18n) | Chinese + English only |\n| Tauri desktop app | Web-only (may add later) |\n| Redis caching | In-memory cache only |\n\n## Key Files to Study\n\nWhen extracting a specific pattern, start with these files:\n\n| Pattern | Read First | Then Read |\n|---------|-----------|-----------|\n| Panel architecture | `src\u002Fcomponents\u002FPanel.ts` | Any concrete panel (e.g., `NewsPanel.ts`) |\n| Service layer | `src\u002Fservices\u002Fruntime.ts` | `src\u002Fservices\u002Fmarket\u002Findex.ts` |\n| CSS theme | `src\u002Fstyles\u002Fmain.css` (first 60 lines) | `src\u002Fstyles\u002Fpanels.css` |\n| API proxy | `api\u002F_cors.js` | Any `api\u002F*\u002Fv1\u002F[rpc].ts` |\n| Refresh | `src\u002Fapp\u002Frefresh-scheduler.ts` | `src\u002Fapp\u002Fevent-handlers.ts` |\n| Grid layout | `src\u002Fstyles\u002Fmain.css` (search `.panels-grid`) | `src\u002Fapp\u002Fpanel-layout.ts` |\n| DOM helpers | `src\u002Futils\u002Fdom-utils.ts` | `src\u002Futils\u002Fsanitize.ts` |\n| Entry point | `src\u002Fmain.ts` | `src\u002FApp.ts` |\n\n","# WorldMonitor Architecture Reference\n\nWorldMonitor is a real-time global intelligence dashboard built with vanilla TypeScript (no framework). This skill provides a curated index of its architecture, organized by the patterns most relevant to building a personal daily monitor.\n\n## When to Use\n\n- You are creating a new dashboard panel and need to follow WorldMonitor conventions\n- You need to understand how a specific pattern works before adapting it\n- You are deciding which WorldMonitor patterns to adopt vs. simplify for a personal project\n\n## Project Overview\n\n| Aspect | Detail |\n|--------|--------|\n| **Language** | TypeScript (strict), vanilla DOM — no React\u002FVue\u002FAngular |\n| **Bundler** | Vite |\n| **Deployment** | Vercel (60+ Edge Functions) + Railway (WebSocket relay) |\n| **Desktop** | Tauri 2 (Rust) with Node.js sidecar |\n| **Map engines** | globe.gl + Three.js (3D), deck.gl + MapLibre GL (2D) |\n| **CSS** | Custom properties, dark\u002Flight themes, responsive grid |\n| **API contracts** | Protocol Buffers (92 proto files, 22 services) |\n| **Data sources** | 435+ RSS feeds, 45 data layers, 30+ live video streams |\n\n## Directory Structure\n\n```\nworldmonitor\u002F\n├── src\u002F\n│   ├── main.ts                    # Entry point: Sentry, analytics, App bootstrap\n│   ├── App.ts                     # Root application class\n│   ├── components\u002F                # All UI panel classes (80+ files)\n│   │   ├── Panel.ts               # *** BASE CLASS — most important file ***\n│   │   ├── VirtualList.ts         # Virtual scrolling for large lists\n│   │   ├── NewsPanel.ts           # News with clustering, NER, summaries\n│   │   ├── MarketPanel.ts         # Stock market with sparklines\n│   │   ├── SearchModal.ts         # Cmd+K command palette\n│   │   ├── InsightsPanel.ts       # AI briefing + metrics\n│   │   ├── WorldClockPanel.ts     # Multi-timezone clock\n│   │   └── ...                    # 70+ more panels\n│   ├── services\u002F                  # Data layer (117 files)\n│   │   ├── runtime.ts             # SmartPollLoop, desktop detection, fetch routing\n│   │   ├── bootstrap.ts           # Initial data hydration from Redis\n│   │   ├── rss.ts                 # RSS feed aggregation\n│   │   ├── news\u002Findex.ts          # News fetching + processing\n│   │   ├── market\u002Findex.ts        # Market data (Yahoo Finance, Finnhub)\n│   │   ├── i18n.ts                # 21-language internationalization\n│   │   ├── threat-classifier.ts   # 3-stage threat classification\n│   │   ├── clustering.ts          # News headline clustering\n│   │   └── ...                    # 100+ more services\n│   ├── config\u002F                    # Static configuration\n│   │   ├── variant.ts             # Multi-variant (world\u002Ftech\u002Ffinance\u002Fcommodity\u002Fhappy)\n│   │   ├── feeds.ts               # 435+ RSS feed definitions\n│   │   ├── panels.ts              # Panel enable\u002Fdisable config\n│   │   ├── markets.ts             # Stock symbol lists\n│   │   └── ...\n│   ├── app\u002F                       # Application-level modules\n│   │   ├── app-context.ts         # Shared state (inFlight, isDestroyed)\n│   │   ├── refresh-scheduler.ts   # *** REFRESH PATTERN ***\n│   │   ├── panel-layout.ts        # Grid layout management\n│   │   ├── search-manager.ts      # Command palette logic\n│   │   └── event-handlers.ts      # Global keyboard\u002Fvisibility events\n│   ├── utils\u002F                     # Utilities (22 files)\n│   │   ├── dom-utils.ts           # h(), fragment(), replaceChildren() — JSX-free helpers\n│   │   ├── sanitize.ts            # escapeHtml(), sanitizeUrl() — XSS prevention\n│   │   ├── index.ts               # formatTime, formatNumber, etc.\n│   │   └── ...\n│   ├── styles\u002F                    # CSS\n│   │   ├── main.css               # *** THEME VARIABLES + GRID LAYOUT ***\n│   │   ├── panels.css             # Panel-specific styles (tabs, rows, badges)\n│   │   ├── base-layer.css         # Foundation layer\n│   │   └── ...\n│   └── generated\u002F                 # Auto-generated from .proto files\n│       ├── client\u002F                # TypeScript API clients\n│       └── server\u002F                # TypeScript API handlers\n├── api\u002F                           # Vercel Edge Functions (60+)\n│   ├── _cors.js                   # CORS origin allowlist\n│   ├── _rate-limit.js             # Upstash Redis rate limiting\n│   ├── _api-key.js                # API key injection\n│   ├── bootstrap.js               # Pre-fetch 15 Redis keys for first render\n│   ├── rss-proxy.js               # RSS feed proxy with domain allowlist\n│   ├── market\u002Fv1\u002F[rpc].ts         # Market data endpoints (proto-first)\n│   ├── news\u002Fv1\u002F[rpc].ts           # News endpoints\n│   └── ...                        # 22 service domains\n├── server\u002F                        # Railway relay server\n├── proto\u002F                         # Protocol Buffer definitions\n└── tests\u002F                         # 30 test files, 554 test cases\n```\n\n## Core Pattern: Panel Base Class\n\n**File**: `src\u002Fcomponents\u002FPanel.ts` (~1000 lines)\n\nThe Panel class is the foundation for ALL UI components (80+ panels inherit from it).\n\n### Constructor Options\n\n```typescript\ninterface PanelOptions {\n  id: string;          \u002F\u002F Unique panel identifier (used in DOM data-panel attr)\n  title: string;       \u002F\u002F Display title in header\n  showCount?: boolean; \u002F\u002F Show item count badge\n  className?: string;  \u002F\u002F Additional CSS class (e.g., 'panel-wide')\n  trackActivity?: boolean; \u002F\u002F Enable activity tracking\n  infoTooltip?: string;    \u002F\u002F Hover tooltip text\n  premium?: 'locked' | 'enhanced'; \u002F\u002F Pro feature gating\n}\n```\n\n### DOM Structure\n\n```\ndiv.panel[data-panel=\"{id}\"]\n├── div.panel-header\n│   ├── div.panel-header-left\n│   │   ├── span.panel-title\n│   │   └── span.panel-new-badge (optional)\n│   ├── span.panel-data-badge (optional, \"LIVE\"\u002F\"CACHED\")\n│   └── span.panel-count (optional)\n├── div.panel-content\n│   └── (loading spinner | error state | rendered content)\n└── div.panel-resize-handle\n```\n\n### Key Methods\n\n| Method | Purpose |\n|--------|---------|\n| `getElement()` | Returns the outer `div.panel` |\n| `showLoading(msg?)` | Display spinner + message |\n| `showError(msg, onRetry?)` | Display error with optional retry button |\n| `setContent(html)` | Set content innerHTML (debounced 150ms) |\n| `setContentDirect(html)` | Set content immediately (no debounce) |\n| `setCount(n)` | Update the count badge |\n| `setStatusBadge(label, type)` | Show \"LIVE\"\u002F\"CACHED\" badge |\n| `show() \u002F hide()` | Toggle visibility |\n| `destroy()` | Remove element, abort controller, cleanup listeners |\n\n### Resize System\n\nPanels support both row span (1-4 rows) and column span (1-3 cols) resizing via drag handles. Sizes are persisted in `localStorage` with keys `worldmonitor-panel-spans` and `worldmonitor-panel-col-spans`.\n\n## Core Pattern: Data Service Layer\n\n**Directory**: `src\u002Fservices\u002F` (117 files)\n\n### SmartPollLoop\n\n**File**: `src\u002Fservices\u002Fruntime.ts`\n\nInstead of raw `setInterval`, WorldMonitor uses `startSmartPollLoop()`:\n\n```typescript\nconst loop = startSmartPollLoop(async () => {\n  \u002F\u002F fetch data, return boolean for success\u002Ffailure\n}, intervalMs);\nloop.stop(); \u002F\u002F cleanup\n```\n\nFeatures:\n- Exponential backoff on failure (1x → 2x → 4x, capped at 8x)\n- Hidden-tab throttle (pauses when `document.hidden`)\n- Circuit breaker integration (stops after N consecutive failures)\n- Adaptive refresh (can adjust interval based on data freshness)\n\n### Service Module Convention\n\nEach service is a module (not a class) exporting async functions:\n\n```typescript\n\u002F\u002F src\u002Fservices\u002Fmarket\u002Findex.ts\nexport async function fetchMarketQuotes(symbols: string[]): Promise\u003CMarketQuote[]> { ... }\nexport async function fetchMarketNews(): Promise\u003CMarketNews[]> { ... }\n```\n\nServices call `\u002Fapi\u002F...` proxy endpoints, never external APIs directly.\n\n## Core Pattern: CSS Theme System\n\n**File**: `src\u002Fstyles\u002Fmain.css` (~17,000 lines)\n\n### CSS Custom Properties (Dark Theme)\n\n```css\n:root {\n  \u002F* Backgrounds *\u002F\n  --bg: #0a0a0a;\n  --bg-secondary: #111;\n  --surface: #141414;\n  --surface-hover: #1e1e1e;\n\n  \u002F* Borders *\u002F\n  --border: #2a2a2a;\n  --border-strong: #444;\n  --border-subtle: #1a1a1a;\n\n  \u002F* Text *\u002F\n  --text: #e8e8e8;\n  --text-secondary: #ccc;\n  --text-dim: #888;\n  --text-muted: #666;\n  --accent: #fff;\n\n  \u002F* Semantic Colors *\u002F\n  --semantic-critical: #ff4444;\n  --semantic-high: #ff8800;\n  --semantic-elevated: #ffaa00;\n  --semantic-normal: #44aa44;\n  --semantic-info: #3b82f6;\n\n  \u002F* Status *\u002F\n  --green: #44ff88;\n  --red: #ff4444;\n  --yellow: #ffaa00;\n\n  \u002F* Font Stack *\u002F\n  --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', 'Fira Code', monospace;\n  --font-body: var(--font-mono);\n}\n```\n\n### Grid Layout\n\n```css\n.panels-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));\n  grid-auto-flow: row dense;\n  grid-auto-rows: minmax(200px, 380px);\n  gap: 4px;\n  padding: 4px;\n}\n```\n\n### Panel Base Styles\n\n```css\n.panel {\n  background: var(--surface);\n  border: 1px solid var(--border);\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.panel-header {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 6px 10px;\n  background: var(--overlay-subtle);\n  border-bottom: 1px solid var(--border);\n}\n\n.panel-title {\n  font-size: 11px;\n  font-weight: 700;\n  color: var(--accent);\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n}\n\n.panel-content {\n  flex: 1;\n  overflow-y: auto;\n  padding: 8px;\n  font-size: 12px;\n}\n```\n\n## Core Pattern: API Proxy Layer\n\n**Directory**: `api\u002F` (60+ Vercel Edge Functions)\n\n### CORS Helper (`api\u002F_cors.js`)\n\nOrigin allowlist pattern — only approved origins can call API endpoints:\n\n```javascript\nconst ALLOWED_ORIGIN_PATTERNS = [\n  \u002F^https:\\\u002F\\\u002F(.*\\.)?worldmonitor\\.app$\u002F,\n  \u002F^https?:\\\u002F\\\u002Flocalhost(:\\d+)?$\u002F,\n];\n\nexport function getCorsHeaders(req, methods = 'GET, OPTIONS') {\n  const origin = req.headers.get('origin') || '';\n  const allowOrigin = isAllowedOrigin(origin) ? origin : 'https:\u002F\u002Fworldmonitor.app';\n  return {\n    'Access-Control-Allow-Origin': allowOrigin,\n    'Access-Control-Allow-Methods': methods,\n    'Access-Control-Allow-Headers': 'Content-Type',\n  };\n}\n```\n\n### Edge Function Pattern\n\nEach endpoint file follows this structure:\n1. CORS preflight handling\n2. Input validation\n3. API key from `process.env`\n4. Upstream fetch with error wrapping\n5. `Cache-Control` headers for CDN caching\n6. Structured JSON response\n\n## Core Pattern: Refresh Scheduler\n\n**File**: `src\u002Fapp\u002Frefresh-scheduler.ts`\n\n```typescript\ninterface RefreshRegistration {\n  name: string;\n  fn: () => Promise\u003Cboolean | void>;\n  intervalMs: number;\n  condition?: () => boolean;   \u002F\u002F Skip refresh if false\n}\n\nclass RefreshScheduler {\n  scheduleRefresh(name, fn, intervalMs, condition?): void\n  flushStaleRefreshes(hiddenMs): void   \u002F\u002F Staggered 150ms between each\n  destroy(): void\n}\n```\n\nKey behaviors:\n- Each panel registers with a unique name and interval\n- Visibility-aware: pauses when tab hidden, flushes stale on return\n- In-flight guard: `ctx.inFlight` set prevents duplicate refreshes\n- Stagger on resume: 150ms gap between each stale refresh to avoid API burst\n\n## Core Pattern: DOM Utilities\n\n**File**: `src\u002Futils\u002Fdom-utils.ts`\n\nWorldMonitor uses a lightweight JSX-free helper `h()`:\n\n```typescript\nfunction h(tag: string, propsOrChild?, ...children): HTMLElement\nfunction fragment(...children): DocumentFragment\nfunction replaceChildren(el: Element, ...children): void\nfunction rawHtml(html: string): DocumentFragment\nfunction safeHtml(html: string): string  \u002F\u002F XSS-safe innerHTML\n```\n\nExample usage:\n```typescript\nconst row = h('div', { className: 'stock-row' },\n  h('span', { className: 'symbol' }, 'AAPL'),\n  h('span', { className: 'price' }, '$178.72'),\n);\n```\n\n## Adaptation Notes for Personal Monitor\n\nWhen adapting WorldMonitor patterns for my-daily-monitor:\n\n| WorldMonitor Feature | Personal Monitor Adaptation |\n|---------------------|----------------------------|\n| 80+ panel classes | 15-20 panels (email, feishu, office, social, etc.) |\n| Proto-first API | Simple REST endpoints (no proto needed) |\n| Vercel Edge Functions | Vite dev server plugin or simple Express routes |\n| SmartPollLoop | Simplified RefreshScheduler with setInterval |\n| VirtualList | Not needed until panel has 100+ items |\n| Multi-variant (5 sites) | Single variant only |\n| 21 languages (i18n) | Chinese + English only |\n| Tauri desktop app | Web-only (may add later) |\n| Redis caching | In-memory cache only |\n\n## Key Files to Study\n\nWhen extracting a specific pattern, start with these files:\n\n| Pattern | Read First | Then Read |\n|---------|-----------|-----------|\n| Panel architecture | `src\u002Fcomponents\u002FPanel.ts` | Any concrete panel (e.g., `NewsPanel.ts`) |\n| Service layer | `src\u002Fservices\u002Fruntime.ts` | `src\u002Fservices\u002Fmarket\u002Findex.ts` |\n| CSS theme | `src\u002Fstyles\u002Fmain.css` (first 60 lines) | `src\u002Fstyles\u002Fpanels.css` |\n| API proxy | `api\u002F_cors.js` | Any `api\u002F*\u002Fv1\u002F[rpc].ts` |\n| Refresh | `src\u002Fapp\u002Frefresh-scheduler.ts` | `src\u002Fapp\u002Fevent-handlers.ts` |\n| Grid layout | `src\u002Fstyles\u002Fmain.css` (search `.panels-grid`) | `src\u002Fapp\u002Fpanel-layout.ts` |\n| DOM helpers | `src\u002Futils\u002Fdom-utils.ts` | `src\u002Futils\u002Fsanitize.ts` |\n| Entry point | `src\u002Fmain.ts` | `src\u002FApp.ts` |\n\n",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","showcase\u002Fskills\u002Fworldmonitor-reference","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think about is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add AG064\u002FOpenSpace --skill worldmonitor-reference",{"tool":56,"command":57},"bunx","bunx skills add AG064\u002FOpenSpace --skill worldmonitor-reference",{"tool":59,"command":60},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill worldmonitor-reference","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",true,[64],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},".skill_id","OTHER","其他",36,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002F.skill_id",[71,93,110,119,135,151],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":38},"01M6KKMPWA0B5SCCH766F8M5EA","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[78,79,80,81,82,83,24,84,85,86,87,88,89,90,37,91,92],"check","write special chars ts check","write","only","Existing","type-checking","errors","template","filters","files","script","output","type","python","file",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":38},"01M6KKMJXVBNVEY3TRK055F4A7","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[100,80,101,102,91,103,104,92,85,105,106,107,108,109,88,24],"write special chars readback","readback","helper","cleanup","verification","read","scripts","via","post","with",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":38},"01M6KKMEGX9M9NC105J0W3Q5B9","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[117,80,91,24,92,118,85,107,88],"write special chars heredoc","shell",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":38},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[126,127,128,129,130,131,132,133,109,134,24],"virtual list","list","virtual","performance","implement","chunk","recycling","rendering","dom",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":38},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[142,143,144,145,146,147,148,92,149,150],"verify directory structure","structure","verify","directory","issues","diagnose","file access","first","access",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":38},"01M6KKKTH41ZNA3FHSSD4MFC7G","verify-directory-structure-parallel-audit","Diagnose and resolve file access issues by verifying directory structure, then reading multiple files in parallel batches for efficient auditing, with built-in guidance for validating TypeScript import patterns.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure-parallel-audit\u002FSKILL.md",[],[145,142,158,144,159,160,143,161,24,162,163,109,164,87,150,92,146,147,37,148],"verify directory structure parallel audit","audit","parallel","guidance","batches","reading","import"]