[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKA79DC1R70K7XAST4ZK46":3,"skill-same:01M6KKA79DC1R70K7XAST4ZK46":67},{"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":22,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":13,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M6KKA79DC1R70K7XAST4ZK46","data-driven-panel",null,"Create dashboard panel components with integrated resilient data services, combining UI construction and data fetching into a unified pattern.","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\u002Fdata-driven-panel\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[23,24,25,26,27,28,29,30,31,32,33,34],"data","driven","panel","data driven panel","dashboard","components","create","ui","services","pattern","with","data fetching","2026-11-10 10:12:30",false,"---\nname: data-driven-panel\ndescription: Create dashboard panel components with integrated resilient data services, combining UI construction and data fetching into a unified pattern.\n---\n\n# Data-Driven Panel Pattern\n\nCreate dashboard panels that seamlessly integrate UI construction with resilient data fetching. Each panel is a self-contained component that manages its own data lifecycle.\n\n## Architecture Overview\n\n```\nPanel (base class)\n├── element: HTMLElement (outer container)\n│   ├── header (title, status indicators)\n│   └── content (data display area)\n└── DataService (internal)\n    ├── Circuit Breaker (failure handling)\n    └── Caching layer\n```\n\n## Implementation\n\n### 1. Base Panel with Integrated Data Service\n\nCreate `src\u002Fcomponents\u002FDataPanel.ts`:\n\n```typescript\nimport { createCircuitBreaker } from '..\u002Futils\u002Fcircuit-breaker';\n\nexport interface PanelOptions\u003CT> {\n  id: string;\n  title: string;\n  showCount?: boolean;\n  className?: string;\n  dataService: () => Promise\u003CT>;\n  defaultValue: T;\n  serviceOptions?: {\n    maxFailures?: number;\n    cooldownMs?: number;\n    cacheTtlMs?: number;\n  };\n}\n\nexport abstract class DataPanel\u003CT> {\n  protected element: HTMLElement;\n  protected content: HTMLElement;\n  private breaker: CircuitBreaker\u003CT>;\n  private refreshTimer: ReturnType\u003Ctypeof setInterval> | null = null;\n\n  constructor(protected options: PanelOptions\u003CT>) {\n    this.breaker = createCircuitBreaker\u003CT>({\n      name: options.id,\n      maxFailures: options.serviceOptions?.maxFailures ?? 2,\n      cooldownMs: options.serviceOptions?.cooldownMs ?? 300_000,\n      cacheTtlMs: options.serviceOptions?.cacheTtlMs ?? 60_000,\n    });\n\n    this.element = document.createElement('div');\n    this.element.className = `panel ${options.className || ''}`;\n    this.element.dataset.panel = options.id;\n\n    \u002F\u002F Initialize UI\n    this.initUI();\n    this.fetchData();\n  }\n\n  private initUI(): void {\n    \u002F\u002F Header setup\n    const header = document.createElement('div');\n    header.className = 'panel-header';\n    \n    const title = document.createElement('span');\n    title.className = 'panel-title';\n    title.textContent = this.options.title;\n    header.appendChild(title);\n\n    \u002F\u002F Content area\n    this.content = document.createElement('div');\n    this.content.className = 'panel-content';\n\n    this.element.appendChild(header);\n    this.element.appendChild(this.content);\n    this.showLoading();\n  }\n\n  protected async fetchData(): Promise\u003Cvoid> {\n    try {\n      const data = await this.breaker.execute(\n        this.options.dataService,\n        this.options.defaultValue\n      );\n      this.render(data);\n    } catch (err) {\n      this.showError('Failed to load data', () => this.fetchData());\n    }\n  }\n\n  protected abstract render(data: T): void;\n\n  public showLoading(message = 'Loading...'): void {\n    this.content.innerHTML = `\u003Cdiv class=\"loading\">${message}\u003C\u002Fdiv>`;\n  }\n\n  public showError(message: string, retryHandler: () => void): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"error\">\n        \u003Cp>${message}\u003C\u002Fp>\n        \u003Cbutton class=\"retry-btn\">Retry\u003C\u002Fbutton>\n      \u003C\u002Fdiv>`;\n    this.content.querySelector('.retry-btn')?.addEventListener('click', retryHandler);\n  }\n\n  public setAutoRefresh(intervalMs: number): void {\n    this.refreshTimer = setInterval(() => this.fetchData(), intervalMs);\n  }\n\n  public destroy(): void {\n    if (this.refreshTimer) clearInterval(this.refreshTimer);\n    this.element.remove();\n  }\n}\n```\n\n### 2. Concrete Panel Implementation Example\n\n```typescript\nimport { DataPanel } from '.\u002FDataPanel';\n\ninterface StockData {\n  quotes: StockQuote[];\n  updatedAt: string;\n}\n\nexport class StockPanel extends DataPanel\u003CStockData> {\n  constructor() {\n    super({\n      id: 'stocks',\n      title: 'Stock Market',\n      dataService: fetchStockData,\n      defaultValue: { quotes: [], updatedAt: new Date().toISOString() },\n      serviceOptions: {\n        cacheTtlMs: 30_000 \u002F\u002F Refresh cache every 30 seconds\n      }\n    });\n    this.setAutoRefresh(60_000); \u002F\u002F Auto-refresh every minute\n  }\n\n  protected render(data: StockData): void {\n    const html = data.quotes.map(quote => `\n      \u003Cdiv class=\"stock-item\">\n        \u003Cspan class=\"symbol\">${quote.symbol}\u003C\u002Fspan>\n        \u003Cspan class=\"price\">$${quote.price?.toFixed(2) || '—'}\u003C\u002Fspan>\n      \u003C\u002Fdiv>\n    `).join('');\n    \n    this.content.innerHTML = `\n      \u003Cdiv class=\"stock-list\">\n        ${html}\n        \u003Cdiv class=\"updated\">Updated: ${new Date(data.updatedAt).toLocaleTimeString()}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n}\n```\n\n### 3. Data Service Implementation\n\n```typescript\n\u002F\u002F src\u002Fservices\u002FstockService.ts\ninterface StockQuote {\n  symbol: string;\n  price: number | null;\n}\n\nexport async function fetchStockData(): Promise\u003CStockData> {\n  const response = await fetch('\u002Fapi\u002Fstocks');\n  if (!response.ok) throw new Error(`HTTP ${response.status}`);\n  const quotes: StockQuote[] = await response.json();\n  return {\n    quotes,\n    updatedAt: new Date().toISOString()\n  };\n}\n```\n\n## Key Benefits\n\n1. **Unified Pattern**: Combines UI and data logic in one coherent pattern\n2. **Resilient Data Fetching**: Built-in circuit breaker and caching\n3. **Simplified Implementation**: Concrete panels only need to implement rendering\n4. **Consistent Behavior**: All panels share the same loading\u002Ferror states\n5. **Flexible Configuration**: Service options customizable per panel\n\n## Best Practices\n\n1. **Service Composition**: Create small, focused services for each data type\n2. **Default Values**: Always provide meaningful fallback data\n3. **Error Boundaries**: Use the built-in error handling for consistency\n4. **Memory Management**: Clean up timers and event listeners in destroy()\n5. **Type Safety**: Maintain strong typing throughout the data flow\n","# Data-Driven Panel Pattern\n\nCreate dashboard panels that seamlessly integrate UI construction with resilient data fetching. Each panel is a self-contained component that manages its own data lifecycle.\n\n## Architecture Overview\n\n```\nPanel (base class)\n├── element: HTMLElement (outer container)\n│   ├── header (title, status indicators)\n│   └── content (data display area)\n└── DataService (internal)\n    ├── Circuit Breaker (failure handling)\n    └── Caching layer\n```\n\n## Implementation\n\n### 1. Base Panel with Integrated Data Service\n\nCreate `src\u002Fcomponents\u002FDataPanel.ts`:\n\n```typescript\nimport { createCircuitBreaker } from '..\u002Futils\u002Fcircuit-breaker';\n\nexport interface PanelOptions\u003CT> {\n  id: string;\n  title: string;\n  showCount?: boolean;\n  className?: string;\n  dataService: () => Promise\u003CT>;\n  defaultValue: T;\n  serviceOptions?: {\n    maxFailures?: number;\n    cooldownMs?: number;\n    cacheTtlMs?: number;\n  };\n}\n\nexport abstract class DataPanel\u003CT> {\n  protected element: HTMLElement;\n  protected content: HTMLElement;\n  private breaker: CircuitBreaker\u003CT>;\n  private refreshTimer: ReturnType\u003Ctypeof setInterval> | null = null;\n\n  constructor(protected options: PanelOptions\u003CT>) {\n    this.breaker = createCircuitBreaker\u003CT>({\n      name: options.id,\n      maxFailures: options.serviceOptions?.maxFailures ?? 2,\n      cooldownMs: options.serviceOptions?.cooldownMs ?? 300_000,\n      cacheTtlMs: options.serviceOptions?.cacheTtlMs ?? 60_000,\n    });\n\n    this.element = document.createElement('div');\n    this.element.className = `panel ${options.className || ''}`;\n    this.element.dataset.panel = options.id;\n\n    \u002F\u002F Initialize UI\n    this.initUI();\n    this.fetchData();\n  }\n\n  private initUI(): void {\n    \u002F\u002F Header setup\n    const header = document.createElement('div');\n    header.className = 'panel-header';\n    \n    const title = document.createElement('span');\n    title.className = 'panel-title';\n    title.textContent = this.options.title;\n    header.appendChild(title);\n\n    \u002F\u002F Content area\n    this.content = document.createElement('div');\n    this.content.className = 'panel-content';\n\n    this.element.appendChild(header);\n    this.element.appendChild(this.content);\n    this.showLoading();\n  }\n\n  protected async fetchData(): Promise\u003Cvoid> {\n    try {\n      const data = await this.breaker.execute(\n        this.options.dataService,\n        this.options.defaultValue\n      );\n      this.render(data);\n    } catch (err) {\n      this.showError('Failed to load data', () => this.fetchData());\n    }\n  }\n\n  protected abstract render(data: T): void;\n\n  public showLoading(message = 'Loading...'): void {\n    this.content.innerHTML = `\u003Cdiv class=\"loading\">${message}\u003C\u002Fdiv>`;\n  }\n\n  public showError(message: string, retryHandler: () => void): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"error\">\n        \u003Cp>${message}\u003C\u002Fp>\n        \u003Cbutton class=\"retry-btn\">Retry\u003C\u002Fbutton>\n      \u003C\u002Fdiv>`;\n    this.content.querySelector('.retry-btn')?.addEventListener('click', retryHandler);\n  }\n\n  public setAutoRefresh(intervalMs: number): void {\n    this.refreshTimer = setInterval(() => this.fetchData(), intervalMs);\n  }\n\n  public destroy(): void {\n    if (this.refreshTimer) clearInterval(this.refreshTimer);\n    this.element.remove();\n  }\n}\n```\n\n### 2. Concrete Panel Implementation Example\n\n```typescript\nimport { DataPanel } from '.\u002FDataPanel';\n\ninterface StockData {\n  quotes: StockQuote[];\n  updatedAt: string;\n}\n\nexport class StockPanel extends DataPanel\u003CStockData> {\n  constructor() {\n    super({\n      id: 'stocks',\n      title: 'Stock Market',\n      dataService: fetchStockData,\n      defaultValue: { quotes: [], updatedAt: new Date().toISOString() },\n      serviceOptions: {\n        cacheTtlMs: 30_000 \u002F\u002F Refresh cache every 30 seconds\n      }\n    });\n    this.setAutoRefresh(60_000); \u002F\u002F Auto-refresh every minute\n  }\n\n  protected render(data: StockData): void {\n    const html = data.quotes.map(quote => `\n      \u003Cdiv class=\"stock-item\">\n        \u003Cspan class=\"symbol\">${quote.symbol}\u003C\u002Fspan>\n        \u003Cspan class=\"price\">$${quote.price?.toFixed(2) || '—'}\u003C\u002Fspan>\n      \u003C\u002Fdiv>\n    `).join('');\n    \n    this.content.innerHTML = `\n      \u003Cdiv class=\"stock-list\">\n        ${html}\n        \u003Cdiv class=\"updated\">Updated: ${new Date(data.updatedAt).toLocaleTimeString()}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n}\n```\n\n### 3. Data Service Implementation\n\n```typescript\n\u002F\u002F src\u002Fservices\u002FstockService.ts\ninterface StockQuote {\n  symbol: string;\n  price: number | null;\n}\n\nexport async function fetchStockData(): Promise\u003CStockData> {\n  const response = await fetch('\u002Fapi\u002Fstocks');\n  if (!response.ok) throw new Error(`HTTP ${response.status}`);\n  const quotes: StockQuote[] = await response.json();\n  return {\n    quotes,\n    updatedAt: new Date().toISOString()\n  };\n}\n```\n\n## Key Benefits\n\n1. **Unified Pattern**: Combines UI and data logic in one coherent pattern\n2. **Resilient Data Fetching**: Built-in circuit breaker and caching\n3. **Simplified Implementation**: Concrete panels only need to implement rendering\n4. **Consistent Behavior**: All panels share the same loading\u002Ferror states\n5. **Flexible Configuration**: Service options customizable per panel\n\n## Best Practices\n\n1. **Service Composition**: Create small, focused services for each data type\n2. **Default Values**: Always provide meaningful fallback data\n3. **Error Boundaries**: Use the built-in error handling for consistency\n4. **Memory Management**: Clean up timers and event listeners in destroy()\n5. **Type Safety**: Maintain strong typing throughout the data flow\n",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","showcase\u002Fskills\u002Fdata-driven-panel","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":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add AG064\u002FOpenSpace --skill data-driven-panel",{"tool":53,"command":54},"bunx","bunx skills add AG064\u002FOpenSpace --skill data-driven-panel",{"tool":56,"command":57},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill data-driven-panel","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fdata-driven-panel\u002FSKILL.md",true,[61],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},".skill_id","OTHER","其他",36,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fdata-driven-panel\u002F.skill_id",[68,92,108,117,140,156],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":35},"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",[],[75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91],"write special chars ts check","check","write","filters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":35},"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",[],[99,100,77,88,101,102,89,90,103,104,105,106,107,81,83,33],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":35},"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",[],[77,115,90,81,105,88,116,89,83],"write special chars heredoc","shell",{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":124,"publishedAt":35},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference","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.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[123],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[125,126,127,27,91,128,129,130,131,132,81,133,25,134,135,136,137,138,23,139],"reference","worldmonitor","worldmonitor reference","css","architecture","extracting","hierarchy","source","layer","patterns","edge functions","integrations","open","api","scheduler",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":35},"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",[],[147,148,149,150,81,151,33,152,153,154,155],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":35},"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",[],[163,164,165,166,167,168,89,169,170,171],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]