creating-plugins
它能做什么
这项技能指导为 EmDash 内容管理系统构建称为插件的扩展功能。适合想为 EmDash 网站添加自定义功能或管理页面的开发者。
适用场景
- ✓当你想通过插件为 EmDash 网站添加新功能的时候。
- ✓当你需要一个带有自己的管理页面或 API 路由的插件的时候。
- ✓当你想发布一个其他人可以从注册中心安装的插件的时候。
技能链接
https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我创建一个 EmDash 插件,在管理后台添加一个自定义表单?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在沙盒插件和受信任的原生插件之间做出选择,搭建项目框架,并实现钩子、路由和管理页面。然后它会运行该插件的测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Creating EmDash plugins
Build against the API that reaches the intended execution mode. Source types and production-boundary tests take precedence over examples in this skill when they disagree.
Choose a format
| Format | Runtime source | Admin UI | Distribution |
|---|---|---|---|
| Sandboxed | src/plugin.ts default-exports a SandboxedPlugin |
Block Kit pages, widgets, saved-entry panels, and actions | Plugin CLI and registry |
| Native | definePlugin() / createPlugin() |
React, Block Kit, and Astro components | Trusted site dependency only |
Use a sandboxed plugin unless the feature needs host-process access, React admin code, Astro rendering components, raw page fragments, or custom Portable Text block definitions. Native plugins run with the site's authority and cannot be installed from the registry.
Scaffold a sandboxed plugin
pnpm dlx @emdash-cms/plugin-cli init my-plugin
cd my-plugin
pnpm install
pnpm run test
The manifest is the identity and trust contract. Runtime hooks and routes live in src/plugin.ts; the CLI generates descriptors, manifests, and bundles. Do not create a separate descriptor factory or sandbox-entry.ts.
import type { SandboxedPlugin } from "emdash/plugin";
const plugin: SandboxedPlugin = {
hooks: {
"content:afterSave": async (event, ctx) => {
ctx.log.info("Content saved", { id: event.content.id });
},
},
};
export default plugin;
Import authoring types from emdash/plugin with import type. The CLI bundles value imports such as pluginRoute() and pluginResponse() from emdash/plugin and portableTextToMarkdown() from emdash/client. Sandboxed runtime code can use Web APIs but not Node.js built-ins.
Declare access
Declare every host API in emdash-plugin.jsonc. Adding authority, exposing a route publicly, or adding MCP tools requires renewed administrator approval.
| Capability | Grants |
|---|---|
schema:read |
Public collection and field definitions |
admin.editor-draft:read |
Selected unsaved field values after an explicit editor interaction |
admin.editor-draft:patch |
Host-validated unsaved field changes proposed for editor review |
content:read |
Content identity, translations, and published public URLs |
content:revisions:read |
Retained revision data; implies content read |
content:write |
Create, update, delete, and translation creation; implies read |
content:publish |
Revision-fenced publish, unpublish, schedule, and unschedule; implies read |
content:restore |
Revision-fenced reads and restoration of trashed content |
hooks.content-policy:register |
Pre-publish, pre-schedule, and pre-unpublish policy hooks |
taxonomies:read |
Taxonomy definitions, terms, and entry assignments |
taxonomies:write |
Term creation and assignment deltas; implies read |
bylines:read |
Public byline profiles and single or batched entry credits |
redirects:read |
Versioned redirect inspection |
redirects:write |
Versioned redirect creation, update, and deletion; implies read |
comments:read |
Stored non-trashed comments and their personal data |
comments:moderate |
Expected-status moderation; implies read |
media:read |
Ready-media metadata and authenticated asset URLs |
media:bytes:read |
Bounded media bytes and content hashes |
| `m |
常见问题
沙盒插件和原生插件有什么区别?
沙盒插件以受限的权限运行,可以从注册中心安装;原生插件拥有网站的全部权限,只适合受信任的代码。
它会提供入门项目吗?
会。插件命令会创建一个起始项目。
插件可以添加 React 页面吗?
原生插件可以在管理页面和网站页面中使用 React 和 Astro 组件。
详情
作者的原始描述
Create EmDash CMS plugins with sandboxed hooks, routes, storage, content and media APIs, MCP tools, and declarative admin UI, or native React and Astro extensions. Use when scaffolding or implementing an EmDash plugin.
repo: emdash-cms/emdash
热度
- GitHub 星标
- 14k
- 排名
- #11247
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
adversarial-reviewer
14k帮你的智能体在代码变更中寻找隐藏的缺陷和不安全的假设;当你要求时,它会超越普通的审查。
agent-browser
14k让你的智能体在真实浏览器中测试网页,检查用户看到的内容,验证操作,并截图作为证据。
building-emdash-site
14k帮你的智能体在 Astro 上构建 EmDash CMS 项目的网站部分,涵盖内容、结构、菜单、分类法和部署。
emdash-cli
14k让你的智能体通过命令行管理 EmDash 网站,包括内容、媒体、菜单、迁移,以及整站导出或导入。