extension-points
它能做什么
这项技能描述扩展插槽系统:应用中命名的空位由可安装的组件填充。它涵盖插槽、插槽目标以及用户的安装操作。适合希望应用能承载可选组件的开发者。
适用场景
- ✓当启用了扩展的应用需要在某个命名插槽中显示组件的时候。
- ✓当一个现有的一次性自定义模块应变为可安装到插槽中的组件的时候。
- ✓当你需要了解插槽及其目标如何存储的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/extension-points/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你能为我的仪表板添加一个插槽,让用户可以在侧边栏安装天气组件吗?”
每周 5 个新技能,1 分钟读完。
工作原理
开发者在应用的布局中放置一个命名插槽。组件注册它可以填充该插槽,用户便可以在那里安装它。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Extension Points
Terminology note. "Extensions" in this doc are the framework's sandboxed Alpine.js mini-app primitive (see the
extensionsskill). They are NOT LLM "tools" (function calls). The slot-system tables are still physically namedtool_slotsandtool_slot_installsfor back-compat — see the table at the bottom of this doc and the "Database & API names" section in theextensionsskill.
Mental model
Slots are named React-shaped holes in apps. Extensions are widgets that opt into filling those holes. The framework matches them up by string ID.
Three primitives:
| Primitive | What it is |
|---|---|
| Slot | <ExtensionSlot id="..." context={...} /> dropped into an app's JSX |
| Slot target | A row saying "extension X can render in slot Y" — tool_slots table (Drizzle: extensionSlots) |
| Slot install | A row saying "user U wants extension X in slot Y" — tool_slot_installs (Drizzle: extensionSlotInstalls) |
Slots do not make extensions a default product surface. Most apps keep extension creation and discovery disabled while preserving installed blocks and old deep links for compatibility. Add a slot only when the app deliberately supports this customization seam; otherwise implement the requested behavior in native app code.
When <ExtensionSlot> renders, it queries the user's installs and mounts
one <EmbeddedTool> (a small auto-sized iframe) per install, pushing the
slot's context into each via postMessage. (The component is still exported
as EmbeddedTool for back-compat.)
Slot ID convention
<app>.<area>.<position> — three dot-separated lowercase-kebab segments.
mail.contact-sidebar.bottommail.thread-toolbar.actionsclips.right-panel.tabscalendar.event-detail.bottom
Stable strings. Renaming a slot is a data migration — same as renaming a route.
How to author an extension that fills a slot
Only follow this flow when the host app explicitly enables extensions and the user has asked for a one-off custom block. Reusable behavior belongs in app code.
Create the extension with
create-extension. The HTML can readwindow.slotContextto get the host's context (the contact email, recording id, etc.) and subscribe to changes viawindow.onSlotContext(fn).<div x-data="{ contact: null }" x-init="contact = window.slotContext; window.onSlotContext(c => contact = c)" > <template x-if="contact"> <div class="rounded-lg border p-4 m-4"> <p class="text-sm"> Notes for <span x-text="contact.contactEmail"></span> </p> </div> </template> </div>Declare the slot target with
add-extension-slot-target:add-extension-slot-target { extensionId: "<id>", slotId: "mail.contact-sidebar.bottom" }Install it for the current user with
install-extension:install-extension { extensionId: "<id>", slotId: "mail.contact-sidebar.bottom" }
The slot will pick up the install on its next render (≤2s via polling sync, immediate after the action's UI invalidation).
How to declare a slot in your app
Drop <ExtensionSlot> wherever you want to allow extensions:
import { ExtensionSlot } from "@agent-native/core/client/extensions";
// inside your component
<ExtensionSlot
id="mail.contact-sidebar.bottom"
context={{ contactEmail: contact.email, contactName: contact.name }}
showEmptyAffordance
/>;
The legacy import path
@agent-native/core/client/toolscontinues to re-export the same component for back-compat with existing templates.
Props:
id— slot identifier. Must match what extensions target.context— object pushed to each embedded extension asslotContext. Re-pushed whenever this prop changes.showEmptyAffordance— when true, shows a "+ Add widget" button in the empty state. Default: false (slot renders nothing when empty).className/toolClassName— optional styling hooks. (ThetoolClassNameprop name is kept for back-compat; it styles the embedded extension's iframe wrapper.)
The host doesn't register slots in advance — <ExtensionSlot> is the
declaration. If an extension ta
常见问题
什么是插槽?
插槽是应用布局中的一个命名位置,组件可以出现在这里。
这默认开启吗?
不开启。技能说明大多数应用会关闭扩展的创建和发现功能,同时保留已安装的模块。
它们与 LLM 工具相同吗?
不同。这里的扩展是小型应用组件,而不是 AI 使用的函数调用。
详情
作者的原始描述
How extensions render as widgets inside other apps via named UI slots — the framework's optional extension system. Use when an extension-enabled app needs to wire an ExtensionSlot or make an existing one-off custom block installable into a slot.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13156
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …