[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXDRRCW14V3CS7JCJQ6X82":3,"skill-same:01M6HXDRRCW14V3CS7JCJQ6X82":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":6,"updatedAt":56,"install":57,"resources":70},"01M6HXDRRCW14V3CS7JCJQ6X82","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.","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"worldmonitor reference","worldmonitor","reference","edge functions","source","for","layer","extracting","panel","patterns","css","integrations","open","api","data","edge","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","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fworldmonitor-reference",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add HKUDS\u002FAgentPilot --skill worldmonitor-reference",{"tool":63,"command":64},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill worldmonitor-reference",{"tool":66,"command":67},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill worldmonitor-reference","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",true,[71],{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},".skill_id","OTHER","其他",36,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fworldmonitor-reference\u002F.skill_id",[78,98,117,142,165,187],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":44},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[80,85,86,87,88,89,90,91,92,93,94,95,96,97],"prepare","requests","with","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":44},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[100,105,106,107,108,109,110,111,112,113,114,115,116],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":128,"publishedAt":44},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[123],{"categoryNo":124,"categoryName":125,"taxonomyType":126,"taxonomyTypeDesc":127},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[129,130,131,108,132,133,134,135,136,137,138,139,140,141],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":149,"publishedAt":44},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[148],{"categoryNo":124,"categoryName":125,"taxonomyType":126,"taxonomyTypeDesc":127},[150,151,152,108,153,154,155,156,157,131,107,92,158,159,160,29,161,162,163,164],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":171,"publishedAt":44},"01M6HYAM9FSGV6E52AYENDQXYH","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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[172,173,174,175,176,177,178,179,180,181,43,182,183,184,29,185,186],"write special chars ts check","write","check","type","files","filters","only","template","file","python","output","Existing","type-checking","errors","script",{"skillNo":188,"name":189,"nameZh":6,"description":190,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":191,"categories":192,"keywords":193,"publishedAt":44},"01M6HYAH05HGV7SVWSVR8PJRQD","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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[194,195,173,87,29,186,196,197,198,199,200,179,180,201,202,181],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]