validating-and-publishing-canvases
它能做什么
本技能验证画布的源代码,检查其声明的权限,并将其安全地发布到 PostHog。适合希望发布画布改动、又不破坏内容或丢失他人工作的构建者。
适用场景
- ✓当你完成画布编辑,想要发布时。
- ✓当发布因验证错误或版本冲突而失败的时候。
- ✓当你想在正式上线前测试新版本时。
技能链接
https://github.com/PostHog/posthog/blob/master/products/canvas/skills/validating-and-publishing-canvases/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的画布是否有问题,然后发布,但要确保不会覆盖他人的改动。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会读取当前版本,修复收到的验证信息,并基于该确切版本进行发布,因此较新的工作不会被覆盖。随后,新版本进入构建队列,在构建完成之前,画布会显示最近一次成功的版本。
技术内容(原始 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 isnullfor a canvas that has never been published — pass thatnullon 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 toph.loadInsight.capabilities.posthog.captureEvents— every event name it passes toph.capture.capabilities.posthog.inlineQueries: true— when it callsph.queryat all.capabilities.posthog.agentRequests: true— when it callsph.agent.request.capabilities.connectors— one{ "provider", "tools" }entry per third-party provider the canvas reads throughph.connectors.call, listing every tool it calls on that provider. A provider is a native id (github) ormcp:<server host>(mcp:mcp.calendly.com). Unknown providers, unregistered native tools, and private MCP hosts fail validation; every declared tool must haveis_read_only: truein 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 byfetch,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 likeintranet, and the.local,.localhost,.internal, and.home.arpasuffixes are all rejected, so a local dev host such ashttps://localhost:8010fails validation with aninvalid_network_originerror. 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:
errordiagnostics 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.warningdiagnostics don't block, but heed them:network_fetch/network_xhrmean the code reaches for the network directly.
常见问题
如果发布时出现冲突怎么办?
这表示在读取之后,有人修改了画布。AI 会读取最新版本,合并其改动,然后重新尝试。
发布后为什么仍然看到旧版本?
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
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
depot-ci
41k帮你的智能体设置并运行 Depot CI 工作流(GitHub Actions 的替代方案),包括迁移现有工作流和读取运行日志。
depot-container-builds
41k帮你的智能体在 Depot 的远程构建器上构建 Docker 镜像,包括多平台镜像、推送到镜像仓库,以及修复构建失败。
depot-github-runners
41k帮你的智能体把 GitHub Actions 任务迁移到 Depot 托管的运行器上,选择运行器规格和标签,并排查运行器设置问题。
editing-agents-md
41k帮你的智能体判断某条规则应写入 AGENTS.md 还是 CLAUDE.md,并以不会让文件臃肿的方式写下,确保规则真正生效。