Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)7.6k · #13156

extension-points

Skill này làm gì

Skill này mô tả hệ thống extension slot, nơi các vị trí trống có tên trong ứng dụng được lấp đầy bằng các widget có thể cài đặt. Nó bao gồm slot, đích của slot và việc người dùng cài đặt. Skill dành cho lập trình viên muốn ứng dụng của mình chứa các widget tùy chọn.

Khi nào nên dùng

  • ✓Khi một ứng dụng hỗ trợ extension cần hiển thị một widget trong một slot có tên.
  • ✓Khi một khối tùy chỉnh dùng một lần hiện có nên trở thành thứ có thể cài vào một slot.
  • ✓Khi bạn cần biết slot và đích của chúng được lưu như thế nào.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/extension-points/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể thêm một slot vào bảng điều khiển của tôi để người dùng cài widget thời tiết ở thanh bên không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Lập trình viên đặt một slot có tên trong layout của ứng dụng. Một widget đăng ký rằng nó có thể lấp đầy slot, và người dùng có thể cài nó ở đó.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

Slot là gì?

Slot là một vị trí có tên trong layout của ứng dụng, nơi một widget có thể xuất hiện.

Tính năng này có bật mặc định không?

Không. Skill nói hầu hết ứng dụng giữ việc tạo và khám phá extension ở trạng thái tắt, nhưng vẫn giữ các khối đã cài.

Chúng có giống công cụ LLM không?

Không. Extension ở đây là widget mini app, không phải các lời gọi hàm mà AI sử dụng.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
7.6k
Vị trí xếp hạng
#13156
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự