跳到正文
Skillpedia
网站与界面(前端)7.6k · #13156

extension-points

它能做什么

这项技能描述扩展插槽系统:应用中命名的空位由可安装的组件填充。它涵盖插槽、插槽目标以及用户的安装操作。适合希望应用能承载可选组件的开发者。

适用场景

  • ✓当启用了扩展的应用需要在某个命名插槽中显示组件的时候。
  • ✓当一个现有的一次性自定义模块应变为可安装到插槽中的组件的时候。
  • ✓当你需要了解插槽及其目标如何存储的时候。

技能链接

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/extension-points/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/extension-points/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 extensions skill). They are NOT LLM "tools" (function calls). The slot-system tables are still physically named tool_slots and tool_slot_installs for back-compat — see the table at the bottom of this doc and the "Database & API names" section in the extensions skill.

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.bottom
  • mail.thread-toolbar.actions
  • clips.right-panel.tabs
  • calendar.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.

  1. Create the extension with create-extension. The HTML can read window.slotContext to get the host's context (the contact email, recording id, etc.) and subscribe to changes via window.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>
    
  2. Declare the slot target with add-extension-slot-target:

    add-extension-slot-target { extensionId: "<id>", slotId: "mail.contact-sidebar.bottom" }
    
  3. 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/tools continues 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 as slotContext. 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. (The toolClassName prop 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能