Skillpedia
المواقع والواجهات (frontend)41k · #6843

validating-and-publishing-canvases

ما الذي تفعله

تتحقق هذه المهارة من شيفرة المصدر للوحة Canvas وتفحص الأذونات المعلنة، ثم تنشرها في PostHog بأمان. وهي مناسبة للبنّائين الذين يريدون إصدار تعديلات اللوحة دون أن تنكسر أو تضيع أعمال غيرهم.

متى تستخدمها

  • ✓عندما تنتهي من تحرير لوحة Canvas وتريد نشرها.
  • ✓عندما يفشل النشر بخطأ تحقق أو بتعارض في الإصدار.
  • ✓عندما تريد اختبار إصدار جديد قبل أن يصبح مباشراً.

رابط المهارة

https://github.com/PostHog/posthog/blob/master/products/canvas/skills/validating-and-publishing-canvases/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/PostHog/posthog/blob/master/products/canvas/skills/validating-and-publishing-canvases/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“افحص لوحة Canvas لدي من المشاكل وانشرها، ولكن تأكد من عدم الكتابة فوق تغييرات أي شخص آخر.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يقرأ الذكاء الاصطناعي الإصدار الحالي، ويصلح رسائل التحقق التي يتلقاها، وينشر مقابل الإصدار نفسه بالضبط حتى لا تُكتب فوق الأعمال الأحدث. ثم يُضاف بناء جديد إلى الطابور، وتعرض اللوحة آخر بناء ناجح حتى ينتهي البناء الجديد.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Validating and publishing canvases

A canvas's source lives in PostHog, versioned per publish. Publishing is guarded: every edit is based on a specific version, and the server refuses to overwrite newer work. Every publish queues a server-side build, and the canvas renders the last successful build.

The source project

canvas-source-retrieve returns:

  • project — schemaVersion (1), files (path → content), entryHtml ("index.html"), dependencies (exact platform-pinned versions), canvasSdkVersion, capabilities.
  • current_version_id — the version your edits are based on. Keep it; the publish needs it. It is null for a canvas that has never been published — pass that null on the first publish.

Keep index.html and dependencies exactly as returned. You may add relative source files and admitted assets to the project. Use ?worker for a self-contained module worker and represent binary assets as base64 entries in assets; new npm dependencies or dependency-version drift fail validation.

Declare capabilities

The host enforces project.capabilities at runtime, so an undeclared ph call builds fine and then dies in the rendered canvas. Declare:

  • capabilities.posthog.insights — every insight short id the canvas passes to ph.loadInsight.
  • capabilities.posthog.captureEvents — every event name it passes to ph.capture.
  • capabilities.posthog.inlineQueries: true — when it calls ph.query at all.
  • capabilities.posthog.agentRequests: true — when it calls ph.agent.request.
  • capabilities.connectors — one { "provider", "tools" } entry per third-party provider the canvas reads through ph.connectors.call, listing every tool it calls on that provider. A provider is a native id (github) or mcp:<server host> (mcp:mcp.calendly.com). Unknown providers, unregistered native tools, and private MCP hosts fail validation; every declared tool must have is_read_only: true in the catalog. An upstream hint alone does not grant access. A canvas with connectors cannot declare shared state.
  • capabilities.network.origins — each exact HTTPS origin used by fetch, XMLHttpRequest, or an external stylesheet, image, font, media file, or frame. Remote scripts remain blocked. Do not include paths, credentials, queries, fragments, or wildcards. The host must be public: loopback and private IPs, single-label names like intranet, and the .local, .localhost, .internal, and .home.arpa suffixes are all rejected, so a local dev host such as https://localhost:8010 fails validation with an invalid_network_origin error. Data sent to a declared origin leaves PostHog and appears in the capability review before promotion.

Before validation, inventory every literal external URL in every source file. Classify navigation links and ph.openExternal() URLs as navigation; they do not need a network origin. For every request or resource URL, declare its scheme + host + optional port only. Include every origin a request redirects to and every secondary origin a stylesheet references for fonts or images. Never infer that one CDN hostname covers another.

Validation rejects undeclared literal calls and resource URLs (capability_missing_* diagnostics) so you can fix them before publishing. Dynamic URLs and redirect destinations cannot be inferred, so the inventory is still required even when validation is clean.

Validate until clean

canvas-validate-create is side-effect free; call it as often as needed. Diagnostics carry severity, a stable code, a message, and (for file-specific problems) path and line:

  • error diagnostics block publishing — fix all of them. Common ones: import_not_allowed (bare imports are limited to the dependencies returned in the source project), forbidden_dynamic_import / forbidden_require / forbidden_inline_script, invalid_path, capability_missing_insight / capability_missing_capture_event / capability_missing_inline_queries / capability_missing_agent_requests / capability_missing_network_origin, dependency_not_admitted / dependency_version_mismatch, platform_token_redeclared (a CSS variable named like a Quill token that the platform stylesheet sets on every element, so the value never applies; prefix your own variables), and path/size violations.
  • warning diagnostics don't block, but heed them: network_fetch / network_xhr mean the code reaches for the network directly.
الأسئلة الشائعة

ماذا لو فشل النشر بتعارض؟

هذا يعني أن شخصاً غيّر اللوحة بعد قراءتها. يقرأ الذكاء الاصطناعي أحدث إصدار، ويدمج تغييراته ويحاول مرة أخرى.

لماذا أرى النسخة القديمة بعد النشر؟

يعرض PostHog آخر بناء ناجح، ويظهر البناء الجديد بعد انتهاء البناء المنتظر في الطابور.

لماذا يفشل استدعاء بيانات بعد النشر؟

يجب تعريف مصادر البيانات في إعدادات اللوحة قبل أن تستطيع استخدامها.

التفاصيل

الوصف الأصلي من المؤلف

Validate and publish a canvas source project safely: the source-project shape, declared capabilities, reading the current version pointer, iterating on validation diagnostics, guarded publishing with expected_current_version_id, staging a draft build and promoting it, waiting out the queued build, and recovering from a 409 version_conflict or a 429 capacity limit without overwriting concurrent work. Use whenever a canvas edit is ready to save, a draft build is wanted, a canvas publish or build returns diagnostics or a conflict, or a task needs to understand canvas version history.

repo: PostHog/posthog

الشعبية

نجوم GitHub
41k
الترتيب
#6843
الترخيص
—
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة